forked from pangeo-forge/pangeo-forge-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experiment: How HDFReferenceRecipe would look as a Beam Pipeline.
This is a prototype for using Apache Beam for the internal (and external?) data model of Pangeo Forge Recipes. Here, I demo how HDFReferenceRecipe could be structured into modular components via composite Beam transforms. xref: pangeo-forge#256
- Loading branch information
Showing
3 changed files
with
96 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import typing as t | ||
import s3fs | ||
import sys | ||
import apache_beam as beam | ||
|
||
from pangeo_forge_recipes.patterns import pattern_from_file_sequence | ||
from pangeo_forge_recipes.recipes.reference_hdf_zarr import HDFReferenceRecipe | ||
|
||
BASE_PATH = 's3://esgf-world/CMIP6/OMIP/NOAA-GFDL/GFDL-CM4/omip1/r1i1p1f1/Omon/thetao/gr/v20180701/' | ||
|
||
|
||
def run(pipeline_args: t.List[str]) -> None: | ||
# Define pattern | ||
fs = s3fs.S3FileSystem(anon=True) | ||
all_paths = fs.ls(BASE_PATH) | ||
pattern = pattern_from_file_sequence(['s3://' + path for path in all_paths], 'time') | ||
|
||
# Create Recipe | ||
rec = HDFReferenceRecipe( | ||
pattern, | ||
xarray_open_kwargs={"decode_coords": "all"}, | ||
netcdf_storage_options={"anon": True} | ||
) | ||
|
||
with beam.Pipeline(argv=pipeline_args) as p: | ||
p | rec.to_beam() | ||
|
||
|
||
if __name__ == '__main__': | ||
run(sys.argv[1:]) | ||
|
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