Skip to content

Add Wikidata QIDs, MoM SPARQL bridge, OKW fixes, and process taxonomy improvements#181

Merged
touchthesun merged 5 commits into
mainfrom
mom-ohm-integration
Jun 30, 2026
Merged

Add Wikidata QIDs, MoM SPARQL bridge, OKW fixes, and process taxonomy improvements#181
touchthesun merged 5 commits into
mainfrom
mom-ohm-integration

Conversation

@touchthesun

Copy link
Copy Markdown
Contributor

Summary

  • Wikidata QIDs: Added wikidata_qid to 9 processes in processes.yaml (3D printing, CNC machining/milling/turning, laser cutting, PCB fabrication, electronics assembly, welding, painting). Exposed as wikidata_iri field in GET /api/taxonomy response.
  • MoM SPARQL bridge (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. Uses httpx.AsyncClient per project convention.
  • OKWResponse fix: Added missing message: str field to OKWResponse — previously caused HTTP 500 on POST /v1/api/okw/create.
  • has_process() rewrite: Now uses taxonomy.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 on OKWFacility that serializes a facility to the SpaceAPI envelope format, enabling MoM ingestion.

Test plan

  • make ready passes (format, lint, tests, parity, docs)
  • GET /api/taxonomy response includes wikidata_iri on processes that have QIDs, null on those that don't
  • POST /v1/api/okw/create returns 200 (not 500) — OKWResponse message fix
  • has_process("cnc_machining") returns True for a facility listing cnc_milling (ancestor match)
  • to_spaceapi_json() returns a valid SpaceAPI envelope with space, state, and location keys

🤖 Generated with Claude Code

MakerNetwork and others added 5 commits June 29, 2026 21:08
… 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 touchthesun merged commit 59b8fea into main Jun 30, 2026
5 checks passed
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>
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