Skip to content

Add kriging diagnostic outputs to the task SDK client - #348

Merged
amirabbas-jalali-bentley merged 3 commits into
SeequentEvo:mainfrom
amirabbas-jalali-bentley:add-kriging-diagnostic-outputs
Sep 24, 2026
Merged

amirabbas-jalali-bentley merged 3 commits into
SeequentEvo:mainfrom
amirabbas-jalali-bentley:add-kriging-diagnostic-outputs

Conversation

@amirabbas-jalali-bentley

@amirabbas-jalali-bentley amirabbas-jalali-bentley commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds support for the kriging task's diagnostic outputs to the evo-compute SDK client.

The kriging task can write per-location diagnostics onto the target object alongside the estimate — kriging variance, slope of regression, sample counts, search distances, and so on. These live under target.diagnostics in the task schema, and were previously not reachable through the SDK.

Parameters

KrigingParameters gains a diagnostics field taking a KrigingDiagnostics. It is folded into target.diagnostics by the existing model serializer, the same way source_filter and target_filter are already folded into source.filter / target.filter — so callers keep passing a typed attribute (or a Target) for target and do not have to hand-build the nested object.

Every diagnostic accepts:

  • True — create an attribute using the recommended name (RECOMMENDED_DIAGNOSTIC_NAMES, e.g. KV, SoR, NS)
  • a string — create an attribute with that name
  • a typed attribute from the target object — update it if it exists, otherwise create it
  • an explicit CreateAttribute / UpdateAttribute
params = KrigingParameters(
    source=pointset.attributes["CU_pct"],
    target=block_model.attributes["CU_estimate"],
    variogram=variogram,
    search=SearchNeighborhood(ellipsoid=search_ellipsoid, max_samples=16),
    diagnostics=KrigingDiagnostics(
        kriging_variance=True,        # -> "KV"
        slope_of_regression=True,     # -> "SoR"
        num_samples="sample_count",   # -> "sample_count"
    ),
)

The recommended names match the conventions used elsewhere in the product so results are familiar once imported. They are the schema's suggested names rather than server-side defaults, so the SDK always sends an explicit attribute name.

Validation

Three mistakes are caught before the payload is built, so they surface as a ValidationError on KrigingParameters rather than a failed or partially applied job:

  • Every output needs its own attribute. Outputs are compared by attribute name — including the name of a typed attribute being updated, which its reference does not carry — and updates are also compared by reference. This covers a diagnostic colliding with target.attribute. A hand-written UpdateAttribute expression carries no name, so it is only compared with other references.
  • Diagnostics belong to the target object. A typed attribute is reduced to a name or reference, which is then resolved against target.object — so an attribute taken from a different object would silently resolve to nothing, or to the wrong attribute. The originating object is remembered during validation and compared with the target, ignoring any ?version= suffix. Attributes that carry no parent object cannot be checked and are left alone.
  • An existing attribute must be able to hold the diagnostic's values. As in the task schema, updating an existing attribute needs a boolean attribute for valid, an integer one for the num_* counts, and a floating-point one for the rest. A newly created attribute takes the diagnostic's type, so it is not checked.

Results

The task returns every diagnostic key, with null for the ones that were not requested. New KrigingDiagnosticsResult and KrigingTargetResult models parse that, and KrigingResult.diagnostics exposes only the diagnostics that were actually written, keyed by diagnostic name:

for diagnostic, attribute in result.diagnostics.items():
    print(f"{diagnostic}: {attribute.name}")

They are also listed in the result summary. Because diagnostics are written onto the target object, result.to_dataframe() returns them alongside the estimate.

Other changes

  • attribute_spec() factored out of _validate_target_attribute in tasks/common/source_target.py and shared, so a diagnostic accepts the same typed attributes as a target does.
  • KrigingDiagnostics exported from evo.compute.tasks and evo.compute.tasks.geostatistics.
  • tests/test_tasks.py fixtures build a KrigingTargetResult instead of a bare TaskTarget, following the retyped KrigingResultModel.target.

Backwards compatibility

No breaking change to the SDK's public surface — diagnostics is optional and defaults to None, so existing kriging calls produce an identical payload.

Testing

  • uv run --package evo-compute pytest packages/evo-compute/tests — 447 passed (34 new tests, plus 104 subtests, covering the accepted shorthands, the serialized payload, the parsed result, and the three validation rules).
  • ruff check and ruff format --check clean across the repository.
  • The generated payload and a realistic result payload were validated against the kriging task's JSON schema with jsonschema (Draft 2020-12) — no errors on either side.
  • Notebooks were verified to parse; they need live Evo credentials to execute, so they were not run end to end.

Documentation

  • packages/evo-compute/docs/examples/kriging.ipynb — new "Request Diagnostics" section.
  • code-samples/geoscience-objects/running-kriging-compute/ — the walkthrough now requests diagnostics, prints the attributes that were written, and includes them in the results DataFrame; the markdown documents the shorthands and lists all 16 diagnostics with their recommended names.

The generated API reference under mkdocs/ is left to the documentation workflow.

