Skip to content

eWaterCycle/sfincs-bmi-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sfincs-bmi-server

grpc4bmi wrapper around Delteras/sfincs BMI for use with eWaterCycle.

To interop with grpc, a c++ wrapper is added on top of the fortran code. So we have:

sfincs_bmi.f90 --> sfincs_bmi.cxx --> sfincs_bmi_server.cxx

The c++ wrapper is modelled after bmi-heat c++ example, version 2.1.

For an example see https://github.com/eWaterCycle/hype-bmi/. Note that this uses an older version of the BMI spec.

Using it

Pull image from https://github.com/eWaterCycle/sfincs-bmi-server/pkgs/container/sfincs-bmiserver or

Build docker image with

docker build -t sfincs-bmiserver .

To interact with it through a grpc4bmi client:

from grpc4bmi.bmi_client_docker import BmiClientDocker

model = BmiClientDocker(image='sfincs-bmiserver', image_port=50051, work_dir="./")
model.get_component_name()
# 'Sfincs hydrodynamic model (C)'

del model

See the example notebook shipped with this repo.

See https://grpc4bmi.readthedocs.io/en/latest/container/usage.html#docker

Development container

To aid development, this repo is configured for use with vscode devcontainers. In vscode, install the devcontainers extension, then from the command pallete choose "Dev Containers: Open Folder in Container". This will build the container mount your working directory, and open the remote environment in vscode. The c++ and docker extensions are automatically be loaded.

To rebuild the server without rebuilding Docker image use

cd src
mkdir build
cd build
cmake ..
make
# Start gprc server
./sfincs_bmi_server

To interact with grpc server through a grpc4bmi client:

import grpc
from grpc4bmi.bmi_grpc_client import BmiClient

model = BmiClient(grpc.insecure_channel("localhost:50051"))

model.get_component_name()
# 'Sfincs hydrodynamic model (C)'

Publish image

After build, publish image to https://github.com/orgs/eWaterCycle/packages with

docker tag sfincs-bmiserver ghcr.io/ewatercycle/sfincs-bmiserver:sfincs-v2.0.2-Blockhaus-Release-Q2-2023
docker push ghcr.io/ewatercycle/sfincs-bmiserver:sfincs-v2.0.2-Blockhaus-Release-Q2-2023