grpc4bmi.bmi_client_docker module
- class grpc4bmi.bmi_client_docker.BmiClientDocker(image: str, work_dir: str, image_port=50051, host=None, input_dirs: Iterable[str] = (), user=1005, remove=False, delay=5, timeout=None)[source]
Bases:
BmiClient
BMI gRPC client for dockerized server processes: the initialization launches the docker container which should have the run-bmi-server as its command. Also, it should expose the tcp port 50001 for communication with this client. Upon destruction, this class terminates the corresponding docker server.
- Parameters:
image (str) – Docker image name of grpc4bmi wrapped model
image_port (int) – Port of server inside the image
host (str) – Host on which the image port is published on a random port
input_dirs (Iterable[str]) –
Directories for input files of model.
All of directories will be mounted read-only inside Docker container on same path as outside container.
work_dir (str) –
Working directory for model.
Directory is mounted inside container and changed into.
user (str) – Username or UID of Docker container. Defaults to own UID.
remove (bool) –
Automatically remove the container and logs when it exits.
Enable to get logs when container dies prematurely.
delay (int) – Seconds to wait for Docker container to startup, before connecting to it
timeout (int) – Seconds to wait for gRPC client to connect to server
extra_volumes (Dict[str,Dict]) –
Extra volumes to attach to Docker container. The key is either the hosts path or a volume name and the value is a dictionary with the keys:
bind
The path to mount the volume inside the containermode
Eitherrw
to mount the volume read/write, orro
to mount it read-only.
For example:
{'/data/shared/forcings/': {'bind': '/forcings', 'mode': 'ro'}}
Increase when container takes a long time to startup.
timeout –
Seconds to wait for gRPC client to connect to server.
By default will try forever to connect to gRPC server inside container. Set to low number to escape endless wait.
See
grpc4bmi.bmi_client_apptainer.BmiClientApptainer
for examples using input_dirs and work_dir.