Repository navigation
feat: per-backend API path, e.g., for TESP - #417
Conversation
Add `api_path` to the entries of TES instances in `custom.tes.backends` (`apiPath` in the chart; default `/ga4gh/tes/v1`), for TES instances that serve the API elsewhere, as TESP does at `/v1`. FOCA's models keep entries of a subclass as they are, so it lives in proTES. Plugins and `check_outbound` keep seeing the path of the API of proTES; the client applies the API path when it sends a request. Add a smoke case with a fake backend that serves `/v1` only, and name TESP in the docs. Closes #411 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use the same characters as the app's check, and rewrap the docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR adds validated per-backend TES API paths, preserving canonical Sequence diagram for per-backend TES API path translationsequenceDiagram
participant Plugin
participant Gateway
participant TesClient
participant TESBackend
Plugin->>Gateway: POST /ga4gh/tes/v1/tasks
Gateway->>Gateway: check_outbound(outbound)
Gateway->>TesClient: forward(outbound, task)
TesClient->>TesClient: Translate DEFAULT_API_PATH to api_path
TesClient->>TESBackend: POST /v1/tasks
TESBackend-->>TesClient: Task response
TesClient-->>Gateway: BackendResponse
Gateway-->>Plugin: Forwarded task result
Sequence diagram for backend-specific task lifecycle pathssequenceDiagram
participant Caller
participant TesClient
participant TESBackend
Caller->>TesClient: get_task(task_id)
TesClient->>TESBackend: GET /v1/tasks/{task_id}
TESBackend-->>TesClient: Task
Caller->>TesClient: cancel_task(task_id)
TesClient->>TESBackend: POST /v1/tasks/{task_id}:cancel
TESBackend-->>TesClient: Cancellation response
Caller->>TesClient: service_info()
TesClient->>TESBackend: GET /v1/service-info
TESBackend-->>TesClient: Service info
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #417 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 2518 2542 +24
=========================================
+ Hits 2518 2542 +24 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 2 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="642-644" />
<code_context>
super().__init__(url=url, timeout=timeout)
self.backend = backend
self.entry = entry
+ self.api_path = (
+ entry.api_path if isinstance(entry, TesServiceEntry) else DEFAULT_API_PATH
+ )
# discovered backends: each connection is checked
self.guarded: GuardedClient | None = None
</code_context>
<issue_to_address>
**Active tasks become unreachable**
When the configured `api_path` changes while tasks created with the previous path are still active, `_poll` and `cancel_task` rebuild clients using the current backend entry's path, but task records retain only the host and task ID. Requests therefore use the wrong route, leaving those tasks untracked or uncancelable.
Store the API path used when each task is created and use it when polling or canceling that task.
</issue_to_address>
### Comment 2
<location path="pro_tes/config_models.py" line_range="322-330" />
<code_context>
+ """
+ if not value.startswith("/"):
+ raise ValueError(f"API path must be absolute: {value!r}")
+ path = value.rstrip("/")
+ if path and (
+ not _API_PATH.fullmatch(path) or {".", ".."} & set(path.split("/"))
+ ):
+ raise ValueError(
+ f"API path must have unreserved characters only, and no segments"
+ f" `.` or `..`: {value!r}"
+ )
+ return path
+
+
</code_context>
<issue_to_address>
**Repeated slashes select the root**
When `api_path` contains only multiple slashes, `rstrip("/")` turns `//` or `///` into an empty path, which passes the root-path check. `TesClient` then sends requests to the backend URL root instead of rejecting the malformed setting, so requests can fail or reach the wrong endpoint.
Accept the empty normalized path only when the original value is exactly `/`; reject other slash-only values.
</issue_to_address>Linked issues
#411 feat: per-backend API path, e.g., for TESP · 4 of 4 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Add a per-entry api_path option (default /ga4gh/tes/v1, apiPath in the chart) and use it for task creation, retrieval, cancellation, and service-info requests. |
✅ Met | The TES entry model defaults and validates api_path; the Helm template maps apiPath, and TesClient applies the configured path to all four request types. |
| 2 | Keep plugins and check_outbound on proTES’s canonical /ga4gh/tes/v1/tasks path. |
✅ Met | TASKS_PATH remains based on DEFAULT_API_PATH; TesClient.forward translates that path only when sending to a backend. |
| 3 | Add a smoke case with a fake backend that serves /v1 only. |
✅ Met | The smoke configuration targets a fake serving /v1 and checks task creation, tracking, and cancellation. |
| 4 | Add documentation naming TESP. | ✅ Met | The configuration documentation names TESP and describes its /v1 API path; the deployment README also includes a TESP-style example. |
Sourcery assessment
Needs a human reviewer. 2 findings to address first, and if the configured API path is wrong but still accepts task submissions, a backend could create tasks at an unintended endpoint; those remote tasks are not removed by reverting this change, though they can generally be canceled. With the default path unchanged, the main risk is limited to backends explicitly configured with an alternate path.
Blocking findings: pro_tes/ga4gh/tes/backends.py:644, pro_tes/config_models.py:330
Only one trailing slash is removed, so that `//` isn't taken for the root path, as in the chart's schema. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
Closes #411
Summary
TESP serves its API below
/v1, and proTES sent all requests to the path of the TES specification. Entries ofcustom.tes.backendscan now setapi_path(default/ga4gh/tes/v1),apiPathin the chart.TesClientuses it for tasks, cancellation and service info;check_outboundkeeps working on the canonical path, so plugins don't have to know it.TesServiceEntryextends FOCA'sServiceEntry, andTes.parse_tes_instancesparses entries before FOCA's list model, which keeps subclass instances. No FOCA change is needed.docs/configuration.md("API paths", naming TESP), chart README and values./v1, with a task held and canceled.Verification
python -m pytestwith real Helm: 1517 passed, 11 skipped.pre-commit run --from-ref origin/dev --to-ref HEAD: passed.Declined review findings
ServiceEntryinstance defaults to the default path: only programmatic use and tests, covered bytest_api_path_default.test_api_path_candidatesand the smoke config test catch a loss; a hook would be a FOCA change, and none is planned for 0.5.0.forward: non-default paths are covered bytest_forward_outbound.FAKE_TES_BASE_PATHalso disables tokens in the fake: test helper only.model_dumpdropsapi_path: no dump and reload exists; documented in the docstring.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Allow each configured TES backend to use a custom API path while preserving the canonical proTES API path for plugins and defaulting discovered backends to the standard path.
New Features:
/v1for TESP, while retaining the standard path by default.Enhancements:
Deployment:
apiPathin the Helm chart and validate it in chart values.Documentation:
Tests: