Skip to content

Make provider merging repeatable and bound provider requests - #70

Open
kennethbruskiewicz wants to merge 2 commits into
mainfrom
fix/provider-merge-and-timeout
Open

kennethbruskiewicz wants to merge 2 commits into
mainfrom
fix/provider-merge-and-timeout

Conversation

@kennethbruskiewicz

Copy link
Copy Markdown
Collaborator

Summary

Three small fixes to provider querying in TCT/translator_query.py. They came out of one recorded run of "what does metformin treat?" across 20 discovered providers on 2026-11-16.

Changes

Empty answers

query_KP returns None when a provider answers with no edges, and for a non-200 response. parallel_api_query then ran 'knowledge_graph' in data on that None, and a broad except swallowed the resulting TypeError. The loop now checks for None directly. Callers get the same result as before.

Merge order

Responses were merged in the order they completed, and a later response overwrote an earlier one wherever two providers returned the same edge ID. In the recorded run 2,378 edges came back and 763 remained, and which copy survived depended on timing. Responses are now merged in provider-name order. The result has the same shape and is the same on every run.

Name order is used because the list of selected providers is built from a set, and its order changes between processes.

Request timeout

requests.post was called with no timeout. In the recorded run cohd.io never accepted the connection and held the query until the operating system gave up. Provider queries now use PROVIDER_TIMEOUT = (10, 300), which is 10 seconds to connect and 300 seconds to read.

This is a behaviour change. A provider that takes more than five minutes to answer was waited for before and is now dropped. Five minutes matches the consortium's response-time target for ARAs.

Not changed

Edges are still matched on each provider's own edge ID. Matching on content, as the ARS does, would change the keys that results and support graphs refer to and needs its own design.

Testing

tests/test_translator_query.py adds two offline tests. One checks that the merged result is identical whichever provider answers first, with an empty and a failing provider in the mix. The other checks that a provider query passes the timeout.

The full suite passes locally with the live services reachable: 125 passed, 1 skipped.

A second commit updates three live-service tests that fail on main today because NameRes and Node Annotator changed. The edits are identical to the ones on #68, so the two will not conflict.

Note for #68

#68 changes the same loop to record merge observations. Whichever lands second needs a small manual merge.

🤖 Generated with Claude Code

kennethbruskiewicz and others added 2 commits November 16, 2026 11:42
An empty answer from a provider is no longer handled by catching a TypeError.
query_KP returns None for it, and the merge loop now checks for that.

Responses are merged in provider-name order, so the edge kept for a shared
edge ID no longer depends on which response arrived first.

Provider queries set a (10, 300) second connect/read timeout. A host that
never accepts the connection previously held the query until the OS gave up.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
These three tests fail on main because the services changed, not the toolkit.
The changes are identical to the ones on #68.

NameRes on Babel 2026jul22 reports Solr stats at the top level and indexes
about 331M names. The status test accepts both shapes and uses a 300M floor.

Node Annotator no longer returns clinical_approval for CHEBI:15377. The
expectation drops the volatile warning and clinical fields.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@kennethbruskiewicz
kennethbruskiewicz marked this pull request as ready for review November 16, 2026 20:43

This branch has not been deployed

No deployments
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