Repository navigation
feat: detect the TES versions of backends - #402
Merged
Merged
Conversation
The label tes.version of a backend entry wins; otherwise proTES reads its service info, leniently, and caches the result per process. Unknown versions count as the oldest supported one, with a warning. No behaviour change for tasks yet. Refs #393 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
uniqueg
marked this pull request as ready for review
November 3, 2026 07:17
Reviewer's GuideIntroduces per-process TES version detection for configured and discovered backends: validated Sequence diagram for TES backend version detectionsequenceDiagram
participant Caller
participant BackendVersions
participant TesClient
participant Backend
participant Config
Caller->>BackendVersions: get(backend)
alt valid tes.version label
BackendVersions-->>Caller: TesVersion 1.0 or 1.1
else no valid label and cache expired
BackendVersions->>TesClient: client_for(backend, timeout=5)
TesClient->>Backend: service_info()
Backend-->>TesClient: GET /ga4gh/tes/v1/service-info
TesClient-->>BackendVersions: service info
BackendVersions->>BackendVersions: reported_version(service_info)
BackendVersions->>Config: read version_cache_ttl
BackendVersions-->>Caller: detected version
else probe fails or reports unsupported version
BackendVersions-->>Caller: cached version or TES 1.0
else cached version is valid
BackendVersions-->>Caller: cached version
end
Flow diagram for TES version precedence and fallbackflowchart TD
A[Backend version requested] --> B{Valid tes.version label?}
B -->|Yes| C[Use labeled TES version]
B -->|No| D{Valid cached service-info version?}
D -->|Yes| E[Use cached version]
D -->|No| F[Probe service-info]
F --> G{Reports supported TES version?}
G -->|Yes| H[Cache version for version_cache_ttl]
G -->|No or failure| I[Keep known version or assume TES 1.0]
H --> J[Return TES version]
C --> J
E --> J
I --> J
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 4 issues
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="1078" />
<code_context>
+ cached = self._cache.get(backend.url)
+ if probe and (cached is None or time.monotonic() >= cached[1]):
+ cached = self._probe(backend, cached[0] if cached else None)
+ self._cache[backend.url] = cached
+ return (cached[0] if cached is not None else None) or OLDEST
+
</code_context>
<issue_to_address>
**Concurrent probes restore stale versions**
When concurrent calls probe the same uncached or expired backend and a failing probe finishes after a successful one, `BackendVersions.get` unconditionally writes each `_probe` result, so the later failing probe replaces the successful cache entry with its stale `known` version or `None`; later callers then use the wrong TES version, often TES 1.0, until another probe succeeds.
Synchronize cache updates or recheck the current entry before allowing a failed probe to replace a successful result.
</issue_to_address>
### Comment 2
<location path="pro_tes/ga4gh/tes/backends.py" line_range="1119" />
<code_context>
+ known or OLDEST,
+ TES_VERSION_LABEL,
+ )
+ return known, now + PROBE_RETRY
+ return version, now + get_custom_config(CustomConfig).tes.version_cache_ttl
+
</code_context>
<issue_to_address>
**Unsupported versions retain old classification**
When a backend with a cached supported version successfully reports a missing or unsupported version on a later probe, `reported_version` returns `None` for the successful response, and `_probe` treats that like a request failure and returns `known`; callers keep using the previously detected version instead of falling back to TES 1.0.
Distinguish a successful response with no supported version from a failed request and use the TES 1.0 fallback for the successful response.
Also at `docs/configuration.md:160`.
</issue_to_address>
### Comment 3
<location path="pro_tes/config_models.py" line_range="330" />
<code_context>
+ """
+ for entry in self.backends.root:
+ label = entry.labels.get("tes.version")
+ if label is not None and TesVersion.parse(label) not in SUPPORTED:
+ raise ValueError(
+ f"Label `tes.version` of {entry.url}: {label!r} is none of the"
</code_context>
<issue_to_address>
**Version aliases pass configuration validation**
When a backend label uses a supported version-like alias such as `v1.1.0` or `1.1.0-rc1`, `check_version_labels` parses the label and accepts it as supported, so startup proceeds even though the documented contract refuses values other than `1.0` and `1.1`.
Validate the raw label against the exact allowed strings `1.0` and `1.1`.
Also at `docs/configuration.md:153-154`.
</issue_to_address>
### Comment 4
<location path="pro_tes/ga4gh/tes/backends.py" line_range="1051" />
<code_context>
+
+ def __init__(self) -> None:
+ """Create an empty cache."""
+ self._cache: dict[str, tuple[TesVersion | None, float]] = {}
+
+ def clear(self) -> None:
</code_context>
<issue_to_address>
**Removed backend entries accumulate**
When a long-lived process probes backend URLs that are later removed while the registry continues to discover new URLs, `BackendVersions._cache` retains entries for removed URLs, and expiry does not remove them unless the same URL is accessed again; registry churn therefore grows worker memory without bound.
Prune cache entries for URLs removed from the registry or otherwise remove expired entries.
</issue_to_address>Sourcery assessment
Approval pending. 3 findings to address first.
Blocking findings: pro_tes/ga4gh/tes/backends.py:1078, pro_tes/ga4gh/tes/backends.py:1119, pro_tes/ga4gh/tes/backends.py:1051
Failed reads of a service info keep the version in the cache as it is afterwards. Answers without a valid version count as TES 1.0, also if another version was read before. Refs #393 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #393 (closed by the final PR from
feat/tes-1.1intodev, with the other children of #241).Summary
proTES now knows the TES version of each backend: the label
tes.versionof its entry wins (other versions than 1.0 and 1.1 stop the app), otherwise it reads the service info of the backend, leniently, and caches the result per process (custom.tes.version_cache_ttl, failures for 60 seconds). Backends that never answered or report no valid version count as TES 1.0, with a warning; a version that was read stays if a later request fails.No behaviour change for tasks yet: the adapters that use this follow in the next PR, for #394.
Documentation:
docs/configuration.md("TES versions"),pro_tes/config.yaml.Verification
ruff check,ruff format --check,mypy,ast-grep scan: pass.coverage run -m pytestwithout the chart tests: 1246 passed, 11 skipped (need a real MongoDB or Docker), 2 deselected; coverage 100%. After the last fixes (Sourcery findings), onlytests/ga4gh/tes/test_backend_versions.pyran again here (22 passed, the changed lines covered); the full suite runs on the adapter branch on top of this one.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; the findings on this part are fixed, with regression tests.Declined review findings
backend_versionduplicatesbackend_versions.get(quality, low): it's what plugins and callers use; the class holds the cache.v1.1.0pass the label check (Sourcery, low): they mean the same; the docs now say "other versions".Open questions
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG