v2.1.0 JSON-LD context produces wrong or missing RDF triples, Blank Nodes
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with oemetadata/v2/v21/context.json, example.json, and schema.json, then reproduce the expansion with rdflib and PyLD as described. Compare the generated RDF against the issue's namespace, term, class/property, prefix, and datatype findings; done means the v2.1 context and example no longer lose or invalidate the specified triples and regression coverage is added.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description of the issue
When oemetadata/v2/v21/example.json is converted to RDF with oemetadata/v2/v21/context.json, some metadata is silently dropped and several triples use wrong or invalid IRIs.
JSON Schema validation still passes, so none of this is visible without converting to RDF.
Expected: every key in the schema either maps to a well-known predicate with the correct datatype, or is explicitly marked as JSON-only.
Current: the problems below. They are ordered by impact.
1. Wrong namespaces for dct and dcat (regression from v2.0.x)
"dcat": "https://www.w3.org/ns/dcat#",
"dct": "https://purl.org/dc/terms/",
Both namespaces are defined with http://. With https://, every dct:* and dcat:* term (title, description, license, subject, spatial, temporal, keyword, accessURL, …) becomes a different, non-standard IRI.
Standard tools and queries that look for dct:title or dcat:keyword will not find them.
v2/v20/context.json and production still use the correct http:// versions. The change came in with 0d86e74 (#296) and has already been copied to oemetadata/latest/context.json on develop.
2. Keys without a term definition are dropped from the RDF
JSON-LD processors silently drop any key the context does not define. There is no error.
These keys exist in schema.json/example.json but not in context.json:
| Key | Probable cause | What is lost |
|---|---|---|
datasetLicenses |
Renamed from licenses (#296); context not updated |
All dataset license information |
resourceLicenses |
Same | All resource license information |
projectContext |
New in v2.1, no term definition | Project, funding, publisher, contact |
mappingRelation |
Added in #302 without a term definition | Every skos:exactMatch etc. on isAbout / valueReference |
3. "@id": null in the example is rejected by strict processors
example.json contains "@id": null six times (in the empty valueReference entries).
pyld fails the whole document with Invalid JSON-LD syntax; "@id" value must be a string.
Some tools (e.g. rdflib) accept it, so whether the file parses depends on the tool.
4. Classes used as properties
These terms map to an RDF class, but they are used as a property (predicate):
| Key | Mapped to | Suggested property |
|---|---|---|
contributors |
foaf:Agent |
dct:contributor (or prov:qualifiedAttribution, see below) |
resources |
dcat:Dataset |
dcat:distribution (or dct:hasPart) |
resource (foreign key reference) |
dcat:Distribution |
a csvw reference property, e.g. csvw:resource |
timeseries |
dct:PeriodOfTime |
dct:temporal, with @type dct:PeriodOfTime on the object |
A class used as a predicate is valid RDF syntax, but the result has no useful meaning and does not work with DCAT/Dublin Core tooling.
5. Broken ncit prefix
"ncit": "http://purl.obolibrary.org/obo/ncit.owl",
The prefix has no trailing separator, so nullable → ncit:NCIT_C47840 expands to http://purl.obolibrary.org/obo/ncit.owlNCIT_C47840, which is not a valid term IRI.
The correct IRI is http://purl.obolibrary.org/obo/NCIT_C47840. That means prefix http://purl.obolibrary.org/obo/, as already used for IAO.
This prefix is the same in v2.0.
6. Datatypes that don't match the values
| Key | Declared type | Example value |
|---|---|---|
embargoPeriod.start / .end |
xsd:dateTime |
"2024-10-11" (a date) |
sources.publicationYear |
xsd:date |
"2023" (a year → xsd:gYear) |
The resulting literals are ill-typed and are rejected or ignored by validating RDF stores and SHACL.
Steps to Reproduce
pip install rdflib pyld- Merge
oemetadata/v2/v21/example.jsonwith the@contextfromoemetadata/v2/v21/context.json. Replace the example's remote@contextURL, and remove the"@id": nullentries so the document parses at all. - Parse with rdflib (
Graph().parse(data=..., format="json-ld")) and inspect the predicates.
Alternatively paste the merged document into the JSON-LD Playground and look at the N-Quads tab. - You will see:
https://purl.org/dc/terms/…andhttps://www.w3.org/ns/dcat#…predicates;- no license, project context or
mappingRelationtriples; …/ncit.owlNCIT_C47840;- rdflib warnings for the ill-typed date literals.
- Running
pyld.jsonld.expand()on the unmodified merged document fails on"@id": null.
Ideas of solution
-
Namespaces: set
dctanddcatback tohttp://, in bothv21/context.jsonandlatest/context.json. This is a trivial fix with no downside. -
Missing terms: add term definitions for
datasetLicenses,resourceLicenses(e.g.dct:license,@container: @set) andprojectContext(e.g.prov:wasGeneratedBywith a scoped context for its sub-keys).
mappingRelationneeds a modelling decision. Its value (skos:exactMatch) really describes which predicate should connect the column to the concept, and a plain term definition can't express that. The options are:- (a) map it as a plain literal /
@vocabIRI for now; - (b) model the mapping as its own node, e.g. SSSOM-style
subject/predicate/object; - (c) have a generator emit
column skos:exactMatch conceptdirectly.
(a) is quick. (b) or (c) produce usable RDF.
- (a) map it as a plain literal /
-
"@id": null: omit@idin the example/template when there is no value, instead of writingnull. Alternatively, have the template use an empty object and document that keys without a value should be left out. -
Classes as properties: remap to the properties suggested above. For
contributors, usedct:contributorfor now. The proper model separates the contribution (role, date, object; a qualified attribution) from the agent (person, with an IRI such as an ORCID). That could be done in a follow-up. -
ncit: change the prefix tohttp://purl.obolibrary.org/obo/(or mapnullableto the full IRI). Consider backporting to v2.0. -
Datatypes: use
xsd:datefor the embargo period, or change the example to full datetimes. Usexsd:gYearforpublicationYear. -
Prevent regressions: add a test that expands the example with the context and fails when a schema key is neither mapped nor on an explicit "JSON-only" allow-list, when a prefix IRI does not end in
/or#, or when a literal is ill-typed. That test would have caught items 1, 2, 5 and 6.
Out of scope here and worth a separate enhancement issue: many nodes end up as blank nodes (licenses, contributors, sources, columns, …) because they have no @id. This makes them impossible to link across datasets.
Context and Environment
- Version used: v2.1.0 (in development,
develop/feature-298-module-energy-system) - Operating system: Linux (WSL2)
- Environment setup and (python) version: Python 3.10.12, rdflib 7.6.0, PyLD 3.3.0; also checked with the JSON-LD Playground
Workflow checklist
- I am aware of the workflow in CONTRIBUTING.md
- Lingua principale
- Python
- Stelle
- 26
- Fork
- 4
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di OpenEnergyPlatform/oemetadata
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
OpenEnergyPlatform/oemetadata#328 ·
-
Develop AI tooling for usersAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
OpenEnergyPlatform/oemetadata#327 · 1 commento ·
-
Codecov workflow fails on every develop push: frictionless not installedForse già presa @jh-RLI l’ha presa 52 giorni fa. Apertapart: github :octocat: status: active 🚧 type: bug 🐛
OpenEnergyPlatform/oemetadata#325 · 1 assegnatario ·
-
The "@id" fields cause problems, rename to "id"Forse già presa @jh-RLI l’ha presa 52 giorni fa. Apertapart: backend 🧱 part: documentation 📖 priority: critical 🔥 status: active 🚧 type: enhancement ⚙️
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
OpenEnergyPlatform/oemetadata#320 · 10 commenti · 2 assegnatari ·
-
Revise and update testsForse già presa @jh-RLI l’ha presa 52 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
OpenEnergyPlatform/oemetadata#316 · 1 commento · 3 assegnatari ·
Tutte le issue di OpenEnergyPlatform/oemetadata
Issue simili
-
needs-triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
flashinfer-ai/flashinfer#9803 ·
I maintainer di solito rispondono entro 1 giorno
-
bug frontend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
oscarbol09/thesisforge#61 ·
-
api bug performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
oscarbol09/audiobard#159 ·
-
area:web p2 product:business triage:active type:bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 89/100
cuadrao-ai/argus#2328 ·
I maintainer di solito rispondono entro 1 giorno
-
bug frontend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
nikhilb2/simple_invoicing#907 ·