Global options are available to configure some of the library behaviour. Functions that depend on any of these options will be tagged with:
Note
Depends on option_class.option_id
.
Option Class | Option ID | Description |
---|---|---|
system | overwrite | Allow overwriting already existing files |
system | output | Default folder to output generated files |
system | cpu | Available CPU for multiprocessing |
rosetta | path | Path to the rosetta binaries |
rosetta | compilation | Target binaries of rosetta |
There are two ways of altering the values of these global options:
This approach can be taken during the development of a script. Has the advantages that:
On code changes can be called through set_option()
to target individual
options or by loading an option file with set_options_from_YAML()
or set_options_from_JSON()
. In these to cases, being yaml
or json
format,
the structure is of a dictionary of dictionaries, being option_class
the first level of keys
and option_id
the second.
Full description of all the functions that allow access to the global variables can be find in the libconfig API
Example: Allowing overwrite of previously generated files.
In [1]: import rstoolbox.core as rc
...: rc.set_option('system', 'overwrite', True)
...:
After the first execution of rstoolbox
, a configuration file ~/.rstoolbox.cfg
is generated
in the user’s home folder.
Everytime the library is loaded after that, it checks on that file to see the user’s particular configuration. Thus, by changing the default parameters in that file, the user can set up global configurations.
Logically, this might change some behaviour between different users, but excludes the need of set up some options (like executable paths) every time.
Example: How a configuration file might look like (MacOS).
rosetta:
compilation: macosclangrelease
path: /Volumes/MiniTwo/bin/Rosetta/main/source/bin/
system:
output: ./
overwrite: false