Set up a grpc4bmi server to run a containerized version of the HydroTrend model through Python.
Build this example locally with:
docker build --tag hydrotrend-grpc4bmi .
The image is built on the csdms/grpc4bmi base image,
which is built on the condaforge/miniforge3 base image.
The OS is Linux/Ubuntu.
The HydroTrend model, grpc4bmi, and the grpc4bmi server are installed in /opt/conda.
The HydroTrend grpc4bmi server is exposed through port 55555.
Use the grpc4bmi Docker client to access the BMI methods of the containerized model.
Install with pip:
pip install grpc4bmi
Then, in a Python session, access HydroTrend in the image built above with:
from grpc4bmi.bmi_client_docker import BmiClientDocker
m = BmiClientDocker(image="hydrotrend-grpc4bmi", image_port=55555, work_dir=".")
m.get_component_name()
del m # stop container cleanlyIf the image isn't found locally, it's pulled from Docker Hub
(e.g., try the csdms/hydrotrend-grpc4bmi image).
For more in-depth examples of running the HydroTrend model through grpc4bmi, see the examples directory.
This work is supported by the U.S. National Science Foundation under Award No. 2103878, Frameworks: Collaborative Research: Integrative Cyberinfrastructure for Next-Generation Modeling Science.