agentleFS
90184479018447/julia-pro-p/skills/zarr-cloud-arrays/SKILL.md

zarr-cloud-arrays

Skill0 starsChanged 4 days agoMITView on GitHub

Cloud-native arrays with Zarr.jl: chunk and shard design, safe parallel writes, and HDF5 or NetCDF migration. Use when data outgrows one file or one machine.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Prefer v3 for new data (zarr.json, codec pipeline, sharding).

    line 16
  2. Distinctive:

    Align with source and writers: use multiples of the source file's chunks, and give each writer whole chunks or shards.

    line 25
  3. Distinctive:

    Codecs: start with Blosc + Zstd level 3–5, shuffle on.

    line 27
  4. Very specific:

    Create the empty array first (shape, dtype, chunks, fill_value), then fill regions in parallel.

    line 32
  5. Distinctive:

    Create the empty target, then copy block by block.

    line 45

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Cloud-Native Zarr Arrays

Zarr stores an N-D array as independently compressed chunks plus small JSON metadata. On object storage each chunk is one object, so readers fetch only the slice they need and many workers read or write at once. Most problems reduce to three decisions: chunk shape, who writes which chunk, and how metadata is found.

Load only what the task needs: julia.md (Zarr.jl) or xpcs.md (APS 8-ID-I XPCS result layout). The Zarr.jl names were checked against 0.11 on 2026-10-13; recheck them on another version.

Format choice

Zarr for large N-D arrays with partial reads, parallel I/O, or object storage. Keep NetCDF/HDF5 for single files on shared POSIX disks. Use Virtual Zarr (VirtualiZarr, Kerchunk) when archives cannot be rewritten. Parquet suits tables, Cloud-Optimized GeoTIFF a single raster.

Prefer v3 for new data (zarr.json, codec pipeline, sharding); write v2 only for readers that cannot read v3. Consolidated metadata (one request for the whole hierarchy) is a v2 feature; in v3 it is an extension outside the spec, so check the target reader.

Design chunks before writing

Chunks are fixed once written; changing them rewrites the data.

  1. Name the dominant read (point time series, map at one time, ML window). Make chunks long along what the read spans, short elsewhere. Opposing patterns need two copies.
  2. Size by bytes: product of chunk dims × itemsize, roughly 1–100 MB uncompressed. Smaller means many tiny requests; larger wastes bandwidth. Compute it: (100, 100, 1) float32 is 40 KB, far too small.
  3. Shard for object count (v3): shards of about 100 MB–1 GB keep a store at thousands of objects, not millions. The inner chunk is the read unit (a byte-range read), so inner chunks under 1 MB are fine inside large shards; size them to the read window.
  4. Align with source and writers: use multiples of the source file's chunks, and give each writer whole chunks or shards.

Codecs: start with Blosc + Zstd level 3–5, shuffle on; time byte versus bit shuffle on a real slice. Lossy codecs change values, so the user must approve them.

Writing safely

  • Writing part of a chunk reads, modifies, and rewrites it; two workers on one chunk silently lose an update. Partition by chunk (or shard) boundaries.
  • Create the empty array first (shape, dtype, chunks, fill_value), then fill regions in parallel.
  • Plain object stores lack transactions, so a failed job leaves a visible half-written store. Use Icechunk, or write to a scratch prefix and switch after validation. Never overwrite the only copy.

Reading efficiently

Open lazily (metadata, not data). Use consolidated metadata where supported and anonymous access for public buckets. A slice crossing N chunks costs N requests. Run compute in the bucket's region to avoid egress and slow transfers.

Migrating HDF5 or NetCDF

Choose the route first: a virtual store when the archive cannot be rewritten, otherwise a block copy. For a rewrite:

  1. Inspect shapes, dtypes, internal chunks (None is contiguous), filters, fill values, scale/offset, attributes, dimension names.
  2. Pick target chunks from the read pattern and byte target, as multiples of source chunks.
  3. Create the empty target, then copy block by block; never load a dataset whole.
  4. Carry the missing-value marker: set fill_value to the source's, because unwritten chunks read as fill_value (0 by default) and 0 looks like data. Keep the CF _FillValue attribute. A reader that returns missing or NaN mismatches the on-disk dtype; copy raw values or decode on purpose.
  5. Copy attributes, dimension names, groups. List anything unrepresentable (references, non-numeric compounds); never drop it silently.

The Julia calls for creating the store and copying a block are in julia.md. For a batch of files, trial one file first (time, memory, object count) before scaling.

Verify

Done means: nothing skipped (or the user accepted the list); shape, dtype, chunks, fill value, attributes match the plan; a full comparison (small input) or sampled slices (large) are equal, with tolerance only for approved lossy codecs; a reduction (sum, mean) agrees; object count and size are in range. Report the numbers, and keep the source until a reader has used the new store.

Credentials and cost

Take credentials from the environment, a profile, or an instance role; never write or print keys. Listing and requests cost money, so check object counts and egress before a large job and flag plans producing millions of objects.

Done when

The chunk shape was chosen from the access pattern before writing, the store was verified by a full or sampled comparison plus a reduction, credentials came from the environment, and the object count and egress cost were estimated before the large job.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.