Skip to content

feat: detect the TES versions of backends - #402

Merged
uniqueg merged 2 commits into
feat/tes-1.1from
feat/tes-backend-versions
Nov 3, 2026
Merged

uniqueg merged 2 commits into
feat/tes-1.1from
feat/tes-backend-versions

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Refs #393 (closed by the final PR from feat/tes-1.1 into dev, with the other children of #241).

Summary

proTES now knows the TES version of each backend: the label tes.version of 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 pytest without the chart tests: 1246 passed, 11 skipped (need a real MongoDB or Docker), 2 deselected; coverage 100%. After the last fixes (Sourcery findings), only tests/ga4gh/tes/test_backend_versions.py ran again here (22 passed, the changed lines covered); the full suite runs on the adapter branch on top of this one.
  • ci.yml doesn't run on PRs into feat/tes-1.1, so these checks ran locally; the chart, docs, smoke and image jobs run on the final PR into dev.
  • Reviewed together with the adapters: adversarial-reviewer (2 rounds) and quality-reviewer; the findings on this part are fixed, with regression tests.

Declined review findings

  • backend_version duplicates backend_versions.get (quality, low): it's what plugins and callers use; the class holds the cache.
  • Version aliases such as v1.1.0 pass the label check (Sourcery, low): they mean the same; the docs now say "other versions".
  • Removed backends stay in the per-process cache (Sourcery): an entry is tiny, and workers restart with deployments.

Open questions

None.

🤖 Generated with Claude Code

https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG

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
uniqueg marked this pull request as ready for review November 3, 2026 07:17
@sourcery-ai

sourcery-ai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Introduces per-process TES version detection for configured and discovered backends: validated tes.version labels take precedence, otherwise versions are leniently read from authenticated service-info responses, cached with configurable success and failure TTLs, and safely defaulted to TES 1.0 when unavailable or unsupported.

Sequence diagram for TES backend version detection

sequenceDiagram
    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
Loading

Flow diagram for TES version precedence and fallback

flowchart 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
Loading

File-Level Changes

Change Details Files
Added lenient TES version parsing and support definitions for TES 1.0 and 1.1.
  • Parses common version formats while retaining major/minor API versions.
  • Defines supported versions and defaults unknown backends to the oldest supported version.
pro_tes/ga4gh/tes/versions.py
Implemented backend TES version detection with label precedence, service-info probing, and per-process caching.
  • Uses a valid tes.version label without probing and validates labels during configuration loading.
  • Adds authenticated service-info requests with a five-second probe timeout.
  • Caches successful detections using the configurable TTL and retries failures after 60 seconds.
  • Preserves a previously detected version when a later probe fails; unknown results fall back to TES 1.0 with warnings.
  • Exposes shared cache management and the backend_version lookup API.
pro_tes/ga4gh/tes/backends.py
pro_tes/config_models.py
pro_tes/config.yaml
Documented TES version detection, fallback behavior, caching, and registry configuration.
  • Explains label precedence, service-info parsing, cache periods, warnings, and Funnel configuration.
  • Describes separating registry-discovered backend versions with entries and version filters.
docs/configuration.md
Added comprehensive coverage for parsing, configuration validation, probing, caching, failure handling, and request construction.
  • Tests valid and invalid service-info formats and configured labels.
  • Verifies cache expiry, retry behavior, preservation of known versions, warnings, and no-probe lookups.
  • Ensures the service-info endpoint, credentials, and timeout are used correctly.
tests/ga4gh/tes/test_versions.py
tests/ga4gh/tes/test_backend_versions.py
tests/conftest.py

Possibly linked issues

  • feat(api): implement TES 1.1 #241: The PR implements this issue’s backend-version detection, caching, label precedence, fallback behavior, and configuration documentation.

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 3, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35605119 | 📁 Comparing 11d2d57 against latest (ed55e4c)

  🔍 Preview build  

6 files changed · ± 6 modified

± Modified

@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 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


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

Comment thread pro_tes/ga4gh/tes/backends.py Resolved
Comment thread pro_tes/ga4gh/tes/backends.py Resolved
Comment thread pro_tes/config_models.py Resolved
Comment thread pro_tes/ga4gh/tes/backends.py Resolved
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
@uniqueg
uniqueg merged commit 30bec40 into feat/tes-1.1 Nov 3, 2026
2 checks passed
@uniqueg
uniqueg deleted the feat/tes-backend-versions branch November 3, 2026 07:24
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