Code Monkey home page Code Monkey logo

apsim.docker's Introduction

APSIM using Docker

Running APSIM through docker can simplify the setup. Docker provides a method to get the dependencies and functionality in a single digital object that runs across multiple operating systems.

After setting up docker, you need to pull the APSIM image, ensure the target .apsimx file is properly configured for you system, and run a docker container using the simulate file as input. If you are beginning with examples from the ApsimX repo, also make sure you've clone have the code locally so it can be mounted to the docker container.

1. Pull the APSIM Docker Image

Ensure docker is running. Then pull the apsimng image. You only need to do this once.

docker pull apsiminitiative/apsimng

2. Run an Example Simulation

# Navigate your terminal to you copy of ApsimX (cloned from https://github.com/APSIMInitiative/ApsimX)
cd /your/path/to/APSIMInitiative/ApsimX

#To run APSIM, we launch a container (which essentially intantiates a live process from the static image)
docker run -i --rm -v "$PWD:/ApsimX" apsiminitiative/apsimng /ApsimX/Examples/Wheat.apsimx

The above:

  • uses the run command to launch a container from the apsiminitiative/apsimng image
  • passes the -i flag to run in interactive mode (attached to the terminal)
  • passes the --rm flag to tell docker to delete the container once the simulation finishes (saving disk space by not accumulating stopped containers)
  • passes the -v command to mount a volume. This mounts the present working directory on the host machine to /ApsimX within the docker container so it has access to the examples at ApsimX/Examples.

Notes

Usage on Non-Windows Machines (e.g., Mac or Linux)

