Quick Start Checklist
Do these steps in order. Do not skip ahead. Before editing, read this SKILL.md and load the relevant reference files for the model type. After implementation, run the focused pytest command before saying tests pass. If tests cannot run, report the exact command and failure instead of claiming success.
- Read this SKILL.md completely first
- Get the reference script, repo, paper, or model documentation (Step 0)
- Classify the diagnostic as simple, AutoModel, or generative (Step 1)
- Propose dependency extras before editing dependency files (Step 1)
- Create
earth2studio/models/dx/<name>.pywith diagnostic-only APIs - Create
test/models/dx/test_<name>.pywith mock tests - Run:
uv run pytest test/models/dx/test_<name>.py -m "not package" -v - Add/update model extra, install docs, API docs, and changelog when required
- Run:
make format && make lint && make license
Critical command rule: always use uv run for Python commands:
- Use
uv run pytest ...anduv run python ... - Do not use bare
pytestorpythonin repo workflows
If the generated model is wrong, do not keep retrying the same fix. Follow Self-Improvement, patch this skill or its references, then continue with the corrected workflow.
Purpose
Implement a diagnostic model wrapper connecting third-party or derived ML transforms to Earth2Studio. Diagnostic models transform data at a single time point: input fields in, output fields out, no forecast integration.
Prerequisites
- Earth2Studio installed via
uvwith dev dependencies (uv sync --all-extras) - Python 3.10+ environment
- Reference inference script, repo, paper, or model documentation
- Checkpoint source and license information for packaged models
Limitations
- Handles single-step transformations only
- Does not support time-stepping forecast models; use
earth2studio-create-prognostic - Real package tests can require network access to NGC, HuggingFace, S3, or other registries
- Generative validation can require GPU and fixed seeds for meaningful comparison
Diagnostic Model Types
Workspace
Never read evals/targets/; those files are grader references only.
Reference Files
Load these files on demand during the matching workflow:
Instructions
Step 0 - Get Reference Material
If $ARGUMENTS provides a URL or local path, use it. Otherwise ask:
Please provide a reference inference script, repository, paper, or model documentation.
Capture the reference model's input variables, output variables, tensor shapes, normalization, grid, checkpoint source, dependency requirements, and license.
Step 1 - Analyze Type and Propose Dependencies
Classify the requested diagnostic before editing files:
Dependency policy:
- Simple derived diagnostics usually do not need a
pyproject.tomlextra. - AutoModel and generative diagnostics must have a named optional dependency extra, even if the list is empty.
- Add the extra alphabetically under
[project.optional-dependencies]and include it in theallaggregate. - Use the model-extra name in
OptionalDependencyFailure("model-extra")and@check_optional_dependencies().
Present the proposed dependency extra and ask the user to approve before editing
pyproject.toml:
Step 2 - Add Dependencies
After approval, edit pyproject.toml:
- Add the extra alphabetically.
- Update the
allaggregate. - Prefer minimum supported versions from the reference package documentation.
- Do not add broad unpinned Git dependencies unless the reference model requires them and the user approves.
Step 3 - Create Model File
File: earth2studio/models/dx/<lowercase>.py
Use the repo-standard SPDX/license header shown in existing model files.
Simple diagnostic imports commonly include:
Packaged and generative diagnostics commonly also include:
Canonical method order:
__init__input_coordsoutput_coordsdecorated with@batch_coords()__str__if usefulload_default_packagefor AutoModel/generative diagnosticsload_modelfor AutoModel/generative diagnosticstoonly when non-PyTorch state must move devices- Private/support methods
__call__decorated with@torch.inference_mode()and@batch_func()
Avoid shared base classes or broad abstractions unless the wrapper naturally has multiple closely related variants where a small base class reduces duplication.
Step 4 - Implement Coordinates
Diagnostic input coordinates usually use this public Earth2Studio order:
batch:np.empty(0)and first in theOrderedDictvariable: input variable names using Earth2Studio vocabulary nameslat: public latitude convention north-to-south, usually90to-90lon: public longitude convention0to360, endpoint normally false
No diagnostic wrapper should expose lead_time. If a diagnostic needs validity
time metadata, document it as per-sample metadata in coords["time"]; do not make
it a tensor dimension unless an existing dx pattern requires it.
output_coords must validate inputs with handshake_dim and handshake_coords.
Then update output variables and, when needed, output lat/lon resolution.
Generative diagnostics must add a sample dimension after batch.
Step 5 - Implement Forward Pass
Use a single-step __call__; never create an iterator. Validate coordinates
before model execution, then return (output_tensor, output_coords).
For generative diagnostics, loop over the batch dimension and generate
number_of_samples per input item. Use explicit seeds for reproducibility when
the reference implementation supports seeded sampling.
Step 6 - Implement Model Loading
For packaged diagnostics:
load_default_packageshould lock HuggingFace URLs to a commit (hf://org/repo@commit) or NGC/S3 versions to an immutable release.load_modelshould callpackage.resolve(...), load checkpoints on CPU first, set modules toeval(), and disable gradients where appropriate.- Use
weights_only=Falseonly when loading a pickled full PyTorch object is required. - Decorate optional model classes and
load_modelwith@check_optional_dependencies(). - Use
loguru.loggerfor useful loading messages; do not useprint()insideearth2studio/.
Step 7 - Write Tests
File: test/models/dx/test_<name>.py
Required tests:
Generative diagnostics also require sample-count and deterministic-seed tests.
Use references/testing-guide.py. Create a Phoo<ModelName> dummy that matches
the real core model's interface and produces deterministic output.
Run focused tests:
Do not omit package tests for packaged models. If arbitrary random inputs are not physically valid for the real checkpoint, build a stable model-appropriate input while still loading real weights and running a forward pass.
Step 8 - Register Model
For public models, update earth2studio/models/dx/__init__.py alphabetically.
Skip registration only when the user explicitly wants an internal or experimental
file that should not be exported.
Step 9 - Documentation
For public models:
- Add to
docs/modules/models_dx.rstalphabetically so API docs include the generated page. - Add to
docs/userguide/about/install.mdif a model extra exists. Include model notes plus bothpip install earth2studio[model-name]anduv add earth2studio --extra model-nameinstructions. - Update
CHANGELOG.mdunder### Added.
Format and lint:
Step 10 - Validation (if requested)
Follow references/validation-guide.md. Create uncommitted vanilla,
Earth2Studio, comparison, and sanity-check scripts. Do not commit generated
outputs, checkpoints, images, or local validation scripts.
For generative diagnostics, fix seeds and compare matching samples or report statistical/tolerance-based agreement when exact equality is impossible. Ask the user to visually inspect plots before proceeding.
Step 11 - PR (if requested)
Follow references/validation-guide.md and use:
references/pr-body-template.mdreferences/pr-comment-template.md
Before creating the PR, verify dependency extras, all, install docs, API docs,
changelog, tests, and validation artifacts are consistent. Do not include machine
names, hostnames, absolute paths, cache paths, device inventory, or uploaded image
links in PR text. Use plot placeholders for manual image upload.
Examples
Simple Diagnostic
AutoModel Diagnostic
Generative Diagnostic
Troubleshooting
Reminders
Do:
- Use
uv run pythonanduv run pytestfor all Python commands. - Use
@batch_coords()onoutput_coords. - Use
@torch.inference_mode()and@batch_func()on__call__. - Keep
batchas the first coordinate withnp.empty(0)ininput_coords. - Validate coordinates with
handshake_dim()andhandshake_coords(). - Add
samplein generativeoutput_coords. - Include the repo-standard SPDX/license header in every Python file.
- Use
loguru.logger, neverprint(), insideearth2studio/.
Do not:
- Inherit from
PrognosticMixin. - Include
lead_timecoordinates. - Create
create_iterator. - Create general base classes for a single wrapper without a clear multi-variant need.
- Commit API keys, credentials, validation scripts, plots, or generated outputs.
- Read from
evals/targets/.
Self-Improvement
If this skill produces incorrect outputs, update it before continuing:
- Identify the issue in the generated code or workflow.
- Edit
SKILL.mdor the relevant file inreferences/to fix the guidance. - Run focused validation for the changed skill files.
- Commit the skill fix separately when working in a branch that expects commits.
- Continue the model implementation with the corrected workflow.
