Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/csdms/bmi-example-python-docker
The Python BMI example, Dockerized
https://github.com/csdms/bmi-example-python-docker
bmi csdms docker python
Last synced: 3 days ago
JSON representation
The Python BMI example, Dockerized
- Host: GitHub
- URL: https://github.com/csdms/bmi-example-python-docker
- Owner: csdms
- License: mit
- Created: 2024-01-10T18:49:55.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-08-29T18:30:06.000Z (4 months ago)
- Last Synced: 2024-08-29T20:16:48.858Z (4 months ago)
- Topics: bmi, csdms, docker, python
- Language: Dockerfile
- Homepage: https://bmi.readthedocs.io
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bmi-example-python-docker
The [Python example](https://github.com/csdms/bmi-example-python)
for the [Basic Model Interface](https://bmi.readthedocs.io),
dockerized.## Build the image
Build this example locally with:
```
docker build --tag bmi-example-python .
```
The image is based on the [csdms/bmi](https://hub.docker.com/r/csdms/bmi) image.
The OS is Linux/Ubuntu.
`conda` and `mamba` are installed in `CONDA_DIR=opt/conda`,
and the *base* environment is activated.
The Python BMI specification and example are installed into it.## Run a container
Run a container from this image interactively:
```
docker run -it bmi-example-python
```
This starts a bash shell.
Start a Python session to run the *heat* model through its BMI.
```python
>>> from heat import BmiHeat
>>> x = BmiHeat()
>>> x.get_component_name()
'The 2D Heat Equation'
```### Run example notebooks through a container
The Python BMI example includes a set of [example notebooks](https://github.com/csdms/bmi-example-python/tree/master/examples).
Run them through a container.
```
docker run -i -t -p 8888:8888 bmi-example-python /bin/bash -c "\
mamba install jupyter -y --quiet && \
jupyter notebook \
--notebook-dir=/opt/bmi-example-python/examples \
--ip='*' --port=8888 \
--no-browser --allow-root"
```
This is a little tricky, but
examine the output of the Jupyter server after it starts;
it will include an URL from *localhost* that includes a security token.
Copy/paste this URL into a browser to view and run the example notebooks.## Developer notes
A versioned, multiplatform image built from this repository is hosted on Docker Hub
at [csdms/bmi-example-python](https://hub.docker.com/r/csdms/bmi-example-python/).
When this repository is tagged,
an image is automatically built and pushed to Docker Hub
by the [release](./.github/workflows/release.yml) CI workflow.
To manually build and push an update, run:
```
docker buildx build --platform linux/amd64,linux/arm64 -t csdms/bmi-example-python:latest --push .
```
A user can pull this image from Docker Hub with:
```
docker pull csdms/bmi-example-python
```
optionally with the `latest` tag or with a version tag.## What is the Basic Model Interface?
The Basic Model Interface (BMI) is a set of functions for querying, modifying, running, and coupling models.
Learn more at https://bmi.readthedocs.io/.## Acknowledgment
This work is supported by the U.S. National Science Foundation under Award No. [2103878](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2103878), *Frameworks: Collaborative Research: Integrative Cyberinfrastructure for Next-Generation Modeling Science*.