Skip to content

Commit

Permalink
Merge branch 'main' into update_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahAlidoost committed Jan 8, 2025
2 parents 75f5ad0 + 43c5e60 commit 6d57e0c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ghcr.io/ecoextreml/stemmus_scope:1.6.1
FROM ghcr.io/ecoextreml/stemmus_scope:1.6.2

LABEL maintainer="Bart Schilperoort <[email protected]>"
LABEL org.opencontainers.image.source = "https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing"
LABEL org.opencontainers.image.source="https://github.com/EcoExtreML/STEMMUS_SCOPE_Processing"

# Requirements for building Python 3.10
RUN apt-get update && apt-get -y upgrade
Expand All @@ -26,8 +26,8 @@ RUN pip3.10 install grpc4bmi==0.5.0

# # Set the STEMMUS_SCOPE environmental variable, so the BMI can find the executable
WORKDIR /
ENV STEMMUS_SCOPE /STEMMUS_SCOPE
ENV STEMMUS_SCOPE=/STEMMUS_SCOPE

EXPOSE 55555
# Start grpc4bmi server
CMD run-bmi-server --name "PyStemmusScope.bmi.implementation.StemmusScopeBmi" --port 55555 --debug
CMD ["run-bmi-server", "--name", "PyStemmusScope.bmi.implementation.StemmusScopeBmi", "--port", "55555", "--debug"]
2 changes: 1 addition & 1 deletion PyStemmusScope/bmi/docker_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class StemmusScopeDocker:
"""Communicate with a STEMMUS_SCOPE Docker container."""

# Default image, can be overridden with config:
compatible_tags = ("1.6.1",)
compatible_tags = ("1.6.2",)

_process_ready_phrase = b"Select BMI mode:"
_process_finalized_phrase = b"Finished clean up."
Expand Down
3 changes: 2 additions & 1 deletion PyStemmusScope/bmi/local_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def __init__(self, cfg_file: str) -> None:
"""Initialize the process."""
self.cfg_file = cfg_file
config = read_config(cfg_file)
self.sleep_duration = int(config.get("SleepDuration", 10))

exe_file = find_exe(config)
args = [exe_file, cfg_file, "bmi"]
Expand Down Expand Up @@ -154,7 +155,7 @@ def finalize(self) -> None:
"""Finalize the model."""
self.process = alive_process(self.process)
self.process.stdin.write(b"finalize\n") # type: ignore
sleep(10)
sleep(self.sleep_duration)
if self.process.poll() != 0:
try:
self.process.terminate()
Expand Down
32 changes: 30 additions & 2 deletions PyStemmusScope/bmi/variable_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,43 @@ class BmiVariable:
keys=["fluxes", "Resp"],
),
BmiVariable(
name="evaporation_total",
name="precipitation",
dtype="float64",
input=True,
output=False,
units="cm s-1",
grid=0,
keys=["ForcingData", "Precip_msr"],
all_timesteps=True,
),
BmiVariable(
name="applied_infiltration",
dtype="float64",
input=False,
output=True,
units="cm s-1",
grid=0,
keys=["EVAP"],
keys=["ForcingData", "applied_inf"],
all_timesteps=True,
),
BmiVariable(
name="soil_evaporation",
dtype="float64",
input=False,
output=True,
units="cm s-1",
grid=0,
keys=["Evap"],
),
BmiVariable(
name="transpiration",
dtype="float64",
input=False,
output=True,
units="cm s-1",
grid=0,
keys=["Trap"],
),
# soil vars:
BmiVariable(
name="soil_temperature",
Expand Down
4 changes: 2 additions & 2 deletions docs/bmi.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ To use the Docker image, use the `DockerImage` setting in the configuration file
```sh
WorkDir=/home/username/tmp/stemmus_scope
...
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.1
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.2
```

It is best to add the version tag here too (`:1.6.1`), this way the BMI will warn you if the version might be incompatible.
It is best to add the version tag here too (`:1.6.2`), this way the BMI will warn you if the version might be incompatible.

Note that the `docker` package for python is required here. Install this with `pip install PyStemmusScope[docker]`.
Additionally, [Docker](https://docs.docker.com/get-docker/) itself has to be installed.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data/config_file_docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ StartTime=1996-01-01T00:00
EndTime=1996-01-01T02:00
InputPath=
OutputPath=
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.1
DockerImage=ghcr.io/ecoextreml/stemmus_scope:1.6.2

0 comments on commit 6d57e0c

Please sign in to comment.