-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist execution context in storage target (#359)
* add BaseRecipe.get_execution_context * get pangeo-forge-recipes (not registrar) version * add test_execution_context * write pangeo-forge execution context to store in XarrayZarrRecipe.prepare_target * drop execution context vars from XarrayZarrRecipe equality tests * update execution context version asserts for actions runners compatibility * execution context docs first pass * mark HDFReference recipe execution context as TODO in docs * add assert identical wrapper to test_XarrayZarrRecipe * add json handler for funcs, update test bc funcs are now serializable * use ds.copy() without deep=True
- Loading branch information
1 parent
3d979a5
commit c0ce841
Showing
9 changed files
with
109 additions
and
14 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
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
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
import xarray as xr | ||
import zarr | ||
from packaging import version | ||
|
||
from pangeo_forge_recipes.recipes import XarrayZarrRecipe | ||
|
||
|
||
@pytest.mark.parametrize("recipe_cls", [XarrayZarrRecipe]) # HDFReferenceRecipe]) | ||
def test_execution_context(recipe_cls, netcdf_local_file_pattern_sequential): | ||
|
||
recipe = recipe_cls(netcdf_local_file_pattern_sequential) | ||
ec = recipe.get_execution_context() | ||
|
||
ec_version = version.parse(ec["version"]) | ||
assert ec_version.is_devrelease # should be True for editable installs used in tests | ||
assert isinstance(ec_version.major, int) and 0 <= ec_version.major <= 1 | ||
assert isinstance(ec_version.minor, int) and 0 <= ec_version.major <= 99 | ||
|
||
assert isinstance(ec["recipe_hash"], str) and len(ec["recipe_hash"]) == 64 | ||
assert isinstance(ec["inputs_hash"], str) and len(ec["inputs_hash"]) == 64 | ||
|
||
recipe.to_function()() | ||
zgroup = zarr.open_group(recipe.target_mapper) | ||
ds = xr.open_zarr(recipe.target_mapper, consolidated=True) | ||
|
||
for k, v in ec.items(): | ||
assert zgroup.attrs[f"pangeo-forge:{k}"] == v | ||
assert ds.attrs[f"pangeo-forge:{k}"] == v |
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