chore: update documentation and descriptions for scientific skills

- Revised the README and scientific skills documentation to enhance clarity and detail, including updates to the What-If Oracle and Vaex skills.
- Improved descriptions for scenario analysis and data processing capabilities, emphasizing new features and usage examples.
- Updated installation instructions and compatibility notes for Vaex and Zarr skills, ensuring alignment with the latest library versions.
- Enhanced the xlsx skill documentation to clarify requirements and installation steps, including optional dependencies for improved functionality.
This commit is contained in:
Timothy Kassis committed 2026-05-27 14:30:14 -07:00
1 parent d9473cf7db
commit b092ba5d4a
13 files changed
+481 -591

No files matched your search

+79 -96
View File
@@ -1,7 +1,9 @@
---
name: zarr-python
description: Chunked N-D arrays for cloud storage. Compressed arrays, parallel I/O, S3/GCS integration, NumPy/Dask/Xarray compatible, for large-scale scientific computing pipelines.
description: Chunked N-D arrays for cloud storage (Zarr-Python 3). Compressed arrays, parallel I/O, S3/GCS via fsspec, NumPy/Dask/Xarray compatible, for large-scale scientific computing pipelines.
allowed-tools: Read Write Edit Bash
license: MIT license
compatibility: Requires Python 3.12+ and zarr 3.x. Cloud I/O needs zarr[remote] plus s3fs or gcsfs. Legacy Zarr v2 workflows use zarr==2.* on older Python.
metadata:
skill-author: K-Dense Inc.
---
@@ -12,20 +14,26 @@ metadata:
Zarr is a Python library for storing large N-dimensional arrays with chunking and compression. Apply this skill for efficient parallel I/O, cloud-native workflows, and seamless integration with NumPy, Dask, and Xarray.
**Current upstream:** zarr **3.2.1** (PyPI, May 2026). Docs: [zarr.readthedocs.io](https://zarr.readthedocs.io/en/stable/). New arrays default to **Zarr format 3**; set `zarr_format=2` for legacy interop. This skill is a **community guide** maintained by K-Dense Inc., not an official zarr-developers package.
## Quick Start
### Installation
```bash
uv pip install zarr
uv pip install "zarr>=3.2,<4"
```
Requires Python 3.11+. For cloud storage support, install additional packages:
```python
uv pip install s3fs # For S3
uv pip install gcsfs # For Google Cloud Storage
Requires **Python 3.12+** (per PyPI metadata for zarr 3.2.x). For remote stores (S3, GCS, HTTP):
```bash
uv pip install "zarr[remote]"
uv pip install s3fs # AWS S3
uv pip install gcsfs # Google Cloud Storage
```
Pin `zarr>=3,<4` in application dependencies. Use `uv pip install "zarr==2.*"` only when you must stay on Zarr-Python 2 / Python 3.10–3.11.
### Basic Array Creation
```python
@@ -108,8 +116,8 @@ z.blocks[0, 0] # Block/chunk indexing
### Resizing and Appending
```python
# Resize array
z.resize(15000, 15000) # Expands or shrinks dimensions
# Resize array (v3: pass shape as a tuple)
z.resize((15000, 15000))
# Append data along an axis
z.append(np.random.random((1000, 10000)), axis=0) # Adds rows
@@ -159,8 +167,7 @@ z = zarr.zeros((10000, 10000), chunks=(1000, 1000)) # Square chunks
When arrays have millions of small chunks, use sharding to group chunks into larger storage objects:
```python
from zarr.codecs import ShardingCodec, BytesCodec
from zarr.codecs.blosc import BloscCodec
from zarr.codecs import BloscCodec, BytesCodec, ShardingCodec
# Create array with sharding
z = zarr.create_array(
@@ -186,8 +193,7 @@ Zarr applies compression per chunk to reduce storage while maintaining fast acce
### Configuring Compression
```python
from zarr.codecs.blosc import BloscCodec
from zarr.codecs import GzipCodec, ZstdCodec
from zarr.codecs import BloscCodec, GzipCodec, ZstdCodec, BytesCodec
# Default: Blosc with Zstandard
z = zarr.zeros((1000, 1000), chunks=(100, 100)) # Uses default compression
@@ -291,23 +297,37 @@ store.close()
### Cloud Storage (S3, GCS)
Zarr 3 uses **fsspec** backends via URI strings or `FsspecStore` (preferred over legacy `S3Map`/`GCSMap`).
```python
import s3fs
import zarr
# S3 storage
s3 = s3fs.S3FileSystem(anon=False) # Use credentials
store = s3fs.S3Map(root='my-bucket/path/to/array.zarr', s3=s3)
z = zarr.open_array(store=store, mode='w', shape=(1000, 1000), chunks=(100, 100))
# S3 — credentials from standard AWS env vars (scope reads to these keys only)
# AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION
z = zarr.create_array(
store="s3://my-bucket/path/to/array.zarr",
shape=(1000, 1000),
chunks=(100, 100),
dtype="f4",
storage_options={"anon": False},
)
z[:] = data
# Google Cloud Storage
import gcsfs
gcs = gcsfs.GCSFileSystem(project='my-project')
store = gcsfs.GCSMap(root='my-bucket/path/to/array.zarr', gcs=gcs)
z = zarr.open_array(store=store, mode='w', shape=(1000, 1000), chunks=(100, 100))
# GCS — GOOGLE_APPLICATION_CREDENTIALS or gcloud default credentials
z = zarr.open_array(
"gs://my-bucket/path/to/array.zarr",
mode="r",
storage_options={"project": "my-project"},
)
# Explicit store (any fsspec filesystem)
from zarr.storage import FsspecStore
store = FsspecStore.from_url("s3://my-bucket/data.zarr", storage_options={"anon": False})
root = zarr.open_group(store=store, mode="r+")
```
Cloud backends read credentials from provider environment variables locally via fsspec; they are not sent to third-party endpoints outside your configured bucket/project.
**Cloud Storage Best Practices**:
- Use consolidated metadata to reduce latency: `zarr.consolidate_metadata(store)`
- Align chunk sizes with cloud object sizing (typically 5-100 MB optimal)
@@ -356,19 +376,16 @@ print(root.tree())
# └── prcp (365, 720, 1440) f4
```
### H5py-Compatible API
### Group API (v3)
Zarr provides an h5py-compatible interface for familiar HDF5 users:
Use `create_array` / `require_array` (h5py-style `create_dataset` / `require_dataset` were removed in v3):
```python
# Create group with h5py-style methods
root = zarr.group('data.zarr')
dataset = root.create_dataset('my_data', shape=(1000, 1000), chunks=(100, 100),
dtype='f4')
arr = root.create_array('my_data', shape=(1000, 1000), chunks=(100, 100), dtype='f4')
# Access like h5py
grp = root.require_group('subgroup')
arr = grp.require_dataset('array', shape=(500, 500), chunks=(50, 50), dtype='i4')
arr2 = grp.require_array('array', shape=(500, 500), chunks=(50, 50), dtype='i4')
```
## Attributes and Metadata
@@ -490,41 +507,15 @@ ds.to_zarr('climate_data.zarr')
- Integration with pandas for time series
- NetCDF-like interface familiar to climate/geospatial scientists
## Parallel Computing and Synchronization
## Parallel Computing and Thread Safety
### Thread-Safe Operations
The `synchronizer` argument (`ThreadSynchronizer`, `ProcessSynchronizer`) is **not ported to Zarr-Python 3** yet. Use these patterns instead:
```python
from zarr import ThreadSynchronizer
import zarr
- **Reads:** always safe across threads/processes.
- **Writes:** safe when each worker writes to **non-overlapping chunks**; most stores support atomic chunk writes.
- **Overlapping writes:** coordinate externally (file locks, workflow design) until synchronizers return.
# For multi-threaded writes
synchronizer = ThreadSynchronizer()
z = zarr.open_array('data.zarr', mode='r+', shape=(10000, 10000),
chunks=(1000, 1000), synchronizer=synchronizer)
# Safe for concurrent writes from multiple threads
# (when writes don't span chunk boundaries)
```
### Process-Safe Operations
```python
from zarr import ProcessSynchronizer
import zarr
# For multi-process writes
synchronizer = ProcessSynchronizer('sync_data.sync')
z = zarr.open_array('data.zarr', mode='r+', shape=(10000, 10000),
chunks=(1000, 1000), synchronizer=synchronizer)
# Safe for concurrent writes from multiple processes
```
**Note**:
- Concurrent reads require no synchronization
- Synchronization only needed for writes that may span chunk boundaries
- Each process/thread writing to separate chunks needs no synchronization
For Dask-heavy workloads, tune Zarr async concurrency — see [Optimizing performance](https://zarr.readthedocs.io/en/stable/user-guide/performance/).
## Consolidated Metadata
@@ -581,7 +572,7 @@ root = zarr.open_consolidated('data.zarr')
4. **Storage Backend**: Match to environment
```python
# Local: LocalStore (default)
# Cloud: S3Map/GCSMap with consolidated metadata
# Cloud: fsspec URIs or FsspecStore + consolidated metadata
# Temporary: MemoryStore
```
@@ -652,26 +643,20 @@ result = (dask_z @ dask_z.T).compute() # Parallel matrix multiply
### Pattern: Cloud-Native Workflow
```python
import s3fs
import zarr
# Write to S3
s3 = s3fs.S3FileSystem()
store = s3fs.S3Map(root='s3://my-bucket/data.zarr', s3=s3)
# Create array with appropriate chunking for cloud
z = zarr.open_array(store=store, mode='w',
shape=(10000, 10000),
chunks=(500, 500), # ~1MB chunks
dtype='f4')
path = "s3://my-bucket/data.zarr"
z = zarr.create_array(
store=path,
shape=(10000, 10000),
chunks=(500, 500),
dtype="f4",
storage_options={"anon": False},
)
z[:] = data
# Consolidate metadata for faster reads
zarr.consolidate_metadata(store)
# Read from S3 (anywhere, anytime)
store_read = s3fs.S3Map(root='s3://my-bucket/data.zarr', s3=s3)
z_read = zarr.open_consolidated(store_read)
zarr.consolidate_metadata(path)
z_read = zarr.open_consolidated(path, storage_options={"anon": False})
subset = z_read[0:100, 0:100]
```
@@ -751,27 +736,25 @@ shards = (10000, 10000) # Groups many chunks
### Issue: Concurrent Write Conflicts
**Solution**: Use synchronizers or ensure non-overlapping writes
```python
from zarr import ProcessSynchronizer
sync = ProcessSynchronizer('sync.sync')
z = zarr.open_array('data.zarr', mode='r+', synchronizer=sync)
# Or design workflow so each process writes to separate chunks
```
**Solution**: Design workflows so each process/thread writes to separate chunks. Zarr-Python 3 does not yet support `ThreadSynchronizer` / `ProcessSynchronizer`; see `references/v3_migration.md`.
## Additional Resources
For detailed API documentation, advanced usage, and the latest updates:
### Bundled references
- **Official Documentation**: https://zarr.readthedocs.io/
- **Zarr Specifications**: https://zarr-specs.readthedocs.io/
- **GitHub Repository**: https://github.com/zarr-developers/zarr-python
- **Community Chat**: https://gitter.im/zarr-developers/community
| File | Contents |
|------|----------|
| `references/api_reference.md` | Function signatures, stores, codecs, indexing |
| `references/v3_migration.md` | Zarr-Python 2→3 breaking changes and WIP features |
**Related Libraries**:
- **Xarray**: https://docs.xarray.dev/ (labeled arrays)
- **Dask**: https://docs.dask.org/ (parallel computing)
- **NumCodecs**: https://numcodecs.readthedocs.io/ (compression codecs)
### Official upstream
- **Documentation**: https://zarr.readthedocs.io/en/stable/
- **3.0 migration guide**: https://zarr.readthedocs.io/en/stable/user-guide/v3_migration/
- **Storage backends**: https://zarr.readthedocs.io/en/stable/user-guide/storage/
- **Zarr specifications**: https://zarr-specs.readthedocs.io/
- **GitHub**: https://github.com/zarr-developers/zarr-python
- **Developer chat**: https://ossci.zulipchat.com/#narrow/channel/423692-Zarr-Python
**Related libraries:** [Xarray](https://docs.xarray.dev/), [Dask](https://docs.dask.org/), [NumCodecs](https://numcodecs.readthedocs.io/)