Dependencies: python 3.8+, pip
pipenv easy the process of managing python dependencies
Inside the project folder (after clone)
$ pip install pipenv
$ cd HMRSsim
$ pipenv install
$ pipenv shell
(hmrssim env) % pipenv install --dev
Currently the easier way to install the package is to do it locally. In the root folder run the command below to install the HMRsim_lesunb
package in edit mode. Edit mode means any changes you make to src/simulator
will be reflected in the package.
pip install -e .
Check the package was installed.
pip list
# ...
# HMRsim-lesunb 0.0.1
# ...
Simulations are defined in by config objects. You can pass the config to the Simulator class either by a dict object, or by passing the path to a json file.
simulator = Simulator(config)
💡
The package exports a utility function to help you parse the config.
$ hmrsimcli configtest -f simulation.json
The file that build a simulation and runs it is run.py
To execute the simulation, run
$ python run.py [path/to/config.json]
💡
Check theexamples/
folder for different example simulations
If you just want to run a simulation in the project (e.g. you are not developing HMRSim itself) you may opt to run it using a Docker container. First you build the image, which does exactly what was described above in a Docker image
$ docker build --rm -t hmrsim .
Then you can run simulations inside the container by using the command below.
$ docker run -it -v ${PWD}/examples/hospitalSimulation:/usr/app hmrsim:latest python run.py ./simulation.json
This command has a few important parts:
-
-v ${PWD}/examples/hospitalSimulation:/usr/app
- Connects the folder${PWD}/examples/hospitalSimulation
in the host machine to the folder/usr/app
in the container. The working directory inside the container is/usr/app
. You should changeexamples/hospitalSimulation
by the path to the root folder of your simulation project. -
hmrsim:latest
- Indicates what image to use -
python run.py ./simulation.json
- Command to start the simulation, as described above. Notice thatrun.py
is actually/usr/app/run.py
inside the container. Same thing forsimualtion.json
.
To add new dependencies use the following command.
$ pipenv install [name]
This command will add the dependency to the Pipfile and Pipfile.lock assuring that the execution can be reproduced in another environment (after dependencies are updated with pipenv install
command )
Same as previous dependencies, but for development libraries such as the ones used for test.
$ pipenv install [name] --dev
Note that other systems after pulling updates will need a reexecution of pipenv install --dev