Write a Simulation
After having installed the CLI you can get started writing your first simulation. This is not an easy process and will take a while to get a good grasp on how to do.
1. Setup development environment
To make writing this simulation easier you should setup your local development environment first.
Create a folder.
mkdir ~/code/almanak-simulations
cd ~/code/almanak-simulations
You can now open this folder in your favorite IDE, in this guide we will be using Visual Studio Code but feel free to use any IDE that supports Python and YAML formatting.
code .
When using Visual Studio Code please install the following plugins:
2. Install the cli
Follow the guide here to install the cli.
3. Use simcli generate
Generate a new simulation folder using the template.
simcli generate simulation1
This will create a new folder simulation1
in which you will find a sample
simulation.
4. Install dependencies
Install the poetry dependencies. It installs the Simulations SDK which can be used for python type hinting and YAML validation.
poetry install
5. Start writing
Open the configuration.yaml
and start writing your simulation using the
configuration specification here. A suggestion would be to
copy the sample provided in the Introduction into your
configuration.yaml
and edit it from there.
For some creature comforts that create a better developer experience please install the following python modules:
6. Start a simulation
Use the CLI to run a simulation with your configuration.
simcli create
This will return an ID for the simulation and if there weren't any errors will start running the simulation.
7. Retrieve results from your simulation
Keep checking the status of your simulation every once in a while using the CLI with the ID that you received when you started the simulation.
simcli get id
Once it's done you will see URLs to files in Google Cloud Storage with the result and metrics that were logged.