Skip to content

Commit 3bf111d

Browse files
committed
ensure zarr notebook is rendered, add cell metadata for large outputs
1 parent 416e46e commit 3bf111d

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

_toc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ parts:
4444
- file: intermediate/indexing/boolean-masking-indexing.ipynb
4545
- file: intermediate/hierarchical_computation.ipynb
4646
- file: intermediate/xarray_and_dask
47+
- file: intermediate/intro-to-zarr.ipynb
4748
- file: intermediate/xarray_ecosystem
4849
- file: intermediate/hvplot
4950
- file: intermediate/remote_data/index

intermediate/intro-to-zarr.ipynb

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,16 @@
6767
"outputs": [],
6868
"source": [
6969
"import zarr\n",
70+
"import pathlib\n",
71+
"import shutil\n",
7072
"\n",
71-
"z = zarr.create_array(shape=(40, 50), chunks=(10, 10), dtype='f8', store='test.zarr')\n",
73+
"# Ensure we start with a clean directory for the tutorial\n",
74+
"datadir = pathlib.Path('../data/zarr-tutorial')\n",
75+
"if datadir.exists():\n",
76+
" shutil.rmtree(datadir)\n",
77+
"\n",
78+
"output = datadir / 'test.zarr'\n",
79+
"z = zarr.create_array(shape=(40, 50), chunks=(10, 10), dtype='f8', store=output)\n",
7280
"z"
7381
]
7482
},
@@ -188,20 +196,28 @@
188196
"cell_type": "code",
189197
"execution_count": null,
190198
"id": "14",
191-
"metadata": {},
199+
"metadata": {
200+
"tags": [
201+
"scroll-output"
202+
]
203+
},
192204
"outputs": [],
193205
"source": [
194-
"!tree -a test.zarr"
206+
"!tree -a ../data/test.zarr"
195207
]
196208
},
197209
{
198210
"cell_type": "code",
199211
"execution_count": null,
200212
"id": "15",
201-
"metadata": {},
213+
"metadata": {
214+
"tags": [
215+
"scroll-output"
216+
]
217+
},
202218
"outputs": [],
203219
"source": [
204-
"!cat test.zarr/zarr.json"
220+
"!cat ../data/test.zarr/zarr.json"
205221
]
206222
},
207223
{
@@ -330,7 +346,8 @@
330346
"metadata": {},
331347
"outputs": [],
332348
"source": [
333-
"c = zarr.create_array(shape=(200, 200, 200), chunks=(1, 200, 200), dtype='f8', store='c.zarr')\n",
349+
"output = datadir / 'c.zarr'\n",
350+
"c = zarr.create_array(shape=(200, 200, 200), chunks=(1, 200, 200), dtype='f8', store=output)\n",
334351
"c[:] = np.random.randn(*c.shape)"
335352
]
336353
},
@@ -351,7 +368,8 @@
351368
"metadata": {},
352369
"outputs": [],
353370
"source": [
354-
"d = zarr.create_array(shape=(200, 200, 200), chunks=(200, 200, 1), dtype='f8', store='d.zarr')\n",
371+
"output = datadir / 'd.zarr'\n",
372+
"d = zarr.create_array(shape=(200, 200, 200), chunks=(200, 200, 1), dtype='f8', store=output)\n",
355373
"d[:] = np.random.randn(*d.shape)"
356374
]
357375
},
@@ -401,8 +419,6 @@
401419
"metadata": {},
402420
"outputs": [],
403421
"source": [
404-
"import zarr\n",
405-
"\n",
406422
"z6 = zarr.create_array(\n",
407423
" store={},\n",
408424
" shape=(10000, 10000, 1000),\n",
@@ -485,7 +501,7 @@
485501
"id": "41",
486502
"metadata": {},
487503
"source": [
488-
"```{info}\n",
504+
"```{note}\n",
489505
"`.info_complete()` provides a more detailed view of the Zarr array, including metadata about the chunks, compressors, and attributes, but will be slower for larger arrays. \n",
490506
"```"
491507
]
@@ -528,7 +544,11 @@
528544
"cell_type": "code",
529545
"execution_count": null,
530546
"id": "45",
531-
"metadata": {},
547+
"metadata": {
548+
"tags": [
549+
"hide-output"
550+
]
551+
},
532552
"outputs": [],
533553
"source": [
534554
"from pprint import pprint\n",
@@ -646,14 +666,6 @@
646666
"- [Scalable and Computationally Reproducible Approaches to Arctic Research](https://learning.nceas.ucsb.edu/2025-04-arctic/sections/zarr.html)\n",
647667
"- [Zarr Cloud Native Geospatial Tutorial](https://github.com/zarr-developers/tutorials/blob/main/zarr_cloud_native_geospatial_2022.ipynb)"
648668
]
649-
},
650-
{
651-
"cell_type": "code",
652-
"execution_count": null,
653-
"id": "54",
654-
"metadata": {},
655-
"outputs": [],
656-
"source": []
657669
}
658670
],
659671
"metadata": {

0 commit comments

Comments
 (0)