emdatabase.config#
Configuration for emdatabase, in the style of dask’s (and quantem’s) config.
Two keys are shipped, in emdatabase/emdatabase.yaml. locations is a
mapping of name to directory: personal is the reserved name for the one
writable location, where downloads go (null means pooch’s cache directory);
every other entry is a read-only directory, searched before it:
locations:
example_data: /group/example_data
personal: /big/disk/emdatabase
check_updates (true by default) is whether downloading a weights family’s
latest asks the index on the project’s main branch whether newer
weights have been published, and warns if they have.
Add and remove entries with add_location(), locations() and
remove_location():
from emdatabase import config
config.add_location("/group/example_data") # read-only
config.add_location("/big/disk/emdatabase", name="personal") # downloads
config.locations() # search order
config.remove_location("example_data")
Each of those persists to the config file unless called with persist=False.
A location’s name is also what a download writes into, which is how a shared
location is seeded: data.CuZnHAADF().download(destination="example_data").
Or read and write the key directly:
config.get("locations")
config.set({"locations.personal": "/big/disk/emdatabase"}) # for this process
with config.set({"locations.personal": "/scratch"}): # or for a block
...
config.write() # persist to the yaml
Or from the environment, prefix EMDATABASE_, double underscore to nest:
EMDATABASE_LOCATIONS__PERSONAL=/scratch/data
EMDATABASE_LOCATIONS__GROUP=/wigeon/shared/example_data
Files live in ~/.config/emdatabase (or wherever EMDATABASE_CONFIG
points); every *.yaml and *.yml in that directory is merged, in name
order. Precedence, lowest first: shipped defaults, config files, environment
variables, set.
Functions
|
Add a location, or repoint one that is already configured. |
|
Return the canonical name for a key. |
|
Check whether a key has been renamed, removed, or is not one we ship |
|
Collect configuration from the config directory and the environment |
|
Collect config from environment variables |
|
Collect configuration from the yaml files in a directory |
|
The directory downloads are written to. |
|
Everywhere to look for an existing dataset: the shared locations, then |
|
Say where downloads will go, once per process. |
|
Get elements from global config |
|
|
|
Every configured location, in search order. |
|
Update a sequence of nested dictionaries |
|
Update configuration by re-reading yaml files and env variables |
|
Remove a location, or reset |
|
The directory a |
|
Update a nested dictionary with values from another |
|
Add a new set of defaults to the configuration |
|
Write the current configuration to a yaml file. |
Classes
|
One place datasets are looked for. |
|
Temporarily set configuration values within a context manager |