fix precommit again
MODIFY
pangeo_forge/executors/python.py
pangeo_forge/executors/python.py
@@ -3,6 +3,7 @@ from typing import Callable, Iterable
Task = Callable[[], None]
+
class PythonExecutor:
def prepare_plan(self, r):
tasks = []

MODIFY
pangeo_forge/recipe.py
pangeo_forge/recipe.py
@@ -40,22 +40,26 @@ logger = logging.getLogger(__name__)
# Might be coming from the cache or might be read directly.
# 6)
+
@contextmanager
def input_opener(fname, **kwargs):
logger.info(f"Opening input '{fname}'")
with fsspec.open(fname, **kwargs) as f:
yield f
+
# Notes about dataclasses:
# - https://www.python.org/dev/peps/pep-0557/#inheritance
# - https://stackoverflow.com/questions/51575931/class-inheritance-in-python-3-7-dataclasses
# This means that, for now, I can't get default arguments to work.
+
@dataclass
class NetCDFtoZarrSequentialRecipe:
"""There are many inputs (a.k.a. files, granules), arranged in a sequence
along the dimension `sequence_dim`. Each file may contain multiple variables.
"""
+
input_urls: Iterable[str]
"""The inputs used to generate the dataset."""
@@ -140,6 +144,7 @@ class NetCDFtoZarrSequentialRecipe:
chunk_key : str
The identifier for the chunk
"""
+
def _store_chunk(chunk_key):
ds_chunk = self.open_chunk(chunk_key)
@@ -180,8 +185,9 @@ class NetCDFtoZarrSequentialRecipe:
with self.input_cache.open(fname, mode="rb") as f:
yield f
else:
- raise ValueError(f"Input '{fname}' has not been cached yet. "
- "Call .cache_input() first.")
+ raise ValueError(
+ f"Input '{fname}' has not been cached yet. " "Call .cache_input() first."
+ )
def open_input(self, fname: str):
with self.input_opener(fname) as f:

MODIFY
tests/test_recipe.py
tests/test_recipe.py
@@ -11,18 +11,7 @@ dummy_fnames = ["a.nc", "b.nc", "c.nc"]
"file_urls, files_per_chunk, expected_keys, expected_filenames",
[
(dummy_fnames, 1, [0, 1, 2], [("a.nc",), ("b.nc",), ("c.nc",)]),
- (
- dummy_fnames,
- 2,
- [0, 1],
- [
- (
- "a.nc",
- "b.nc",
- ),
- ("c.nc",),
- ],
- ),
+ (dummy_fnames, 2, [0, 1], [("a.nc", "b.nc",), ("c.nc",)]),
],
)
def test_sequence_recipe(file_urls, files_per_chunk, expected_keys, expected_filenames, tmp_target):
@@ -45,7 +34,9 @@ def test_sequence_recipe(file_urls, files_per_chunk, expected_keys, expected_fil
assert fnames == expected
-def test_NetCDFtoZarrSequentialRecipe(daily_xarray_dataset, netcdf_local_paths, tmp_target, tmp_cache):
+def test_NetCDFtoZarrSequentialRecipe(
+ daily_xarray_dataset, netcdf_local_paths, tmp_target, tmp_cache
+):
# the same recipe is created as a fixture in conftest.py
# I left it here explicitly because it makes the test easier to read.

fix precommit again