Skip to content

Commit f1a295e

Browse files
committed
Move manifest to s3
1 parent aef680e commit f1a295e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

examples/virtual-rechunk/create-virtualzarr.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def reduce_references(results):
4040
coords="minimal",
4141
compat="override",
4242
)
43-
43+
4444
return combined_vds
4545

4646

@@ -55,5 +55,9 @@ def reduce_references(results):
5555

5656
ds = futures.get_result()
5757

58-
# Save the virtual zarr manifest to s3
59-
ds.virtualize.to_kerchunk(f"{bucket_url}/combined.json", format="json")
58+
# Save the virtual zarr manifest
59+
ds.virtualize.to_kerchunk(f"combined.json", format="json")
60+
61+
# Upload manifest to s3
62+
fs_write = fsspec.filesystem("s3", anon=False, skip_instance_cache=True)
63+
fs_write.put("combined.json", f"{bucket_url}/combined.json")

examples/virtual-rechunk/virtual-rechunk.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
# aren't propogated until the kernel is restarted.
88

99
import os
10+
import fsspec
1011
import xarray as xr
1112

1213
bucket_url = os.getenv("BUCKET_URL")
1314

15+
target = fsspec.get_mapper(f"{bucket_url}/rechunked.zarr")
16+
# client_kwargs={'region_name':'us-west-2'})
17+
1418
combined_ds = xr.open_dataset(
1519
f"{bucket_url}/combined.json", # location must be accessible to workers
1620
engine="kerchunk",
@@ -26,7 +30,7 @@
2630
)
2731

2832
rechunked_ds.to_zarr(
29-
f"{bucket_url}/rechunked.zarr",
33+
target,
3034
mode="w",
3135
encoding={}, # TODO
3236
consolidated=True,

0 commit comments

Comments
 (0)