misc.config.Settings
misc.config.Settings()
The configuration settings for the FloodAdapt database and integrator.
Precedence is as follows: user arguments > environment variables > defaults in this class. When loading is done, the settings are validated and the environment variables are updated with the loaded values.
If any required settings are missing or invalid, a ValidationError is raised.
Usage
from flood_adapt.misc.config import Settings
One of the following:
Load settings from environment variables, if no environment variables are set, use defaults defined in the class:
settings = Settings()
Load settings from a .toml file, overwriting any environment variables set:
settings = Settings.read(toml_path: Path)
Load settings from keyword arguments, overwriting any environment variables:
settings = Settings(database_root="path/to/database", database_name="database_name", system_folder="path/to/system_folder")
Attributes
Name | Type | Description |
---|---|---|
database_name | str | The name of the database. |
database_root | Path | The root directory of the database. |
system_folder | Path | The root directory of the system folder containing the kernels. |
delete_crashed_runs | bool | Whether to delete crashed/corrupted runs immediately after they are detected. |
unit_system | UnitSystem | The unit system to use for the calculations. Must be ‘imperial’ or ‘metric’. |
Properties
database_path : Path The full path to the database. sfincs_path : Path The path to the SFINCS binary. fiat_path : Path The path to the FIAT binary.
Raises
Name | Type | Description |
---|---|---|
ValidationError | If required settings are missing or invalid. |
Methods
Name | Description |
---|---|
read | Parse the configuration file and return the parsed settings. |
write | Write the configuration settings to a .toml file. |
read
misc.config.Settings.read(toml_path)
Parse the configuration file and return the parsed settings.
Parameters
Name | Type | Description | Default |
---|---|---|---|
toml_path | Path | The path to the configuration file. | required |
Returns
Name | Type | Description |
---|---|---|
Settings | The parsed configuration settings. |
Raises
Name | Type | Description |
---|---|---|
ValidationError | If required configuration values are missing or if there is an error parsing the configuration file. |
write
misc.config.Settings.write(toml_path)
Write the configuration settings to a .toml file.
Parameters
Name | Type | Description | Default |
---|---|---|---|
toml_path | Path | The path to the configuration file. | required |
Returns
Name | Type | Description |
---|---|---|
None |