Skip to content

Commit

Permalink
Repo should only have interface
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Aug 28, 2018
1 parent 5b266a1 commit cf43e7d
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 24,926 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ addons:
apt:
packages:
- libxml2-dev
- protobuf-compiler
- libprotobuf-dev
- libprotoc-dev
- libgrpc++-dev
8 changes: 3 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
Package: grpc4bmi
Package: bmi
Type: Package
Title: gRPC server of basic model interface (bmi)
Title: basic model interface
Version: 1.0.0
Date: 2018-07-31
Author: S. Verhoeven
Maintainer: S. Verhoeven <[email protected]>
Description: Model as a service. Used in eWatercycle project to run hydrology models.
Description: Used in eWatercycle project to run hydrology models via grpc4bmi
License: file LICENSE
Depends: R (>= 3.4.0), configr, R6
Imports: Rcpp (>= 0.12.18)
LinkingTo: Rcpp
RoxygenNote: 6.1.0
Suggests:
testthat
Expand Down
30 changes: 0 additions & 30 deletions Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# Generated by roxygen2: do not edit by hand

export(AbstractBmi)
export(MockedBmi)
export(run)
export(runAsyncMultiServer)
export(runMocked)
importFrom(Rcpp,evalCpp)
useDynLib(grpc4bmi)
10 changes: 0 additions & 10 deletions R/RcppExports.R

This file was deleted.

9 changes: 1 addition & 8 deletions R/abstract-bmi.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ AbstractBmi <- R6Class(
runModel = function() stop('Not implemented'),

getComponentName = function() stop('Not implemented'),
getInputVarNameCount = function() stop('Not implemented'),
getOutputVarNameCount = function() stop('Not implemented'),
getInputVarNames = function() stop('Not implemented'),
getOutputVarNames = function() stop('Not implemented'),

Expand All @@ -36,11 +34,9 @@ AbstractBmi <- R6Class(
getVarNBytes = function(name) stop('Not implemented'),

getValue = function(name) stop('Not implemented'),
getValuePtr = function(name) stop('Not implemented'),
getValueAtIndices = function(name, indices) stop('Not implemented'),

setValue = function(name, values, shape) stop('Not implemented'),
setValuePtr = function(name, ref) stop('Not implemented'),
setValue = function(name, values) stop('Not implemented'),
setValueAtIndices = function(name, indices, values) stop('Not implemented'),

getGridSize = function(grid_id) stop('Not implemented'),
Expand All @@ -52,9 +48,6 @@ AbstractBmi <- R6Class(
getGridX = function(grid_id) stop('Not implemented'),
getGridY = function(grid_id) stop('Not implemented'),
getGridZ = function(grid_id) stop('Not implemented'),
getGridCellCount = function(grid_id) stop('Not implemented'),
getGridPointCount = function(grid_id) stop('Not implemented'),
getGridVertexCount = function(grid_id) stop('Not implemented'),
getGridConnectivity = function(grid_id) stop('Not implemented'),
getGridOffset = function(grid_id) stop('Not implemented')
)
Expand Down
64 changes: 0 additions & 64 deletions R/bmi-server.R

This file was deleted.

45 changes: 12 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
Wrap a model written in R which implements the basic model interface (bmi) in a gRPC server.
Contains abstract super class which implements the basic model interface (bmi) in R.

See https://github.com/eWaterCycle/grpc4bmi for the Python server/client implementation.

# Install

System requirements:
* Protobuf
* [grpc](https://github.com/grpc/grpc/blob/master/BUILDING.md) >=v1.14.x

From R

```R
devtools::install_github("eWaterCycle/grpc4bmi-r")
devtools::install_github("eWaterCycle/bmi-r")
```

# Usage
Expand All @@ -20,31 +16,28 @@ First the model should be wrapped in a basic model interface be subclassing the
Then the server can be started with:

```
export BMI_MODULE=<path to r script with bmi class>
export BMI_CLASS=<bmi class name>
export BMI_PORT=<port on which to run grpc server, default is 55555>
Rscript -e 'grpc4bmi::run()'
pip install grpc4bmi[R]
run-bmi-server --lang R --name <path to r script with bmi class>.<bmi class name>
```

## Docker container

To install grpc is a bit of a hassle so a Docker image is provided called [ewatercycle/grpc4bmi-r](https://hub.docker.com/r/ewatercycle/grpc4bmi-r/) which contains R and grpc installation.

To create a Docker image of a R based hydrology model use this image as a start.

So for example for https://github.com/ClaudiaBrauer/WALRUS

```Dockerfile
FROM ewatercycle/grpc4bmi-r
FROM r-base

RUN installGithub.r ClaudiaBrauer/WALRUS
RUN installGithub.r ClaudiaBrauer/WALRUS eWaterCycle/bmi-r

RUN mkdir /opt/walrus-bmi

COPY walrus-bmi.r /opt/walrus-bmi/walrus-bmi.r

ENV BMI_MODULE=/opt/walrus-bmi/walrus-bmi.r
ENV BMI_CLASS=WalrusBmi
WORKDIR /opt/walrus-bmi

RUN apt update && apt install -y python3-dev python3-pip && pip3 install grpc4bmi[R]
CMD run-bmi-server --lang R --name walrus-bmi.WalrusBmi --path /opt/walrus-bmi --port 55555
EXPOSE 55555
```

To run server use
Expand All @@ -53,11 +46,6 @@ docker run -d -v $PWD:/data -p 55555:55555 <docker image from ewatercycle/grpc4b
```
The config file for the bmi initialize function should be put in current working directory and the initialize function should be called with `/data/<config filename`.

To run server in debug mode use
```bash
docker run -d -v $PWD:/data -p 55555:55555 -e GRPC_TRACE=api -e GRPC_VERBOSITY=DEBUG <docker image from ewatercycle/grpc4bmi-r>
```

# Release

## Generate man pages
Expand All @@ -66,19 +54,10 @@ docker run -d -v $PWD:/data -p 55555:55555 -e GRPC_TRACE=api -e GRPC_VERBOSITY=D
Rscript -e "devtools::document(roclets=c('rd', 'collate', 'namespace'))"
```

## Generate cpp files from proto file

```bash
cd src
protoc -I ../inst/proto --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ../inst/proto/bmi.proto
protoc -I ../inst/proto --cpp_out=. ../inst/proto/bmi.proto
cd -
```

## Local build & install

```bash
Rscript -e 'Rcpp::compileAttributes();devtools::document()'
Rscript -e 'devtools::document()'
R CMD INSTALL .
Rscript -e 'grpc4bmi::run()'
```
Loading

0 comments on commit cf43e7d

Please sign in to comment.