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.
Critical command rule: always use
for Python commands:
- Use and
- Do not use bare or in 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 with dev dependencies ()
- 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
| Type | Inheritance | Dependency extra | Example |
|---|
| Simple derived diagnostic | only | Usually none | , wind speed |
| Packaged AutoModel diagnostic | torch.nn.Module, AutoModelMixin
| Required, even if empty | |
| Generative diagnostic | torch.nn.Module, AutoModelMixin
| Required, even if empty | |
Workspace
| Context | Location |
|---|
| Harbor eval | Write to /workspace/output/earth2studio/models/dx/...
|
| Harbor + | Full checkout at |
| Local clone | Directory with |
Never read
; those files are grader references only.
Reference Files
Load these files on demand during the matching workflow:
| File | Content | Load at |
|---|
references/skeleton-template.py
| Full diagnostic skeletons for simple, AutoModel, and generative wrappers | Steps 3-6 |
references/method-templates.py
| Focused coordinate, loading, forward, and device method snippets | Steps 4-6 |
references/testing-guide.py
| Mock, package, exception, sample, and seed test patterns | Step 7 |
references/validation-guide.md
| Reference comparison, plots, PR hygiene, and review follow-up | Steps 10-11 |
references/pr-body-template.md
| PR body template | Step 11 |
references/pr-comment-template.md
| Validation comment template | Step 11 |
Instructions
Step 0 - Get Reference Material
If
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:
| If the model... | Then use... |
|---|
| Computes a derived quantity with no checkpoint | Simple diagnostic |
| Loads weights from or an external checkpoint | AutoModel diagnostic |
| Produces multiple samples, diffusion outputs, VAE samples, or stochastic super-resolution | Generative diagnostic |
Dependency policy:
- Simple derived diagnostics usually do not need a extra.
- 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 the aggregate.
- 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
:
toml
model-name = ["package1>=version", "package2"]
# or, when the packaged diagnostic needs no extra runtime packages:
model-name = []
Step 2 - Add Dependencies
- Add the extra alphabetically.
- Update the aggregate.
- 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:
python
from collections import OrderedDict
import numpy as np
import torch
from earth2studio.models.batch import batch_coords, batch_func
from earth2studio.utils import handshake_coords, handshake_dim
from earth2studio.utils.type import CoordSystem
Packaged and generative diagnostics commonly also include:
python
from earth2studio.models.auto import AutoModelMixin, Package
from earth2studio.models.dx.base import DiagnosticModel
from earth2studio.utils.imports import OptionalDependencyFailure, check_optional_dependencies
from loguru import logger
Canonical method order:
- decorated with
- if useful
- for AutoModel/generative diagnostics
- for AutoModel/generative diagnostics
- only when non-PyTorch state must move devices
- Private/support methods
- decorated with and
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:
- : and first in the
- : input variable names using Earth2Studio vocabulary names
- : public latitude convention north-to-south, usually to
- : public longitude convention to , endpoint normally false
No diagnostic wrapper should expose
. If a diagnostic needs validity
time metadata, document it as per-sample metadata in
; do not make
it a tensor dimension unless an existing dx pattern requires it.
must validate inputs with
and
.
Then update output variables and, when needed, output lat/lon resolution.
Generative diagnostics must add a
dimension after
.
Step 5 - Implement Forward Pass
Use a single-step
; never create an iterator. Validate coordinates
before model execution, then return
(output_tensor, output_coords)
.
python
@torch.inference_mode()
@batch_func()
def __call__(self, x: torch.Tensor, coords: CoordSystem) -> tuple[torch.Tensor, CoordSystem]:
output_coords = self.output_coords(coords)
x = (x - self.center) / self.scale
out = self.core_model(x)
return out, output_coords
For generative diagnostics, loop over the batch dimension and generate
per input item. Use explicit seeds for reproducibility when
the reference implementation supports seeded sampling.
Step 6 - Implement Model Loading
For packaged diagnostics:
- should lock HuggingFace URLs to a commit () or NGC/S3 versions to an immutable release.
- should call , load checkpoints on CPU first, set modules to , and disable gradients where appropriate.
- Use only when loading a pickled full PyTorch object is required.
- Decorate optional model classes and with
@check_optional_dependencies()
.
- Use for useful loading messages; do not use inside .
Step 7 - Write Tests
File:
test/models/dx/test_<name>.py
Required tests:
| Function | Purpose |
|---|
| Forward pass with mock or simple model |
| Invalid coordinate order, values, or variables raise errors |
| Real weights with for AutoModel/generative diagnostics |
Generative diagnostics also require sample-count and deterministic-seed tests.
Use
references/testing-guide.py
. Create a
dummy that matches
the real core model's interface and produces deterministic output.
Run focused tests:
bash
uv run pytest test/models/dx/test_<name>.py -m "not package" -v
uv run pytest test/models/dx/test_<name>.py::test_<model>_package --package -v
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.rst
alphabetically so API docs include the generated page.
- Add to
docs/userguide/about/install.md
if a model extra exists. Include model notes plus both pip install earth2studio[model-name]
and uv add earth2studio --extra model-name
instructions.
- Update under .
Format and lint:
bash
make format && make lint && make license
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.md
references/pr-comment-template.md
Before creating the PR, verify dependency extras,
, 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
text
User: Create a diagnostic that computes wind speed from u10m and v10m.
Agent: Reads SKILL.md, classifies as simple, creates windspeed.py with only
torch.nn.Module, writes call and exception tests, runs focused pytest.
AutoModel Diagnostic
text
User: Add a precipitation estimator from this reference script.
Agent: Reads SKILL.md and references, proposes dependency extra, creates a
torch.nn.Module + AutoModelMixin wrapper, writes mock/package tests,
updates docs/changelog/dependencies, and runs validation commands.
Generative Diagnostic
text
User: Wrap this diffusion super-resolution model.
Agent: Classifies as generative, adds sample output coordinates, supports seed
handling, writes sample and deterministic-seed tests, and prepares seeded
validation comparisons.
Troubleshooting
| Error | Solution |
|---|
OptionalDependencyFailure
| Install with uv sync --extra <model-extra>
or fix the extra name |
| Coordinate handshake fails | Check order and indices |
| Wrong output shape | Verify lengths match returned tensor shape |
ModuleNotFoundError: pytest
| Use , not bare |
| Package test fails on random input | Use a stable physically plausible input while still loading real weights |
Reminders
Do:
- Use and for all Python commands.
- Use on .
- Use and on .
- Keep as the first coordinate with in .
- Validate coordinates with and .
- Add in generative .
- Include the repo-standard SPDX/license header in every Python file.
- Use , never , inside .
Do not:
- Inherit from .
- Include coordinates.
- Create .
- 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 .
Self-Improvement
If this skill produces incorrect outputs, update it before continuing:
- Identify the issue in the generated code or workflow.
- Edit or the relevant file in 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.