pyiron_base.state.settings module

The Settings object controls all the parameters of the pyiron environment that are specific to your particular configuration: your username, where on the filesystem to look for resources, and all flags necessary to define how pyiron objects relate to your database (or lack thereof). It is universally available for import an instantiation, and the python interpreter only ever sees a single instance of it, so modifications to the Settings in one place are available everywhere else that Settings gets/has gotten instantiated.

It is possible to run pyiron only with default behaviour from the Settings class itself, but standard practice is to overwrite part or all of the default configuration by reading information stored on the system. This is done in an XOR priority order, where input from only one source is used to overwrite the default values: The highest priority is available only with the update method after the Settings object already exists, and is to take values from a user-provided dictionary. If no such dictionary is provided, or at initialization time then the highest priority is to read values to read from system environment variables starting with ‘PYIRON’. If none of these except ‘PYIRONCONFIG’ are found, next Settings will try to read a configuration file stored at this location. If ‘PYIRONCONFIG’ was not specified, Settings will instead try to read a file at the default location: ~/.pyiron. Finally, if none of these were specified, only the default values from the codebase are used.

The configuration can later be updated by calling the update method. Before going through the update cycle specified above, this routine first checks to see if a dictionary was passed in and if so uses that to update the default configuration instead.

Additionally, if either of the conda flags ‘CONDA_PREFIX’ or ‘CONDA_DIR’ are system environment variables, they get /share/pyiron appended to them and these values are appended to the resource paths.

Finally, Settings converts any file paths from your OS to something pyiron-compatible, and does some other cleaning and consistency checks.

class pyiron_base.state.settings.Settings(*args, **kwargs)

Bases: object

The unique settings object (singleton) for the currently running pyiron instance.

The settings object reads configuration data from the following sources in decreasing order of priority: system environment values (starting with ‘PYIRON’), a configuration file identified in the PYIRONCONFIG system environment variable, or a default configuration file in ~/.pyiron. One (or none) of these is used to overwrite default values specified in the codebase.

Here are the configuration keys as the appear in the python code/config files/system env variables:

user / USER / PYIRONUSER (str): resource_paths / RESOURCE_PATHS / PYIRONRESOURCEPATHS (list): project_paths / PROJECT_PATHS / PYIRONPROJECTPATHS (list): connection_timeout / CONNECTION_TIMEOUT / PYIRONCONNECTIONTIMEOUT (int): sql_connection_string / CONNECTION / PYIRONSQLCONNECTIONSTRING (str): sql_table_name / JOB_TABLE / PYIRONSQLTABLENAME (str): sql_view_connection_string / - / - (str): Constructed, not available to be set in config files or sys env. sql_view_table_name / VIEWER_TABLE / PYIRONSQLVIEWTABLENAME (str): sql_view_user / VIEWERUSER / PYIRONSQLVIEWUSER (str): sql_view_user_key / VIEWERPASSWD / PYIRONSQLVIEWUSERKEY (str): sql_file / FILE / PYIRONSQLFILE (str): sql_host / HOST / PYIRONSQHOST (str): sql_type / TYPE / PYIRONSQLTYPE (“SQLite”|”Postgres”|”MySQL”): What type of SQL database to use. (Default is

“SQLite”.)

sql_user_key / PASSWD / PYIRONSQLUSERKEY (): sql_database / NAME / PYIRONSQLDATABASE (): project_check_enabled / PROJECT_CHECK_ENABLED / PYIRONPROJECTCHECKENABLED (bool): disable_database / DISABLE_DATABASE / PYIRONDISABLE (bool): Whether to turn off the database and use a

file-system-based hierarchy. (Default is False.)

credentials_file / CREDENTIALS_FILE / CREDENTIALSFILE (str): Path to an additional credentials file holding

credential information. If specified, the values in the credentials_file overwrite the values of other sources.

write_work_dir_warnings / WRITE_WORK_DIR_WARNINGS / PYIRONWRITEWORKDIRWARNINGS (bool): Whether to write

the working directory warning files to inform users about possibly modified content. (Default is True).

config_file_permissions_warning / CONFIG_FILE_PERMISSIONS_WARNING / PYIRONCONFIGFILEPERMISSIONSWARNING (bool):

Whether to print a warning message, when the permission of the .pyiron config file, let others access it.

Properties:

configuration (dict): Global variables for configuring the pyiron experience. resource_paths (list[str]): A shortcut to the configuration value for locations with pyiron resources. login_user (str): A shortcut to the configuration value for the user name. default_configuration (dict): Default values for configuration items. environment_configuration_map (dict): A map between system environment variable names and the configuration. file_configuration_map (dict): A map between config file variable names and the configuration.

update()

After instantiation, the configuration can be refreshed with this method, which optionally takes a dictionary (cf keys above) as the primary (overriding) source but otherwise has the same primacy order as the initialization.

convert_path_to_abs_posix()

A path converter, since pyiron internally uses posix style regardless of OS.

property configuration: Dict
static convert_path_to_abs_posix(path: str) str

Convert path to an absolute POSIX path

Parameters:

path (str) – input path.

Returns:

absolute path in POSIX format

Return type:

str

property credentials: Dict
property default_configuration: Dict
property environment_configuration_map: Dict
property environment_credential_map: Dict
property file_configuration_map: Dict
property file_credential_map: Dict
property logger
property login_user: str

Get the username of the current user

Returns:

username

Return type:

str

property publication
publication_add(pub_dict)

Add a publication to the list of publications

Parameters:

pub_dict (dict) – The key should be the name of the code used and the value a list of publications to cite.

property publication_lst

List of publications currently in use.

Returns:

list of publications

Return type:

list

property queue_adapter
property resource_paths: List[str]

Paths for pyiron resources, e.g. executables, queue adapter config files, etc.

Returns:

path of paths

Return type:

list

update(user_dict: Dict | None = None) None

Starting from a clean set of defaults, overwrite with input from exactly one source with the following priority: - User input - System environment variables - A config file at a locations specified in the PYIRONCONFIG system environment variable - A config file at ~/.pyiron - Nothing, just use defaults.

Parameters:

user_dict (dict) – Configuration items