Add `dataset_type` class attribute for recipe classes
MODIFY
pangeo_forge_recipes/recipes/base.py
pangeo_forge_recipes/recipes/base.py
@@ -14,6 +14,7 @@ from ..storage import StorageConfig, temporary_storage_config
@dataclass
class BaseRecipe(ABC):
+ dataset_type: ClassVar[str]
_compiler: ClassVar[RecipeCompiler]
_hash_exclude_ = ["storage_config"]
sha256: Optional[bytes] = None

MODIFY
pangeo_forge_recipes/recipes/reference_hdf_zarr.py
pangeo_forge_recipes/recipes/reference_hdf_zarr.py
@@ -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

MODIFY
pangeo_forge_recipes/recipes/xarray_zarr.py
pangeo_forge_recipes/recipes/xarray_zarr.py
@@ -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

MODIFY
tests/recipe_tests/test_HDFReferenceRecipe.py
tests/recipe_tests/test_HDFReferenceRecipe.py
@@ -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")

MODIFY
tests/recipe_tests/test_XarrayZarrRecipe.py
tests/recipe_tests/test_XarrayZarrRecipe.py
@@ -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)

Add `dataset_type` class attribute for recipe classes