Giter Site home page Giter Site logo

rserve_client's Introduction

Rserve client for SWI-Prolog/SWISH

Rserve R-package:

Compiling this package

This library is configured as a SWI-Prolog pack. It can be installed using the command below. The installation requires git, autoconf and the common C++ build tools.

?- pack_install('rserve_client').

This is tested on Ubuntu (14.04 and 16.04). It performs these steps:

  • Clone my fork of Rserve (some extensions to the C++ client)
  • Configure and build the C++ client library
  • Build the SWI-Prolog interface rserve.so

Using this package

This package is primarily intended for accessing R in server environments such as SWISH. We created a Docker container that runs Rserve in a sandbox. The container exposes Rserve using a Unix-domain socket at the following address:

/home/rserve/socket

With SWISH and is interface installed in adjacent directories, i.e., below the same parent, R may be linked to SWISH doing

:- use_module(lib/r_swish).

Now, R is not safe. You should either run Rserve in a tight OS container and load library(r/r_sandbox) or run SWISH in authenticated mode by loading lib/authenticate.pl.

Libraries provided

User libraries

  • library(r/r_call) Defines basic user API to R
  • library(r/r_data) Utilities to create and fetch R data frames

Implementation libraries

  • library(r/r_expand_dot) Allow for dots in atoms and functors without quotes.
  • library(r/r_grammar) R Parser utilities (lexer) that support R quasi quotations
  • library(r/r_term) DCG non-terminal to translate a term into an R command string
  • library(r/r_sandbox) Declare the R API sandbox-safe
  • library(r/r_serve) Low-level level communication library

Status

This is just a proof of context. Obviously missing functionality:

  • Cover more Prolog term --> R translations, following Real.
  • Support OOB (Out Of Band) communication introduced in recent versions of Rserve to deal with R I/O.

Related projects

This interface is inspired by Real by Nicos Angelopoulos. Main differences:

  • Real is embedded in SWI-Prolog. This is more productive for local deployment as the communication is faster and R has access to its default environment. Thus, R can open graphical windows and can read and write files. Real is also much more mature, notably in the supporting a much larger part of the R syntax from Prolog.

  • Rserve runs typically using a different user in a different environment. The R environment cannot easily communicate with your local development environment. When used in a (web) server environment this comes with several advantages. We can seriously sandbox the R executable, each query in SWISH gets its own R instance and information can thus nog leak between queries and users.

rserve_client's People

Contributors

janwielemaker avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

frnmst kamahen

rserve_client's Issues

Library options

When running swish with the latest swipl version I get

Mar 14 11:45:02 cpr run.sh[1277]: ERROR: /home/rzf/swish/pack/rserve_client/prolog/r/r_call.pl:61:
Mar 14 11:45:02 cpr run.sh[1277]: ERROR:    source_sink `library(options)' does not exist
Mar 14 11:45:02 cpr run.sh[1277]: Warning: /home/rzf/swish/pack/rserve_client/prolog/r/r_call.pl:61:
Mar 14 11:45:02 cpr run.sh[1277]: Warning:    Goal (directive) failed: r_call:use_module(library(options))

loading twice foreign library gives error

Makes swish not working with R (error while loadin lib r/r_serve)

rzf@cpr:~/swish$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.20-63-g9d33c3f81)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit http://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- use_foreign_library(foreign(rserve)).
true.

?- use_foreign_library(foreign(rserve)).
ERROR: Initialization goal shlib:load_foreign_library(user:foreign(rserve)) rais ed exception:
ERROR: No install function in '/home/rzf/lib/swipl/pack/rserve_client/lib/x86_64 -linux/rserve.so'
ERROR: Tried: [install_rserve,install]
true.

Adopt width of console

Console width can be set with options(width=150). Default width should be computed from the interface.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.