The above Wheat example (and others) in ApsimX/Examples/*.apsimx specify file locations using a Windows file string convention. You'll need to modify any specified files in the .apsimx file to match your OS.

In the above example, Mac/Linux users will likely need to change the filepath specified in the Models.Climate.Weather from "%root%\\Examples\\WeatherFiles\\Dalby.met" to "/ApsimX/Examples/WeatherFiles/Dalby.met"

Customizing the Docker Container Call

  • When building your own workflow, you will likely want to modify the volume mount and .apsimx file locations.
  • Extra switches can be appended to the docker run command to utilise extra functionality. Some examples are the --verbose, --apply, and any others you can use with Models.exe. Additional docker run options are listed in the docker documentation.

apsim.docker's People

Contributors

hol353 avatar asherbender avatar hol430 avatar par456 avatar ric394 avatar peter-devoil avatar

Stargazers

Luana Becker da Luz avatar Jian (AKA Frank) Liu  avatar

Watchers

James Cloos avatar  avatar  avatar

apsim.docker's Issues

How to start apsim with docker

I'm a beginner in apsim.
I'm using docker desktop to run the apsimng-complete:latest image, but the run fails!
Here is the running log.

2023-09-14 16:26:41 APSIM 2023.9.7308.0
2023-09-14 16:26:41 Copyright © APSIM Initiative 2022
2023-09-14 16:26:41 
2023-09-14 16:26:41 ERROR(S):
2023-09-14 16:26:41   A required value not bound to option name is missing.
2023-09-14 16:26:41 USAGE:
2023-09-14 16:26:41 Normal usage:
2023-09-14 16:26:41   Models file.apsimx file2.apsimx
2023-09-14 16:26:41 Run all files under a directory, recursively:
2023-09-14 16:26:41   Models --recursive dir/*.apsimx
2023-09-14 16:26:41 Edit a file before running it:
2023-09-14 16:26:41   Models --edit /path/to/config/file.txt /path/to/file.apsimx
2023-09-14 16:26:41 
2023-09-14 16:26:41   --recursive                    Recursively search through subdirectories for
2023-09-14 16:26:41                                  files matching the file specification.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --upgrade                      Upgrade a file to the latest version of the
2023-09-14 16:26:41                                  .apsimx file format without running the file.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --run-tests                    After running the file, run all tests inside
2023-09-14 16:26:41                                  the file.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --verbose                      Write detailed messages to stdout when a
2023-09-14 16:26:41                                  simulation starts/finishes.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --csv                          Export all reports to .csv files.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --merge-db-files               Merge multiple .db files into a single .db
2023-09-14 16:26:41                                  file.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --edit                         Deprecated. Use --apply switch with config file
2023-09-14 16:26:41                                  workflow instead.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --run-use-config               Edit the .apsimx file(s) before running them.
2023-09-14 16:26:41                                  Path to a config file must be specified which
2023-09-14 16:26:41                                  contains lines of parameters to change, in the
2023-09-14 16:26:41                                  form 'path = value'.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --edit-use-config              Edit the .apsimx file and save without running
2023-09-14 16:26:41                                  them. Path to a config file must be specified
2023-09-14 16:26:41                                  which contains lines of parameters to change,
2023-09-14 16:26:41                                  in the form 'path = value'.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --list-simulations             List simulation names without running them.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --list-referenced-filenames    List all files that are referenced by an
2023-09-14 16:26:41                                  .apsimx file(s).
2023-09-14 16:26:41 
2023-09-14 16:26:41   --single-threaded              Run all simulations sequentially on a single
2023-09-14 16:26:41                                  thread.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --cpu-count                    (Default: -1) Maximum number of
2023-09-14 16:26:41                                  threads/processes to spawn for running
2023-09-14 16:26:41                                  simulations.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --simulation-names             Only run simulations if their names match this
2023-09-14 16:26:41                                  regular expression.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --apply                        Uses a config file to apply instructions. Can
2023-09-14 16:26:41                                  be used to create new simulations and modify
2023-09-14 16:26:41                                  existing ones.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --help                         Display this help screen.
2023-09-14 16:26:41 
2023-09-14 16:26:41   --version                      Display version information.
2023-09-14 16:26:41 
2023-09-14 16:26:41   ApsimXFileSpec (pos. 0)        Required. .apsimx file(s) to be run.
2023-09-14 16:26:41 

The logs prompted me to ”A required value not bound to option name is missing.“, missing values look like "Models", but I don't know how to set it up.
Can you show me how to set it up when running the ”docker run“ command?

Cannot build OldAPSIM docker image

After a day trying, I cannot build the APSIM Classic windows docker image. It silently fails to install the build tools. No c:\BuildTools directory is created. I'm unsure why this is happening. I remember something like this from years ago but cannot remember the solution.

Error building/running docker images on M1 Mac

Hi @hol353, I'm having issues getting APSIM running within docker. My overall goal is to be able to batch process a series of .apsimx files by repeatedly executing a APSIM Docker container.

I'll admit I was a little lost without a README, so let me know if there are docker docs somewhere else. From the comments in the Dockerfiles, it seemed like this is a multi-step build (see workflow below). I'm happy to help put together a simple README file and PR it if I can get this working.

Workflow

Currently, I'm doing the following:

# Build the `apsimng-build` image
cd /my/work/dir/APSIMInitiative/APSIM.Docker/NextGen/apsimng-build
docker build -t apsiminitiative/apsimng-build .

# Build the `apsimng` image
cd/my/work/dir/APSIMInitiative/APSIM.Docker/NextGen/apsimng
docker build -t apsiminitiative/apsimng .

# cd to the ApsimX directory, and hit the docker entrypoint
cd /my/work/dir/APSIMInitiative/ApsimX
docker run -i --rm -v "$PWD:/apsim" \
apsiminitiative/apsimng \
test_simulation_file.apsimx

Error

On the last line, I get this error
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

From some poking around, it seems like this may be an issue with me building the images on an M1 Mac (with an ARM processor). However, I tried to force build the images for a more typical platform (by adding the --platform=linux/amd64 flag to FROM statements), but that didn't work for me either. I'd hit issues installing gtk-sharp3, and wasn't able to fix it from the logs.

Guidance

Any tips on the docker build process or if Apple silicon is supported?

Tagging releases on Docker Hub

I was wondering if it was possible to tag releases on Docker Hub so some tooling I am working on can be pinned to a version of APSIM for consistency. Using :latest changes versions on me when we build the pipeline.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.