em_database.config#

Runtime settings for em_database, in the style of matplotlib’s rcParams.

em_database.settings is a live dict, seeded at import from a YAML file (or the built-in defaults). Change it in memory:

import em_database
em_database.settings["data_dir"] = "/big/disk/em_data"

and it takes effect immediately. To remember the choice across sessions, persist it:

em_database.settings.save()

Settings live in a ~/.em_database folder (~/.em_database/settings.yaml), or wherever EM_DATABASE_CONFIG points. No environment variable is needed to configure em_database - the settings object is the source of truth; the old EM_DATABASE_DATA_DIR is still honored as a seed for backward compatibility.

Data can also be installed system-wide and shared by every user. When resolving where a dataset lives, em_database looks in the shared/system locations first, then the user’s own data directory, and only downloads (into the user directory) if it is nowhere to be found. Shared locations come from a system config file (see system_config_path()), the EM_DATABASE_SHARED_DIR environment variable (an os.pathsep-separated list), or a shared_data_dirs list in the user’s settings.

Module Attributes

DEFAULTS

Built-in defaults - the fallback when nothing is configured.

settings

The live settings object (seeded once at import).

Functions

config_dir()

The ~/.em_database folder that holds the settings file.

config_path()

Path to the YAML settings file.

data_dir()

The user's data directory - where downloads are written.

data_search_dirs()

Everywhere to look for an existing dataset: shared/system dirs first, then the user's data directory.

shared_data_dirs()

System-wide / shared data locations, checked before the user's dir.

system_config_path()

Path to the machine-wide settings file (for system-wide installs).

Classes

Settings

A live settings mapping that can persist itself to the YAML file.