Configuration how-tos#
Get and set config items#
Using the config sub-command in the MatFlow CLI, we can get configuration items like this:
matflow config get machine
Items can be set like this:
matflow config set machine my-machine-name
In the Python API, we can interact with the MatFlow configuration as below. Note that we must call config.save
to make the config changes persistent, otherwise any changes made will only be temporary.
import matflow as mf
# print the value of the `machine` item:
print(mf.config.machine)
# set the value of the `machine` item:
mf.config.machine = "my-machine-name"
# optionally save the changes to the config file:
mf.config.save()
If you want to change a configuration item temporarily (just for the current session), you can also provide configuration item values to load_config and reload_config, like this:
import matflow as mf
# modify the log console level just for this session:
mf.load_config(log_console_level="debug")
See the configuration reference documentation for a listing of configurable items.
Reset the config to default values#
Usually, when MatFlow is invoked, the first thing it does is load the configuration file. However, if you have updated to a newer, incompatible version, sometime your existing configuration file will fail validation. In this case, you can reset the configuration file to its default value by running the following CLI command:
matflow manage reset-config
Within the Python API, the config can be reset like this:
import matflow as mf
mf.reset_config()
Warning
Resetting the configuration will remove any custom configuration you had, including pointers to template component source files (like environment source files). If you want to make a copy of the old file before resetting, you can retrieve its file path like this: matflow manage get-config-path
, with the CLI, or, mf.get_config_path()
, with the Python API.
Clear the known-submissions file#
The known-submissions file is used to track running and recent workflow, and is used by the mf.show
/ matflow show
command. Sometimes you might need to clear this file, which can be done like this:
matflow manage clear-known-subs
Within the Python API, the equivalent command is:
import matflow as mf
mf.clear_known_submissions_file()