Repository navigation
Settings in ~/.em_database + system-wide data resolution - #10
Merged
Merged
Conversation
- em_database.settings is a live, rcParams-style dict seeded at import from ~/.em_database/settings.yaml (override with EM_DATABASE_CONFIG). Mutate in memory for an immediate effect; settings.save() / set_data_dir(persist=True) persist across sessions. No env var is needed; EM_DATABASE_DATA_DIR is still honored as a backward-compat seed. - save() writes only values that differ from the defaults, so a default (like the data dir) is never frozen into the file - it stays dynamic and obeyed. - Data can be installed system-wide: filepath()/download() search shared locations first (EM_DATABASE_SHARED_DIR, a shared_data_dirs setting, or a system config at /etc/em_database or %PROGRAMDATA%), then the user's data dir, and only download (into the user dir) if it is nowhere to be found. - Colab: auto-enable the custom widget manager and broaden notebook detection so browse()/display()/toasts work out of the box. - Tests isolate the user + system config; add test_settings and test_shared_data.
Update the README and the changing_download_location example to use em_database.settings (matplotlib rcParams-style, ~/.em_database/settings.yaml), the persist/session-only set_data_dir, generic get_setting/set_setting, and the system-wide shared-data locations. The example resets settings at the end so it leaves nothing behind when run by the docs gallery.
display(em_database.settings) (or em_database.settings.widget()) now renders an anywidget panel to set the data directory directly - Save (persist), Use for session (in-memory), or Reset - and shows the settings-file path and the shared-then-user search order. Falls back to the dict repr without anywidget.
Pick a folder with a hidden webkitdirectory <input> in the browser and fill the path field client-side (deriving the absolute path from File.path where the environment exposes it, e.g. desktop/Electron), then Save. No kernel-side dialog.
The webkitdirectory input made the browser show an "upload" dialog. Use a plain file <input> instead (a normal "Open" dialog) and take the selected file's parent as the directory. Move the Browse button onto the directory line, to the right of the path field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the env-var-based data-dir config with a matplotlib-
rcParams-stylesettings object backed by a YAML file, and adds system-wide → per-user data
resolution.
Settings (
em_database.settings)~/.em_database/settings.yaml(relocate withEM_DATABASE_CONFIG). Mutate in memory for an immediate effect:em_database.settings["data_dir"] = "/big/disk";settings.save()orset_data_dir(..., persist=True)persists across sessions.EM_DATABASE_DATA_DIRis still honored as abackward-compat seed.
save()writes only values that differ from the defaults, so a default(like the data dir) is never frozen into the file — it stays dynamic and keeps
being obeyed across sessions/machines/default changes.
get_setting/set_settingfor arbitrary keys;reset_data_dir()clears thesaved choice.
System-wide vs per-user data
filepath()anddownload()search shared/system locations first, then theuser's data dir, and only download (into the user dir) if the file is nowhere.
EM_DATABASE_SHARED_DIR(anos.pathseplist), ashared_data_dirssetting, or a system config file(
/etc/em_database/settings.yamlor%PROGRAMDATA%\em_database\settings.yaml).re-downloading.
Colab
browse(),display(ds), and download toasts work out of the box.Misc
platformdirsdependency (uses~/.em_database).Tests
83 non-slow pass. Adds
test_settings.py,test_shared_data.py, and aconftest.pythat isolates every test from the developer's real user/systemconfig.