Add Wikidata QIDs, MoM SPARQL bridge, OKW fixes, and process taxonomy improvements#181
Merged
Conversation
… improvements - Add Wikidata QIDs to 9 processes in processes.yaml and expose them via GET /api/taxonomy (wikidata_iri field per process entry) - Add ProcessTaxonomy.get_wikidata_iri() and wikidata_qid support throughout the taxonomy loading/reload pipeline - Add src/core/services/mom_bridge.py: async SPARQL bridge to Maps of Making, querying spaces by Wikidata IRI alignment (uses httpx.AsyncClient per project convention) - Fix OKWResponse missing message field that caused HTTP 500 on POST /v1/api/okw/create - Rewrite OKWFacility.has_process() to use canonical taxonomy matching with ancestor traversal for hierarchical process lookup - Add OKWFacility.to_spaceapi_json() for SpaceAPI envelope serialization Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- storage_config.py: get_okw_source() reads OKW_SOURCE env var (storage|mom); get_mom_config() reads MOM_SPARQL_ENDPOINT with MoM default - mom_bridge.py: fetch_mom_facilities_for_manifest() aggregates MoM spaces across all required processes from an OKH manifest into ManufacturingFacility stubs for the matching pipeline - match.py: --okw-source option (OKW_SOURCE envvar) routes manufacturing facility load to MoM SPARQL or blob storage; each path logs the source - main.py: ohm config shows OKW facility source and MoM endpoint Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
processes.yaml: 3d_printing Q785781→Q229367, cnc_machining Q644395→Q174689 to match MoM ontology's owl:sameAs links (confirmed against live endpoint). Laser cutting, welding, painting QIDs are already correct per PR #18 and will activate once maps_of_making#18 is merged. match.py: when --okw-source mom is set, force the fallback matching path before attempting the HTTP API. The API route loads facilities from blob storage only; MoM SPARQL discovery requires the CLI fallback. Also fixes 3-dot relative imports (src.config.storage_config) that caused ImportError in the fallback path. E2E confirmed: `ohm match requirements demo.json --okw-source mom` returns real facilities from MoM (FabLab Pau, FabLab TSU, Fablab Chengdu, etc.) sourced via Wikidata wormhole SPARQL query against mapsofmaking.org/sparql. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
_get_filtered_facilities() now accepts an optional okh_manifest and checks OKW_SOURCE before falling back to blob storage. When OKW_SOURCE=mom and a manifest is present, it calls fetch_mom_facilities_for_manifest() against the MoM SPARQL endpoint and logs source + facility count clearly. The storage path gains provider/bucket logging (parallel to the CLI) so operators can see which backend is active regardless of which source is used. Live test: OKW_SOURCE=mom + CNC+3DP manifest → 2,548 ManufacturingFacility objects from mapsofmaking.org/sparql, 0 type-gate failures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
touchthesun
pushed a commit
that referenced
this pull request
Jun 30, 2026
… add docs and tests The match API checked MATCHING_LOCAL_OKW_JSON_DIR (a local-dev convenience for blob storage) before OKW_SOURCE, so an explicit mom request was silently overridden whenever that env var was set — a divergence from the CLI, where --okw-source mom always reaches MoM. Reorder so OKW_SOURCE wins. Also adds the demo/validation runbook and unit test coverage that were missing from the original MoM integration (PR #181): mom_bridge.py, taxonomy wikidata_qid lookups, and the OKW_SOURCE routing logic, including a regression test for this fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
wikidata_qidto 9 processes inprocesses.yaml(3D printing, CNC machining/milling/turning, laser cutting, PCB fabrication, electronics assembly, welding, painting). Exposed aswikidata_irifield inGET /api/taxonomyresponse.src/core/services/mom_bridge.py): New async service that queries the Maps of Making SPARQL endpoint for makerspaces that have a given manufacturing process, matched via Wikidata IRI alignment. Useshttpx.AsyncClientper project convention.message: strfield toOKWResponse— previously caused HTTP 500 onPOST /v1/api/okw/create.has_process()rewrite: Now usestaxonomy.normalize()+taxonomy.get_ancestors()for hierarchical process matching (e.g. querying for "cnc_machining" matches a facility that lists "cnc_milling"), with substring fallback for unrecognized process strings.to_spaceapi_json(): New method onOKWFacilitythat serializes a facility to the SpaceAPI envelope format, enabling MoM ingestion.Test plan
make readypasses (format, lint, tests, parity, docs)GET /api/taxonomyresponse includeswikidata_irion processes that have QIDs,nullon those that don'tPOST /v1/api/okw/createreturns 200 (not 500) — OKWResponse message fixhas_process("cnc_machining")returnsTruefor a facility listingcnc_milling(ancestor match)to_spaceapi_json()returns a valid SpaceAPI envelope withspace,state, andlocationkeys🤖 Generated with Claude Code