本文へ移動
cccskills
無料GitHub で公開

modal-run

Use when the user asks to run heavy or GPU work on Modal (the cloud compute platform) — writing a Modal function in the workspace, running it with the user's own `modal` CLI + token, and bringing results back. Data-to-compute for jobs too big for the laptop, without a Slurm cluster.

インストール方法を見る

含まれるファイル(2)

  • SKILL.md4.4 KB
  • record_run.py9.0 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Run compute on Modal

Modal runs code in the cloud on demand (CPU/GPU), billed to the user's own Modal account. Like the HPC/Slurm path, the app never handles credentials — you use the user's installed modal CLI and their token. Prefer local execution or Slurm first; reach for Modal when the job needs cloud GPUs or elastic scale and no cluster is available.

1 · Check Modal is ready

Modal must be installed and authenticated (the Settings Cloud compute (Modal) card shows this). Verify before writing code:

modal --version          # installed?
test -f ~/.modal.toml && echo "authenticated" || echo "run: modal token new"

If it is not installed, tell the user to pip install modal; if not authenticated, ask them to run modal token new in their terminal (it opens a browser). Do not attempt to create or store tokens yourself.

2 · Write the Modal function into the workspace

Put the script in the workspace so provenance records it. Pin dependencies in the image so the run is reproducible, and fix any random seed.

# compute.py — run with:  modal run compute.py
import modal

app = modal.App("open-science-job")
image = modal.Image.debian_slim().pip_install("numpy==1.26.4", "scipy==1.13.1")

@app.function(image=image, gpu=None, timeout=1800)  # set gpu="A10G" etc. if needed
def run(n: int = 1_000_000):
    import numpy as np
    rng = np.random.default_rng(0)          # fixed seed → reproducible
    x = rng.standard_normal(n)
    return {"n": n, "mean": float(x.mean()), "std": float(x.std())}

@app.local_entrypoint()
def main():
    result = run.remote()
    print(result)                            # printed locally; capture it below

3 · Run it and capture the result

modal run executes remotely and streams logs + the local entrypoint's stdout back. Write the result into a fresh, immutable result directory so it becomes a traceable artifact and does not overwrite a previous run:

RESULT=results/<job-name>/<YYYYmmdd-HHMMSS>
mkdir -p "$RESULT"
modal run compute.py | tee "$RESULT"/modal_result.txt

For large outputs, have the function write to a Modal Volume and download with modal volume get, rather than returning big objects. Download every run into its own RESULT directory; never reuse a recorded output path.

4 · Record the run (reproducibility) — REQUIRED, every time

Modal runs on remote cloud hardware the app can't see, so this call is the ONLY thing that makes the run exist in Runs. Do it after every completed run — including quick re-runs. Skipping it loses the run entirely (it shows in neither the global Runs view nor the session). Record it after it completes (from the workspace root):

Record it completely: --code once per script that ran, and --output once per file you captured or downloaded (the streamed result and any modal volume get files) — not just the summary. Output paths must be under the fresh RESULT directory; the helper refuses to record paths used by earlier runs.

python "$XDG_CONFIG_HOME/opencode/skills/modal-run/record_run.py" \
  --surface modal --command "modal run compute.py" \
  --status <ok|failed> --host "modal:<app-name>" \
  --hardware "<the gpu= from @app.function, e.g. A10G — or 'CPU'>" \
  --code compute.py --output "$RESULT"/modal_result.txt \
  --output "$RESULT"/<each downloaded file> \
  --session-id "$(cat .openscience/session.txt 2>/dev/null)"

--session-id attaches the run to this session (empty-safe if the marker's absent).

The environment is reproduced by the modal.Image definition in compute.py (pinned pip_install + base image — already versioned in the workspace), so record the GPU/hardware string, not a package list, and no --env-file is needed. Use --status failed if the run errored.

Rules

  • User's account only. Never handle, print, or store Modal tokens.
  • Reproducible. Pin image packages and fix seeds; record the script + result in the workspace (provenance captures them).
  • Cost-aware. Modal bills the user — keep timeout bounded, don't request a GPU unless the work needs one, and say what you're about to run before a large job.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Use when a task needs an app on the user's own screen — a native desktop application (instrument control software, Origin, GraphPad, ImageJ, a reference manager, a spreadsheet), or a desktop browser window that needs window-level control. Read before the first `computer` call. Covers the observe-act-observe loop, why element indexes go stale, which action to prefer for which control, what "unverified" means and why it must never be reported as success, and the recovery for each error code. Not for page-level web automation (use the browser connector) and not for anything that can be done from the shell.

日本語の概要は準備中です。原文の説明を表示しています。

ai4s-research/open-science1,7882026年10月12日 更新

Use ONLY when the user asks to check, validate, review or audit analysis code for scientific correctness, or when you are the reviewer agent running its checks. Never run it unprompted as part of ordinary analysis work. Covers physics, earth/geo, biology, chemistry, social science and bioprocess/fermentation. Runs a deterministic domain-correctness gate that catches code which runs but is scientifically wrong (unit/dimension mismatch, Euclidean distance on lat/lon without a CRS, 0-based/1-based coordinate and strand errors, impossible SMILES valence, uncorrected multiple comparisons, averaging a categorical code, unconstrained kinetic-parameter fits, kLa computed from raw DO instead of the driving force, arithmetic mean of raw CFU counts, ANOVA/Tukey with no assumption check, a curvature DOE design fit with a first-order model, an ML model fit across process scales with no correction). Surfaces structured findings; never claims the code is correct.

日本語の概要は準備中です。原文の説明を表示しています。

ai4s-research/open-science1,7882026年10月12日 更新

Use BEFORE reading any data file that could be large (CSV/TSV, Parquet, HDF5, FITS, NetCDF, NDJSON, genomics FASTQ/FASTA/VCF/BAM, GRIB, ROOT, or big text/simulation logs like VASP OUTCAR). Returns a compact memory pointer — header/schema/shape/sample/key numbers — by introspection and sampling in bounded memory, so you never load a file bigger than the context window into the model. Reference data via the pointer; read specific ranges deterministically.

日本語の概要は準備中です。原文の説明を表示しています。

ai4s-research/open-science1,7882026年10月12日 更新

my-skill

無料

A test skill that says hello. Use when you want to test skill loading or verify that the skill system is working.

日本語の概要は準備中です。原文の説明を表示しています。

ai4s-research/open-science1,7882026年10月12日 更新

Use whenever you generate or review a chart, plot, table, or paper figure in this workspace, including work delegated by paper-writing, literature-survey, and experiment skills. Applies the Open Science publication style, enforces readable final-size layout for figures and tables, and rejects generic diagram-tool output as a publication figure. Interactive Plotly/HTML may be used for exploration, but paper delivery requires a static publication-ready export.

日本語の概要は準備中です。原文の説明を表示しています。

ai4s-research/open-science1,7882026年10月12日 更新

Use when the user asks to run, submit, monitor, or cancel a job on a remote machine over SSH — their own GPU/CPU server, a workstation, or a Slurm cluster ("the cluster", a login node, "my 3090 box", "the compute server"). Picks a saved machine, runs the work directly over SSH (or via Slurm when present), tracks it, and fetches results back into the workspace.

日本語の概要は準備中です。原文の説明を表示しています。

ai4s-research/open-science1,7882026年10月12日 更新

ai4s-research のスキルをすべて見る

このスキルの問題を報告する