Skip to content

Commit

Permalink
Merge pull request #437 from pangeo-forge/define-dataset-type
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Nov 8, 2022
2 parents bd90598 + cf3cf0b commit fe5d1f7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions pangeo_forge_recipes/recipes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

@dataclass
class BaseRecipe(ABC):
dataset_type: ClassVar[str]
_compiler: ClassVar[RecipeCompiler]
_hash_exclude_ = ["storage_config"]
sha256: Optional[bytes] = None
Expand Down
1 change: 1 addition & 0 deletions pangeo_forge_recipes/recipes/reference_hdf_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class HDFReferenceRecipe(BaseRecipe, StorageMixin, FilePatternMixin):
:param postprocess: a function applied to the global combined references before write
"""

dataset_type = "kerchunk"
_compiler = hdf_reference_recipe_compiler

# TODO: support chunked ("tree") aggregation: would entail processing each file
Expand Down
1 change: 1 addition & 0 deletions pangeo_forge_recipes/recipes/xarray_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ class XarrayZarrRecipe(BaseRecipe, StorageMixin, FilePatternMixin):
the file with Xarray as a virtual Zarr dataset.
"""

dataset_type = "zarr"
_compiler = xarray_zarr_recipe_compiler

inputs_per_chunk: int = 1
Expand Down
2 changes: 2 additions & 0 deletions tests/recipe_tests/test_HDFReferenceRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def test_single(

execute_recipe(recipe)

assert recipe.dataset_type == "kerchunk"

assert out_target.exists("reference.json")
assert out_target.exists("reference.yaml")

Expand Down
2 changes: 2 additions & 0 deletions tests/recipe_tests/test_XarrayZarrRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def test_recipe(recipe_fixture, execute_recipe):

RecipeClass, file_pattern, kwargs, ds_expected, target = recipe_fixture
rec = RecipeClass(file_pattern, **kwargs)
assert isinstance(rec.dataset_type, str)
assert rec.dataset_type == "zarr"
execute_recipe(rec)
ds_actual = xr.open_zarr(target.get_mapper()).load()
assert_identical(ds_actual, ds_expected)
Expand Down

0 comments on commit fe5d1f7

Please sign in to comment.