-
Notifications
You must be signed in to change notification settings - Fork 54
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
Persist execution context in storage target #359
Merged
rabernat
merged 14 commits into
pangeo-forge:master
from
cisaacstern:persist-execution-context
Jun 6, 2022
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
94be70d
add BaseRecipe.get_execution_context
cisaacstern 3ca6066
get pangeo-forge-recipes (not registrar) version
cisaacstern a5b6f8f
add test_execution_context
cisaacstern e8fa96d
Merge remote-tracking branch 'origin/master' into persist-execution-c…
cisaacstern 474d69b
Merge remote-tracking branch 'origin/master' into persist-execution-c…
cisaacstern 5dd3f45
write pangeo-forge execution context to store in XarrayZarrRecipe.pre…
cisaacstern 2cb2e59
drop execution context vars from XarrayZarrRecipe equality tests
cisaacstern d356bd7
update execution context version asserts for actions runners compatib…
cisaacstern d3fcf0f
execution context docs first pass
cisaacstern 62183f3
mark HDFReference recipe execution context as TODO in docs
cisaacstern b781e30
add assert identical wrapper to test_XarrayZarrRecipe
cisaacstern a84793d
add json handler for funcs, update test bc funcs are now serializable
cisaacstern 149108c
use ds.copy() without deep=True
cisaacstern 88bd8f4
Merge remote-tracking branch 'origin/master' into persist-execution-c…
cisaacstern 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 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
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 really need a deep copy here? That will use a lot more memory.
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.
I'm not sure! It's "just" the tests so happy to use regular copy and see how it goes.
TBH, I've now run into enough weird behavior of copied dictionaries that are not deep copies (due to shared references with the original, I guess), that I just reflexively make all dictionary copies deep now. 😅