Our YAML module#
The swarmsim.yaml
module provides a custom YAML loader
that defines some convenience tags. This article will explain how
the YAML files are loaded and how to use the custom tags.
See also
Looking for how to load or dump YAML files with our custom tags?
See swarmsim.yaml
Or for information on how to use your custom class in a YAML file, see Config Registry.
YAML#
YAML is a human-readable data serialization format. We use it to write configurations that describe simulations.
It’s a superset of JSON, so it’s easy to read and write.
We use the PyYAML library to load and dump YAML files.
See also
Here’s a nice and quick tutorial for YAML: Learn YAML in Y minutes
Or have a look at the YAML specification
Path Resolution Order#
When loading a YAML file, the !include
and !relpath
tags will resolve the path
by testing the following assumptions in order:
Path is not relative to the current working directory
(i.e. the path is absolute or relative to the user home directory)
Path is relative to the
.yaml
file with the tagPath is relative to the current working directory (where you were when you ran
python
).This is the default behavior for relative paths in Python, but it is the last place we look.
If a file isn’t found at any of these locations, an error will be raised. See include.search_file()
.