Skip to content

fix: track tasks with fields py-tes doesn't know - #412

Merged
uniqueg merged 4 commits into
devfrom
fix/unknown-task-fields
Nov 4, 2026
Merged

uniqueg merged 4 commits into
devfrom
fix/unknown-task-fields

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #409.

  • known_fields drops the keys that py-tes's models don't know, recursively, before unmarshal in TesClient.get_task. Tasks of backends that add fields (TESP: author) are now tracked to their final state, with their logs and outputs. Free-form maps (tags, metadata, env, backend_parameters) are kept.
  • tests/smoke/fake_tes.py serves author (except as TES 1.0), so the smoke test covers it.
  • docs/tes-versions.md: new section on fields that TES instances add.

Verification

  • pytest tests/ga4gh/tes/test_backends.py tests/tasks: passed, including new tests with extra fields at all levels, camel case, values that are no objects, and a check of the map of nested models against py-tes's type hints. Without the filter, py-tes raises UnmarshalError on author (checked directly).
  • pre-commit run on the changed files: passed.
  • Not run locally: the Compose smoke test and the docs build (both run in CI). Not run against a real TESP.

Declined review findings

  • None.

🤖 Generated with Claude Code

Summary by Sourcery

Support TES backends that add fields beyond the specification while preserving normal task tracking and client responses.

Bug Fixes:

  • Ensure tasks containing backend-specific fields are tracked successfully instead of failing during deserialization.

Enhancements:

  • Ignore unknown fields recursively while preserving free-form maps and supported camel-case fields.
  • Document how proTES handles fields added by TES instances.

Documentation:

  • Document that TES instance-specific fields are ignored at all task nesting levels and are not exposed to clients.

Tests:

  • Add coverage for unknown nested fields, free-form maps, camel-case fields, non-object values, immutability, and nested model mappings.
  • Extend the smoke test backend and assertions to cover backend-added task fields.

uniqueg and others added 2 commits November 4, 2026 05:44
py-tes raises on keys that its models don't know, also in nested
objects, so that tasks of backends that add such fields (e.g., `author`
of TESP) stayed `UNKNOWN`. Drop these keys before `unmarshal`. The fake
TES backend of the smoke test now serves such a field.

Closes #409

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Check that the map of nested models is complete against py-tes's type
hints, test values that are no objects and that the input isn't changed,
and log ignored fields at debug level.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg added this to the v0.5.0 milestone Nov 4, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR makes task tracking tolerant of backend-specific fields by recursively removing fields unknown to py-tes before unmarshalling, while preserving free-form maps and supported task data; it adds unit and smoke coverage and documents the behavior.

Sequence diagram for filtering backend-specific task fields

sequenceDiagram
    participant Backend
    participant TesClient
    participant known_fields
    participant py_tes
    participant ProTESClient

    ProTESClient->>TesClient: get_task(task_id, view)
    TesClient->>Backend: GET task
    Backend-->>TesClient: Task JSON with backend fields
    TesClient->>known_fields: known_fields(body)
    known_fields->>known_fields: Recursively filter nested models
    known_fields-->>TesClient: Supported fields and free-form maps
    TesClient->>py_tes: unmarshal(filtered body, tes.Task)
    py_tes-->>TesClient: tes.Task
    TesClient-->>ProTESClient: Task without unknown fields
Loading

File-Level Changes

Change Details Files
Filter backend-specific task fields before py-tes unmarshalling while preserving supported fields and free-form maps.
  • Add recursive, non-mutating filtering based on py-tes model signatures.
  • Handle nested task models, lists, camelCase keys, and non-object values.
  • Keep maps such as tags and metadata unchanged.
  • Apply filtering in TesClient.get_task before unmarshal.
pro_tes/ga4gh/tes/backends.py
Add regression coverage for unknown fields and model coverage.
  • Verify unsupported fields are removed at every nested task level while supported values and free-form maps remain.
  • Test camelCase handling, scalar values, input immutability, and nested-model mappings against py-tes type hints.
  • Confirm py-tes task retrieval succeeds with backend-specific fields.
tests/ga4gh/tes/test_backends.py
Extend smoke coverage to backend-added fields and document their client-visible behavior.
  • Make the fake TES 1.1 backend serve an author field while TES 1.0 remains unchanged.
  • Assert tracked tasks complete and the added field is not exposed by proTES.
  • Document that TES-added fields are ignored recursively and not served to clients.
tests/smoke/fake_tes.py
tests/smoke/check.sh
docs/tes-versions.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35633296 | 📁 Comparing a0cf12e against latest (5a57844)

  🔍 Preview build  

3 files changed
± api/index.html
± reference/index.html
± tes-versions/index.html

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c924f3f) to head (a0cf12e).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #412   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines         2500      2518   +18     
=========================================
+ Hits          2500      2518   +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 4, 2026 04:59

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="pro_tes/ga4gh/tes/backends.py" line_range="579-580" />
<code_context>
+        The value, without the unknown fields; not changed in place.
+    """
+    if isinstance(value, list):
+        return [known_fields(item, model) for item in value]
+    if not isinstance(value, dict):
+        return value
+    fields = signature(model).parameters
</code_context>
<issue_to_address>
**Nested arrays stall task polling**

When a configured or discovered TES backend returns a task containing deeply nested arrays, such as in `inputs`, `known_fields` recursively processes every nested list without checking its expected model shape, so a backend response containing sufficiently deep arrays raises `RecursionError` before unmarshalling. The poll handlers treat this as a failed poll and retry, leaving affected tasks untracked to completion and repeatedly consuming poll attempts.

Reject unexpected list shapes or impose a recursion-depth limit before descending into list values.
</issue_to_address>

Linked issues

#409 fix: track tasks with fields py-tes doesn't know · 4 of 4 met

# Requirement Status Notes
1 Drop fields unknown to py-tes recursively from task objects, including inputs, outputs, resources, executors, task logs, executor logs, and output file logs. ✅ Met known_fields filters each model and recurses through the mapped nested models before unmarshal in TesClient.get_task.
2 Add a regression test with extra fields at each level. ✅ Met The tests cover unknown fields on the task and its nested objects, including executor logs and output file logs.
3 Add a non-standard author field to the smoke-test backend and check that the task is tracked to its final state. ✅ Met The TES 1.1 fake backend serves author; the smoke test waits for COMPLETE and verifies that author is not exposed by proTES.
4 Add documentation. ✅ Met docs/tes-versions.md documents how fields added by TES instances are handled.

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: pro_tes/ga4gh/tes/backends.py:580


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread pro_tes/ga4gh/tes/backends.py Resolved
Lists of lists aren't valid in tasks, and deep ones would raise a
`RecursionError`: keep them for py-tes to reject.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@sourcery-ai sourcery-ai Bot 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.

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit f88399b into dev Nov 4, 2026
32 checks passed
@uniqueg
uniqueg deleted the fix/unknown-task-fields branch November 4, 2026 05:22
uniqueg added a commit that referenced this pull request Nov 4, 2026
Brings in the review fixes #410, #412, #417, #419, #420, #421.

The only conflict is in the module docstring of
`pro_tes/ga4gh/tes/backends.py`: keeps this branch's removal of the
FOCA 0.19 caveat about redirects, and the sentence of #419 about tasks
in the view `FULL`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

fix: track tasks with fields py-tes doesn't know

1 participant