-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚑 Package atlas_catalog.yaml into deepicedrain
So that calling `deepicedrain.catalog` will actually work when people `pip install deepicedrain` without cloning the git repository (otherwise a FileNotFoundError is raised). Added a plugin to pyproject.toml so that the ATLAS catalog can be loaded via intake through `intake.cat.atlas_cat` too! Done by moving atlas_catalog.yaml and tests/ into the deepicedrain folder. This relies on a bit of magic (good ones), using the Python 3.7+ importlib.resources module to locate the atlas_catalog.yaml file via a relative path where the package is installed (in site-packages). Basically following a modified version of https://github.com/intake/intake-examples/tree/04bbe1880f2a4d2c74c6ea9c54385c380c1b9a1e/data_package. Had to use {{ CATALOG_DIR }} to link to the test_catalog.yaml file too. Side effect of this is that we're bundling all our tests into the `deepicedrain` python package, which might be bad for file size but good for finding test examples I guess.
- Loading branch information
Showing
9 changed files
with
15 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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,10 +1,18 @@ | ||
import importlib.resources | ||
import logging | ||
|
||
import intake | ||
|
||
import deepicedrain | ||
from deepicedrain.deltamath import calculate_delta | ||
from deepicedrain.spatiotemporal import Region | ||
|
||
__version__: str = "0.1.0" | ||
|
||
# Loads the ICESat-2 ATLAS intake data catalog | ||
catalog: intake.catalog.local.YAMLFileCatalog = intake.open_catalog( | ||
uri="atlas_catalog.yaml" | ||
_catalog_path = importlib.resources.path( | ||
package=deepicedrain, resource="atlas_catalog.yaml" | ||
) | ||
with _catalog_path as uri: | ||
logging.info(f"Loading intake catalog from {uri}") | ||
catalog: intake.catalog.local.YAMLFileCatalog = intake.open_catalog(uri=str(uri)) |
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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