/scientific-agent-skills:daskfrom scientific-agent-skills
Provides guidance on using Dask for parallel computing in Python, scaling pandas/NumPy/scikit-learn to multi-core systems or distributed clusters with lazy evaluation and out-of-core processing.
Ships in scientific-agent-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Dask provides high-level collections (Arrays, DataFrames, Bags) that mimic the APIs of NumPy and pandas but operate in parallel on data sets that are larger than memory.
Official docs: https://docs.dask.org/
Dask Examples: https://examples.dask.org/
Search patterns: dask.dataframe, dask.array, dask.delayed, client.compute, dask.distributed
Dask doesn't compute results immediately. Instead, it builds a Task Graph. Actual computation only happens when you explicitly call .compute() or .persist().
| Collection | Analogy | Use Case |
|---|---|---|
dask.array | NumPy | Large-scale multidimensional math. |
dask.dataframe | pandas | Large CSV/Parquet/SQL tables. |
dask.bag | Lists/Toolz | Unstructured data (JSON, Logs). |
dask.delayed | Functions | Custom parallel logic. |
pip install "dask[complete]"
import dask.array as da
import dask.dataframe as dd
from dask import delayed, compute
from dask.distributed import Client
from dask.distributed import Client
# Setup local cluster and dashboard
client = Client()
print(client.dashboard_link) # View real-time computation graph
.persist() on reused data - If you use the same intermediate result multiple times, persist it in memory..compute() too early; try to keep calculations lazy as long as possible.map_partitions - For custom logic on DataFrames, use this to apply pandas functions directly to each chunk..compute() triggers the entire graph execution and pulls data into RAM.client.scatter for large objects needed by all workers instead of passing them as arguments.for row in dask_df is incredibly slow; use vectorized operations.import dask.dataframe as dd
# ❌ BAD: Computing a large result into a local variable
# This will crash your local machine by filling RAM
result = dd_df.compute()
# ✅ GOOD: Compute only what you need (aggregations)
mean_val = dd_df['column'].mean().compute()
# ❌ BAD: Too many small tasks (Task Overhead)
# result = [delayed(inc)(i) for i in range(1000000)] # 1 million tasks is too much
# ✅ GOOD: Batch tasks together or use Dask Collections
import dask.array as da
x = da.arange(1000000, chunks=10000) # Only 100 tasks
# ❌ BAD: Hardcoding workers' file paths
# dd.read_csv('/Users/me/data.csv') # Workers on other machines can't see this path!
# ✅ GOOD: Use shared storage (S3, HDFS, NFS)
# dd.read_csv('s3://my-bucket/data.csv')
import dask.array as da
# Create a large random array (100GB)
x = da.random.random((100000, 100000), chunks=(10000, 10000))
# Perform operations (Lazy)
y = x + x.T
z = y[::2, :5000].mean(axis=0)
# Compute result
result = z.compute()
import dask.dataframe as dd
# Load massive dataset
df = dd.read_csv('data/*.csv')
# Filtering and Grouping
result = (df[df['value'] > 0]
.groupby('category')
.amount.sum())
# Execute
final_amounts = result.compute()
# Convert from pandas to dask
import pandas as pd
pdf = pd.DataFrame(...)
ddf = dd.from_pandas(pdf, npartitions=10)
from dask import delayed
@delayed
def load(filename):
...
return data
@delayed
def process(data):
...
return result
@delayed
def summarize(results):
return sum(results)
# Build graph
filenames = ['file1.csv', 'file2.csv', 'file3.csv']
outputs = [process(load(f)) for f in filenames]
total = summarize(outputs)
# Visualize graph (requires graphviz)
# total.visualize()
# Execute in parallel
final_sum = total.compute()
from dask_ml.preprocessing import StandardScaler
from dask_ml.linear_model import LogisticRegression
from dask_ml.model_selection import train_test_split
# Scaling to large data
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X_dask)
# Training on large datasets (Parallel SGD)
model = LogisticRegression()
model.fit(X_dask, y_dask)
# Scikit-learn wrapper (for small data, parallelizing search)
from sklearn.ensemble import RandomForestClassifier
from dask_ml.model_selection import GridSearchCV
clf = RandomForestClassifier()
grid = GridSearchCV(clf, param_grid, cv=3)
grid.fit(X, y) # Grid search runs in parallel across cluster
import dask.bag as db
import json
def analyze_logs(pattern):
# Read unstructured text files
b = db.read_text('logs/2023-*.log')
# Parse JSON and filter
records = b.map(json.loads).filter(lambda x: x['level'] == 'ERROR')
# Extract specific field and count frequencies
counts = records.pluck('message').frequencies()
return counts.compute()
def process_satellite_images(da_stack):
"""Calculate NDVI anomaly across time on 1TB of data."""
# da_stack is a 3D dask array (time, x, y)
# Simple vectorized math (Parallel)
climatology = da_stack.mean(axis=0)
anomaly = da_stack - climatology
# Save results directly to disk without loading into RAM
anomaly.to_zarr('anomalies.zarr')
def clean_dataset(ddf):
return (ddf
.dropna(subset=['id'])
.fillna({'status': 'unknown'})
.assign(timestamp=dd.to_datetime(ddf['time_str']))
.groupby('user_id')
.last()
.persist()) # Keep in memory for fast future use
Problem: Workers crash because they ran out of RAM.
Solution: Decrease chunk size or use a machine with more memory. Check for data skew.
Problem: Dask can't send your custom object to workers.
Solution: Use dask.distributed.Client.register_plugin or ensure classes are defined in a separate file accessible by workers.
Problem: You created 1,000,000+ tiny tasks.
Solution: Re-chunk your data into larger pieces. Use dask_array.rechunk() or dask_df.repartition().
.compute() when you need the final result.map_partitions for custom pandas operations on Dask DataFrames.Dask transforms Python from a single-threaded scripting language into a world-class system for distributed computing. It is the bridge between a researcher's laptop and a high-performance compute cluster.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub tondevrel/scientific-agent-skills --plugin scientific-agent-skills70 skills in this plugin
/aseAtomic Simulation Environment - a set of tools for setting up, manipulating, running, visualizing, and analyzing atomistic simulations. Acts as a universal interface between Python and numerous quantum chemical and molecular dynamics codes. Use for building atomic structures, geometry optimization, molecular dynamics simulations, transition state searches (NEB), file format conversion (CIF, XYZ, POSCAR, PDB), electronic property calculations (DOS, band structures), and automating simulation workflows with DFT/MD codes like VASP, GPAW, Quantum ESPRESSO, LAMMPS./astropyThe core library for Astronomy and Astrophysics in Python. Provides data structures for coordinates, time, units, FITS files, and cosmological models. Essential for observational data reduction and theoretical astrophysics. Use when working with astronomical coordinates (RA/Dec), physical units, FITS files, time scales, WCS, cosmology, or astronomical tables./biopythonComprehensive guide for Biopython - the premier Python library for computational biology and bioinformatics. Use for DNA/RNA/protein sequence analysis, file I/O (FASTA, FASTQ, GenBank, PDB), sequence alignment, BLAST searches, phylogenetic analysis, structure analysis, and NCBI database access./chempyA Python package useful for chemistry (mainly physical/analytical/inorganic chemistry). Features include balancing chemical reactions, chemical kinetics (ODE integration), chemical equilibria, ionic strength calculations, and unit handling. Use when working with chemical equations, reaction balancing, kinetic modeling, equilibrium calculations, speciation, pH calculations, ionic strength, activity coefficients, or chemical formula parsing./cobrapyConstraints-Based Reconstruction and Analysis for Python. Used for modeling large-scale metabolic networks in microorganisms./dask-optimizationAdvanced sub-skill for Dask focused on distributed system performance, memory management, and task graph optimization. Covers cluster tuning, efficient serialization, data skew mitigation, and dashboard-driven debugging.Other plugins' skills for the same job