Skip to content

Validate compute task parameters against their schema - #407

Draft
amirabbas-jalali-bentley wants to merge 2 commits into
SeequentEvo:add-generic-compute-enginefrom
amirabbas-jalali-bentley:validate-compute-task-parameters
Draft

amirabbas-jalali-bentley wants to merge 2 commits into
SeequentEvo:add-generic-compute-enginefrom
amirabbas-jalali-bentley:validate-compute-task-parameters

Conversation

@amirabbas-jalali-bentley

@amirabbas-jalali-bentley amirabbas-jalali-bentley commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Part 2 of 6 in the generic compute engine series (stacked on #395, targeting add-generic-compute-engine).

ComputeClient (#395) binds top-level keyword arguments from a task's discovery schema before submitting a job. This adds schema-driven parameter validation so invalid payloads fail locally with clear, path-prefixed messages instead of reaching the service.

Changes

  • Adds ParameterValidationError(ValueError) (exported from evo.compute), carrying .task (topic.task) and .errors (one message per validation failure). Signature-binding errors from ComputeClient now raise ParameterValidationError too.
  • Adds evo.compute.validation.validate_parameters:
    • Shallow validation (validate=True, on by default): checks that every required field is present on the wire payload and is not None unless the property's schema permits null (including nullable unions and $ref targets).
    • Deep validation (deep_validation=False, opt-in on ComputeClient or per arun call): validates the payload against JSON Schema Draft 2020-12 ($ref / $defs, scalar/container types, bounds, enums, and discriminated unions). validate=False acts as the master switch over deep_validation.
    • Discriminated union reporting: when a oneOf/anyOf carries discriminator.propertyName, reports the selected branch's specific field errors (or the allowed discriminator values when no branch matches) instead of a generic union error.
    • Reference-leaf relaxation: properties carrying reference_to keep scalar carrier types (such as URL strings) while relaxing object/array resolved shapes ahead of the reference-resolution layer.
  • Adds KNOWN_SCHEMA_ANNOTATIONS and unknown_annotation_keys(schema) to guard the closed schema-annotation vocabulary the engine interprets.
from evo.compute import ComputeClient, ParameterValidationError

client = ComputeClient(manager, deep_validation=True)

try:
    await client.geostatistics.declustering.run(
        source=..., grid=..., target=..., neighborhood=..., power="invalid", preview=True
    )
except ParameterValidationError as exc:
    print(exc.task, exc.errors)

No breaking changes to existing task runners. ComputeClient parameter binding errors now raise ParameterValidationError (a ValueError subclass).

Testing

  • Unit tests in test_validation.py cover shallow required/nullability checks, deep Draft 2020-12 validation, $ref resolution, reference-leaf relaxation, discriminated union diagnostics, and client/per-call toggle combinations.
  • Schema conformance tests in test_schema_conformance.py verify the closed annotation vocabulary against bundled fixtures (plus an opt-in live discovery check).
  • evo-compute tests: 590 passed, 1 skipped (49 new). ruff check, ruff format --check, uv lock --check, and pre-commit hooks pass.

Checklist

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

Add ParameterValidationError and schema-driven validation before
ComputeClient submits a job. Shallow validation checks required-field
presence and nullability by default; opt-in deep validation checks
JSON Schema Draft 2020-12 constraints with path-prefixed messages and
discriminated union diagnostics.

Also adds unknown_annotation_keys() and conformance tests for the closed
schema-annotation vocabulary the engine interprets.
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.

1 participant