Repository navigation
Allow a separate store root for each modality #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| defaults: | ||
| - _self_ | ||
| - paths | ||
| - eval: gobabeb | ||
|
|
||
| # --- required --- | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # @package paths | ||
| # Site paths shared by training, inference and asset generation. | ||
| # Use a separate preload cache when changing the common store root. | ||
| eozarr_root: /Net/Groups/BGI/work_5/scratch/WeatherGenerator/data/lowres_old | ||
| preload_cache_root: null | ||
| preload_cache_parent: /Net/Groups/BGI/tscratch | ||
|
|
||
| # Only list modalities whose stores live under a different root. | ||
| store_roots: {} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
|
|
||
| defaults: | ||
| - _self_ | ||
| - paths | ||
| - sources: eozarr | ||
|
|
||
| modality: ??? | ||
|
|
||
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,8 @@ def open_store_reader(modality, store, data_types): | |
| reader_kwargs[flag] = data_type in data_types | ||
| accepted = inspect.signature(get_data_reader_class(modality)).parameters | ||
| reader_kwargs = {key: value for key, value in reader_kwargs.items() if key in accepted} | ||
| return eodata.get_data_reader(modality, store=str(PATHS.eozarr_store_path(store)), **reader_kwargs) | ||
| store_path = PATHS.eozarr_store_path(store, PATHS.store_roots.get(modality)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above, do we still need PATHS? |
||
| return eodata.get_data_reader(modality, store=str(store_path), **reader_kwargs) | ||
|
|
||
|
|
||
| def load_store_columns(modality, store, spatial, load, anchor="mtg", day_range=None, num_workers=8): | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,25 @@ | |
| import os | ||
| import re | ||
| from dataclasses import dataclass, field | ||
| from functools import cache | ||
| from pathlib import Path | ||
|
|
||
| from omegaconf import OmegaConf | ||
|
|
||
|
|
||
| @cache | ||
| def _default_paths() -> dict: | ||
| return OmegaConf.to_container( | ||
| OmegaConf.load(Path(__file__).resolve().parents[2] / "conf" / "paths.yaml"), resolve=True | ||
| ) | ||
|
|
||
|
|
||
| def _preload_cache_root(settings: dict) -> Path: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to change this such that we also set this path manually in the paths.yaml |
||
| root = settings["preload_cache_root"] or os.environ.get("DEEP_LST_CACHE_ROOT") | ||
| if root: | ||
| return Path(root) | ||
| return Path(settings["preload_cache_parent"]) / (os.environ.get("USER") or getpass.getuser()) / "tmp" | ||
|
|
||
|
|
||
| @dataclass | ||
| class ExperimentPaths: | ||
|
|
@@ -12,17 +29,21 @@ class ExperimentPaths: | |
| experiment_root: Path = field(default_factory=lambda: Path("./experiments")) | ||
| config_root: Path = field(default_factory=lambda: Path("./configs")) | ||
| assets_root: Path = field(default_factory=lambda: Path("./assets")) | ||
| # Full eodata stores. Moved off tscratch (90-day purge) in October 2026. | ||
| eozarr_root: Path = field( | ||
| default_factory=lambda: Path("/Net/Groups/BGI/work_5/scratch/WeatherGenerator/data/lowres_old") | ||
| ) | ||
| preload_cache_root: Path = field( | ||
| default_factory=lambda: Path( | ||
| os.environ.get("DEEP_LST_CACHE_ROOT") | ||
| or f"/Net/Groups/BGI/tscratch/{os.environ.get('USER') or getpass.getuser()}/tmp" | ||
| ) | ||
| eozarr_root: Path = field(default_factory=lambda: Path(_default_paths()["eozarr_root"])) | ||
| preload_cache_root: Path = field(default_factory=lambda: _preload_cache_root(_default_paths())) | ||
| store_roots: dict[str, str | None] = field( | ||
| default_factory=lambda: dict(_default_paths()["store_roots"]), kw_only=True | ||
| ) | ||
|
|
||
| @classmethod | ||
| def from_config(cls, config) -> "ExperimentPaths": | ||
| settings = {**_default_paths(), **{key: value for key, value in (config or {}).items() if value is not None}} | ||
| cache_root = _preload_cache_root(settings) | ||
| settings.pop("preload_cache_parent") | ||
| store_roots = dict(settings.pop("store_roots")) | ||
| settings["preload_cache_root"] = cache_root | ||
| return cls(store_roots=store_roots, **{key: Path(value) for key, value in settings.items()}) | ||
|
|
||
| def experiment_dir(self, experiment: str) -> Path: | ||
| return self.experiment_root / experiment | ||
|
|
||
|
|
@@ -50,14 +71,15 @@ def config_path(self, experiment: str) -> Path: | |
| def statistics_path(self, modality, name) -> Path: | ||
| return self.assets_root / modality / "statistics" / f"statistics_{name}.npz" | ||
|
|
||
| def eozarr_store_path(self, store_name: str) -> Path: | ||
| def eozarr_store_path(self, store_name: str, store_root: str | Path | None = None) -> Path: | ||
| """Resolve a full eodata .eozarr store from its config-provided name. | ||
|
|
||
| Prefers the directory store when it is readable and falls back to the .zip sibling: | ||
| under eozarr_root the era5, era5_land, glofas and swe stores exist only as zips, while | ||
| under the selected root the era5, era5_land, glofas and swe stores exist only as zips, while | ||
| seviri is a directory store.""" | ||
| directory = self.eozarr_root / f"{store_name}.eozarr" | ||
| archive = self.eozarr_root / f"{store_name}.eozarr.zip" | ||
| root = self.eozarr_root if store_root is None else Path(store_root) | ||
| directory = root / f"{store_name}.eozarr" | ||
| archive = root / f"{store_name}.eozarr.zip" | ||
| directory_is_readable = (directory / "data" / "zarr.json").exists() | ||
| if not directory_is_readable and archive.exists(): | ||
| return archive | ||
|
|
||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need PATHS?