1/*  Part of SWISH
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@cs.vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (C): 2017, VU University Amsterdam
    7			 CWI Amsterdam
    8    All rights reserved.
    9
   10    Redistribution and use in source and binary forms, with or without
   11    modification, are permitted provided that the following conditions
   12    are met:
   13
   14    1. Redistributions of source code must retain the above copyright
   15       notice, this list of conditions and the following disclaimer.
   16
   17    2. Redistributions in binary form must reproduce the above copyright
   18       notice, this list of conditions and the following disclaimer in
   19       the documentation and/or other materials provided with the
   20       distribution.
   21
   22    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   23    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   24    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   25    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   26    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   27    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   28    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   29    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   30    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   32    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   33    POSSIBILITY OF SUCH DAMAGE.
   34*/
   35
   36:- module(config_r_serve, []).   37:- use_module(library(settings)).   38:- use_module(swish:swish(lib/r_swish)).

Provide R access using Rserve

This config file provides access to R by means of the Rserve package.

To use this config file, you need to

  1. Install the Rserve client Prolog pack from Prolog:
    $ git submodule update pack/rserve_client
    $ swipl run.pl
    ?- pack_rebuild(rserve_client).
  2. Install R in an OS sandbox. We provided a Docker recipe for that at https://github.com/JanWielemaker/rserve-sandbox. This docker image makes Rserve accessible at `/home/rserve/socket`, which is accessible for users in the group rserve
  3. Add the user running SWISH to the group rserve to provide access to the Rserve socket. */
   66% EDIT: COMMENT IF R IS NOT RUNNING IN AN OS SANDBOX.
   67:- use_module(library(r/r_sandbox)).   68
   69% EDIT: Uncomment and edit these values if Rserve is accessible
   70% from another location.  If a `socket` is configured and exists
   71% the socket is used.  Otherwise it will try a TCP connection to
   72% the given host and port.
   73%
   74% IF R IS NOT RUNNING IN AN OS SANDBOX, COMMENT THE SANDBOX LINE
   75% ABOVE AND RUN SWISH WITH AUTHENTICATION SUPPORT.
   76
   77%:- set_setting_default(rserve:socket, '/home/rserve/socket').
   78%:- set_setting_default(rserve:host,   '127.0.0.1').
   79%:- set_setting_default(rserve:port,   6311).