Checklist

  • I have read the contributing guide and the code of conduct

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Output collisions and cross-object attributes are not validated, and generated documentation links target missing pages.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds typed kriging diagnostic outputs to the compute SDK, including request serialization, result parsing, tests, and examples.

Changes:

  • Adds diagnostic selectors, recommended names, and target serialization.
  • Exposes returned diagnostic attributes through kriging results.
  • Updates exports, tests, notebooks, generated documentation, and dependencies.
File summaries
File Description
uv.lock Updates evo-blockmodels lock version.
packages/evo-compute/tests/test_tasks.py Uses the specialized kriging target result.
packages/evo-compute/tests/geostatistics/test_kriging_tasks.py Tests diagnostic inputs, serialization, and results.
packages/evo-compute/src/evo/compute/tasks/geostatistics/kriging.py Implements diagnostic request and result models.
packages/evo-compute/src/evo/compute/tasks/geostatistics/__init__.py Exports KrigingDiagnostics.
packages/evo-compute/src/evo/compute/tasks/common/source_target.py Extracts typed attribute conversion.
packages/evo-compute/src/evo/compute/tasks/common/__init__.py Exports attribute_spec.
packages/evo-compute/src/evo/compute/tasks/__init__.py Adds the top-level diagnostics export.
packages/evo-compute/docs/examples/kriging.ipynb Demonstrates requesting diagnostics.
mkdocs/site/packages/evo-files/index.html Updates generated previous-page navigation.
mkdocs/site/packages/evo-compute/typed-objects/source-target/UpdateAttribute.html Updates generated next-page navigation.
mkdocs/site/packages/evo-compute/typed-objects/kriging/SimpleKriging.html Updates generated navigation.
mkdocs/site/packages/evo-compute/typed-objects/kriging/OrdinaryKriging.html Updates generated navigation.
mkdocs/site/packages/evo-compute/typed-objects/kriging/KrigingRunner.html Updates generated navigation.
mkdocs/site/packages/evo-compute/typed-objects/kriging/KrigingResultModel.html Documents the specialized target result.
mkdocs/site/packages/evo-compute/typed-objects/kriging/KrigingResult.html Documents result diagnostics.
mkdocs/site/packages/evo-compute/typed-objects/kriging/KrigingParameters.html Documents diagnostic parameters.
mkdocs/site/packages/evo-compute/typed-objects/kriging/KrigingMethod.html Updates generated navigation.
code-samples/geoscience-objects/running-kriging-compute/running-kriging-compute.ipynb Extends the walkthrough with diagnostics.
code-samples/geoscience-objects/running-kriging-compute/README.md Lists diagnostics in the walkthrough scope.
Review details

Suppressed comments (1)

mkdocs/site/packages/evo-compute/typed-objects/kriging/OrdinaryKriging.html:42

  • RECOMMENDED_DIAGNOSTIC_NAMES.html is absent from the checked-in kriging API directory, making this Next link a 404. Regenerate and commit the missing API page.
                                <a rel="next" href="RECOMMENDED_DIAGNOSTIC_NAMES.html" class="nav-link">
  • Files reviewed: 19/20 changed files
  • Comments generated: 8
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/evo-compute/src/evo/compute/tasks/geostatistics/kriging.py
Comment thread packages/evo-compute/src/evo/compute/tasks/geostatistics/kriging.py
Comment thread mkdocs/site/packages/evo-files/index.html
Comment thread packages/evo-compute/src/evo/compute/tasks/geostatistics/kriging.py Outdated
Comment thread packages/evo-compute/src/evo/compute/tasks/geostatistics/kriging.py

@aminabedi-bentley aminabedi-bentley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; with some minor comments.

@amirabbas-jalali-bentley
amirabbas-jalali-bentley force-pushed the add-kriging-diagnostic-outputs branch 2 times, most recently from 85e8562 to 77950e2 Compare September 23, 2026 21:55
- Expose the `target.diagnostics` structure of the kriging task, so the 16
optional per-location diagnostics can be requested through the SDK.

- `KrigingParameters.diagnostics` takes a `KrigingDiagnostics` and is folded
into `target.diagnostics` on the wire, matching how the source and target
filters are already handled. Each diagnostic accepts `True` for the
recommended attribute name, a string for a custom name, a typed attribute
to update an existing one, or an explicit create/update specification.

- The result now parses `target.diagnostics`, so `KrigingResult.diagnostics`
reports the definitive name and reference of every attribute that was
written.

@GriffinBaxterSeequent GriffinBaxterSeequent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this from a evo-python-sdk-maintainers perspective, cheers!

@PaulCaygill-Seequent PaulCaygill-Seequent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small things, around the same area of code around Diagnostic validation, otherwise nothing jumping out as an issue

Comment thread packages/evo-compute/src/evo/compute/tasks/geostatistics/kriging.py Outdated
Comment thread packages/evo-compute/tests/geostatistics/test_kriging_tasks.py
- Track attribute names and update references in two separate maps, so the
  rule reads directly: no two outputs may share an attribute name or an
  update reference.
- Cover a typed attribute that a hand-written update reference also targets.
@amirabbas-jalali-bentley
amirabbas-jalali-bentley merged commit d4c0b00 into SeequentEvo:main Sep 24, 2026
88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants