Skip to content

EMPTY: read the OWL files EMPTY.m reads, with its matching and failover (#11 item 3) - #14

Merged
stevevanhooser merged 1 commit into
mainfrom
claude/empty-owl-parity
Oct 21, 2026
Merged

stevevanhooser merged 1 commit into
mainfrom
claude/empty-owl-parity

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor

Item 3 of #11: brings EMPTYProvider to parity with src/ndi/+ndi/+ontology/EMPTY.m (ndi-ontology-matlab @ 8e109b0). Only EMPTY changes, in code, tests and bridge entry. No other provider or bridge entry is touched.

What changed

  • Source file: the provider now reads main/empty-base.owl instead of empty-base.json.
  • Format detection: it parses either format, as EMPTY.m does. If the content contains <?xml or <rdf:RDF it goes to parseXMLFormat; anything else goes to parseFunctionalFormat.
  • Failover: any failure on main, whether the term is missing or the download fails, tries development/src/ontology/empty-edit.owl.
    • If the development file 404s, main's error is re-raised.
    • Any other failure there raises LookupFailed, which carries both errors (EMPTY.m:46-51).
  • Matching now follows EMPTY.m:89/:160: the bare numeric id or the whole label, case-insensitive and exact, with the first match winning.
    • The old zero-padding, EMPTY_0000074 form and label-substring fallback are removed, because MATLAB has none of them.
    • Behaviour change: EMPTY:2 and partial labels no longer resolve.
  • Returned fields: EMPTY:<digits>, the label, the first IAO_0000115 definition, and every exact or related synonym.
    • XML values go through unescapeXML in MATLAB's order: &amp; before &lt;/&gt;, leftover tags stripped, result trimmed. It is kept separate from the module's _unescape_xml, which other providers use and which gives different results.
    • Functional-syntax values are returned raw, as in MATLAB.
  • Method names follow MATLAB: lookupTermOrID, performRemoteLookup, parseXMLFormat, parseFunctionalFormat, unescapeXML, plus the constants OWL_URL_MAIN and OWL_URL_DEV.

Kept from #10

  • A failed download raises and is not cached.
  • clearCache() resets EMPTYProvider._cache. The cache now holds each file's body, keyed by URL.

Deliberate differences (recorded in the bridge entry)

  • Per-process cache: kept. EMPTY.m caches nothing, but a failure can no longer end up in the cache, so the cache is safe to keep.
  • 404 detection: EMPTY.m:39 checks whether the error message contains 404 or Not Found. Python checks the HTTP status code instead, so a term containing 404 is not mistaken for a missing branch. Only which error gets raised can differ; both versions raise.

Testing

  • 17 new offline tests, all with mocked downloads. They cover:
    • small OWL excerpts in RDF/XML and in functional syntax
    • lookup by id and by name
    • the matches that are no longer accepted
    • unescaping
    • every failover path: development has the term, main times out, development 404s, both fail
    • caching
  • All 17 failed before the change and pass after it.
  • black, ruff and pytest -m "not live" (166 passed) are clean.
  • The six EMPTY cases in the shared case table pass live against GitHub raw. The suite's network probe targets EBI, which this sandbox can't reach, so I forced the probe to true and ran only -k EMPTY.
  • The development branch currently 404s, so live lookups exercise only the main path. The fallback is covered by the mocked tests only.

Generated by Claude Code

…er (#11 item 3)

EMPTYProvider read empty-base.json; EMPTY.m reads main/empty-base.owl,
detects RDF/XML vs functional syntax, and falls back to the development
branch's src/ontology/empty-edit.owl, re-raising main's error when that
404s and combining both errors otherwise. Port all of it under MATLAB's
method names (lookupTermOrID, performRemoteLookup, parseXMLFormat,
parseFunctionalFormat, unescapeXML).

Matching now follows EMPTY.m: bare numeric id or whole label,
case-insensitive, exact. The old zero-padding, EMPTY_ form and label
substring fallback are gone, as MATLAB has none of them.

The per-process cache stays (by URL, failures never cached, reset by
clearCache()). The 404 check uses the HTTP status rather than MATLAB's
message sniffing. Both recorded in the bridge entry, now examined at
8e109b0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UaMQ8AiBeK9Bj7tZ7U1CS2
@stevevanhooser
stevevanhooser merged commit 005271a into main Oct 21, 2026
6 checks passed
@stevevanhooser
stevevanhooser deleted the claude/empty-owl-parity branch October 21, 2026 16:58
stevevanhooser pushed a commit that referenced this pull request Oct 21, 2026
…ed helpers

main brought #14 (EMPTY), #15 (NCIT codes by obo_id), #17 (lookup
trimming, the same fix as this branch's) and #18 (known_gaps).

#15's NCITProvider.lookup_term called OLSProvider._search_ols, which this
branch replaces; git merged it cleanly, and every NCIT lookup would have
raised AttributeError. It now does what NCIT.m does on the ported
helpers: preprocessLookupInput, then searchOLSAndPerformIRILookup on
obo_id for ['NCIT:', search_query]. Its tests move to FakeOLS, plus one
for the prefixed and numeric forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017iFBFMQmEZaz21d9ZFJbiH
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.

2 participants