Repository navigation
feat!: adapt tasks to TES versions of backends - #403
Conversation
Add version adapters with a 1.1 to 1.0 adapter. Filter backends before routing, so tasks that TES 1.0 can't express go only to TES 1.1 backends (400 if none is left), and downgrade tasks per backend after the forward phase. Fetched tasks are upgraded in TesClient.get_task, so that the tracker and a later live relay share it. Refs #394 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
Reviewer's GuideThis PR makes proTES TES 1.1-canonical while adapting tasks per backend TES version through a chained adapter system, adding version-aware eligibility and routing, preserving canonical stored tasks, upgrading backend reads, recording relay versions, and documenting and testing the resulting behavior. Sequence diagram for version-aware task submissionsequenceDiagram
actor Client
participant ProTES
participant Versions as BackendVersions
participant Plugin as Route plugins
participant Backend as TES backend
Client->>ProTES: POST /tasks
ProTES->>Versions: eligible_backends(task, backends)
Versions->>Backend: service_info()
Backend-->>Versions: TES version
Versions-->>ProTES: Eligible backends
ProTES->>Plugin: route(eligible backends)
Plugin-->>ProTES: Ranked backend
ProTES->>ProTES: Store canonical TES 1.1 task
ProTES->>ProTES: backend_version(backend)
ProTES->>ProTES: relayed_task(payload, prefix, version)
ProTES->>Backend: forward(downgraded task)
Backend-->>ProTES: Accepted or rejected
ProTES-->>Client: Task response
Flow diagram for TES backend eligibility and adaptationflowchart TD
Start[Canonical TES 1.1 task] --> Check["incompatibilities(task, backend version)"]
Check -->|Incompatible| Eligible{Any eligible backend?}
Check -->|Compatible| Route[Route among backend]
Eligible -->|No, versions confirmed| BadRequest[400 Bad Request; task not stored]
Eligible -->|Unknown or unavailable backend| Unavailable[503 Service Unavailable]
Eligible -->|Yes| Route
Route --> Relay["relayed_task(payload, prefix, version)"]
Relay --> Downgrade["downgrade_task(task, version)"]
Downgrade --> Forward[Forward backend-specific task]
Forward --> Record[Record tes_endpoint.tes_version]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pro_tes/ga4gh/tes/task_runs.py" line_range="472" />
<code_context>
db_document.tes_endpoint = TesEndpoint(host=tes_url)
- # checked by `check_outbound` before the attempt
- task = relayed_task(attempt.outbound.payload, prefix=prefix)
+ version = backend_version(attempt.backend)
try:
+ # checked by `check_outbound` before the attempt, but not
</code_context>
<issue_to_address>
**Backend probes exceed request timeout**
When the version cache is cold or expired, a task needs no eligibility filtering, and multiple backends do not answer service-info requests, `backend_version` can spend the full service-info probe timeout before the attempt’s `try` block; the remaining-time limit is passed only later to `cli.forward`. For ordinary tasks, `eligible_backends` skips probing, so several unavailable backends can make the request exceed `forward_timeout` and the proxy timeout, leaving the caller with a timeout despite subsequent forwarding attempts.
Include service-info probes in the same overall forwarding deadline, or avoid blocking probes in the forwarding path.
</issue_to_address>
### Comment 2
<location path="pro_tes/ga4gh/tes/backends.py" line_range="1109" />
<code_context>
- if probe and (cached is None or time.monotonic() >= cached[1]):
+ if probe and (cached is None or time.monotonic() >= cached.expires_at):
cached = self._probe(backend)
self._cache[backend.url] = cached
- return (cached[0] if cached is not None else None) or OLDEST
+ return (cached.version if cached is not None else None) or OLDEST
</code_context>
<issue_to_address>
**Stale probes replace newer results**
When overlapping probes for the same backend URL complete out of order, the unconditional `_cache[backend.url]` assignment lets an older or failed probe replace a newer successful result, so later routing uses stale version or parameter data and can reject a runnable task, send it to an incapable backend, or report `503`.
Only store a probe result if the cache has not changed since that probe began.
Also at `pro_tes/ga4gh/tes/backends.py:1182`.
</issue_to_address>
### Comment 3
<location path="pro_tes/ga4gh/tes/versions.py" line_range="179" />
<code_context>
+ )
+ )
+ for index, output in _items(task, "outputs"):
+ if _WILDCARDS.search(str(output.get("path"))):
+ found.append(
+ Incompatibility(
</code_context>
<issue_to_address>
**Valid literal paths get rejected**
When an output path contains an unmatched literal `[` and only TES 1.0 backends are eligible, `_WILDCARDS.search` treats the unmatched bracket as a wildcard, so `incompatibilities` excludes TES 1.0 backends and returns `400 Bad Request` for a task they can run.
Treat `[` as a wildcard only when it begins a valid bracket expression.
</issue_to_address>
### Comment 4
<location path="pro_tes/ga4gh/tes/backends.py" line_range="1168" />
<code_context>
try:
- version = reported_version(
- client_for(backend, timeout=PROBE_TIMEOUT).service_info()
+ service_info = client_for(backend, timeout=PROBE_TIMEOUT).service_info()
+ version = reported_version(service_info)
+ listed: Any = (
</code_context>
<issue_to_address>
**Version probes exceed their timeout**
When a cold version probe to a configured backend spends close to the timeout connecting and then close to the timeout waiting for a response, `client_for` applies `PROBE_TIMEOUT` as both the connect and read timeout for configured backends, not as a total deadline. A probe can therefore take nearly 10 seconds, stalling task creation longer than the documented five-second probe limit.
Enforce a five-second end-to-end probe deadline, including both connection and response time.
</issue_to_address>
### Comment 5
<location path="pro_tes/ga4gh/tes/backends.py" line_range="1206" />
<code_context>
+ return _Probe(
+ version,
+ time.monotonic() + get_custom_config(CustomConfig).tes.version_cache_ttl,
+ parameters,
+ )
</code_context>
<issue_to_address>
**Previously listed parameters disappear**
When a backend's advertised parameter list changes between service-info probes, such as after a backend configuration change, a successful refresh replaces the cached parameter list with only the latest service-info response, and `parameters()` unions only the current cache entries. A key reported before the refresh therefore disappears from proTES service info, contrary to the documented union of keys read so far; clients can stop seeing a parameter that proTES previously advertised.
Accumulate previously observed parameter keys separately from the replaceable version-probe cache, or otherwise retain the documented historical union.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 5 findings to address first, and a faulty compatibility check or downgrade could send a task to a TES 1.0 backend with different execution semantics—for example, treating a wildcard output path literally. If the backend runs it and produces side effects, reverting the code will not undo them.
Blocking findings: pro_tes/ga4gh/tes/task_runs.py:472, pro_tes/ga4gh/tes/backends.py:1109, pro_tes/ga4gh/tes/versions.py:179, pro_tes/ga4gh/tes/backends.py:1168, pro_tes/ga4gh/tes/backends.py:1206
An unmatched bracket in an output path is literal, also for TES 1.1, so such tasks can go to TES 1.0. Say in the docs what the timeouts of service info requests are, and where the backend parameters come from. Refs #394 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
Refs #394 (closed by the final PR from
feat/tes-1.1intodev, with the other children of #241).Summary
proTES now adapts tasks to the TES version of each backend, with a chain of adapters in
pro_tes/ga4gh/tes/versions.py(a 1.1 to 1.0 adapter for now).eligible_backendsremoves backends that can't run a task unchanged:ignore_error: true, strictbackend_parametersand wildcards in output paths can't be expressed in TES 1.0. If none is left:400 Bad Request, nothing stored; also if the client's selection leaves only such backends. If backends didn't answer so far:503, as retrying may help.relayed_taskdowngrades the task per backend, after the forward phase and credential stripping. Fields that TES 1.0 can drop are dropped (streamable,path_prefix, non-strictbackend_parameters,ignore_error: false). The stored task keeps them;tes_endpoint.tes_versionrecords the version it was relayed in.TesClient.get_taskupgrades them, so the tracker needs no adapters and a live relay (proTES 0.6.0) can share this.tesResources_backend_parametersis the union of what was read so far, from the cache only (no network on the public endpoint). A configured value wins.400comes, the next backend is tried.Docs:
docs/tes-versions.md(new),docs/api.md,docs/configuration.md,docs/upgrading.md.Operators: Funnel needs the label
tes.version: "1.1", as it reports its own version; registries with both versions need one entry per version, with a label.Verification
ruff check,ruff format --check,mypy,ast-grep scan: pass.coverage run -m pytestwithout the chart tests: 1281 passed, 11 skipped (need a real MongoDB or Docker), 2 deselected; coverage 100%. After the last fix (wildcards), onlytest_versions.pyandtest_backend_versions.pyran again here.ci.ymldoesn't run on PRs intofeat/tes-1.1, so these checks ran locally; the chart, docs, smoke and image jobs run on the final PR intodev.adversarial-reviewer(2 rounds) andquality-reviewer. Fixed: a failed re-read replaced a known version (high); valid tasks got400if backends were cold or unreachable (now503); an unavailable backend could keep others from being read;get_taskread the service info; a failure could undo a concurrent read; answers without a version lost their parameters; tasks with an unknown outcome lackedtes_version.Declined review findings
A plugin that empties the route after backends were filtered gets
400, not503(quality, medium): the same path serves the decided case of a client selection that leaves only ineligible backends; telling the two apart needs knowledge of what plugins do.The probe in
_forwarduses the forward budget if backends are unreachable (adversarial, medium): a cold cache only, at most once a minute per process, and a healthy backend answers at once. Limiting it would silently drop fields for a healthy TES 1.1 backend, which is worse. Documented indocs/configuration.md.tes_endpoint.tes_versionhas no reader (quality, medium): it's for operators who investigate tasks, as dropped fields aren't recorded per task.Hard-coded URL of the problem type, reason codes not in the docs (quality, medium): no shared constant in
pro_tes, and no reason code is documented so far.A cold backend that the client didn't select turns a
400into a503(adversarial, low): rare; the selection runs inside the route phase of the plugin engine, which this check can't see into.backend_versionwrapper, floats such as1.10parsed as 1.1 (quality, low): harmless today.Sourcery: probes in the forward budget (see above); out-of-order successful probes (only within seconds, corrected by the next read); 5 seconds per phase, not in total (docs corrected); keys that a backend stops listing disappear (intended, docs corrected). Fixed: an unmatched
[isn't a wildcard.Open questions
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG