mapping-commons / sssom-py

Python toolkit for SSSOM mapping format
https://mapping-commons.github.io/sssom-py/index.html#
MIT License
49 stars 12 forks source link

`@context` missing the type definitions in version 0.4.0 #477

Closed anitacaron closed 9 months ago

anitacaron commented 9 months ago

The new release changed the @context when calling to_json, now only returning prefixes, instead of a complete definition of types in JSON-LD.

Expected @context returned in version 0.3.41

Click to view context version 0.3.41

```json { "@context":{ "dcterms":"http://purl.org/dc/terms/", "linkml":"https://w3id.org/linkml/", "oboInOwl":"http://www.geneontology.org/formats/oboInOwl#", "owl":"http://www.w3.org/2002/07/owl#", "pav":"http://purl.org/pav/", "prov":"http://www.w3.org/ns/prov#", "rdf":"http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs":"http://www.w3.org/2000/01/rdf-schema#", "semapv":"https://w3id.org/semapv/vocab/", "skos":"http://www.w3.org/2004/02/skos/core#", "sssom":"https://w3id.org/sssom/", "@vocab":"https://w3id.org/sssom/", "author_id":{ "@type":"@id", "@id":"pav:authoredBy" }, "comment":{ "@id":"rdfs:comment" }, "confidence":{ "@type":"xsd:double" }, "creator_id":{ "@type":"@id", "@id":"dcterms:creator" }, "curation_rule":{ "@type":"@id" }, "documentation":{ "@type":"@id" }, "homepage":{ "@type":"@id" }, "imports":{ "@type":"@id" }, "issue_tracker":{ "@type":"@id" }, "issue_tracker_item":{ "@type":"@id" }, "last_updated":{ "@type":"xsd:date" }, "license":{ "@type":"@id", "@id":"dcterms:license" }, "mapping_cardinality":{ "@context":{ "@vocab":"@null", "text":"skos:notation", "description":"skos:prefLabel", "meaning":"@id" } }, "mapping_date":{ "@type":"xsd:date", "@id":"pav:authoredOn" }, "mapping_justification":{ "@type":"@id" }, "mapping_provider":{ "@type":"@id" }, "mapping_registry_id":{ "@type":"@id" }, "mapping_set_description":{ "@id":"dcterms:description" }, "mapping_set_id":{ "@type":"@id" }, "mapping_set_references":{ "@type":"@id" }, "mapping_set_source":{ "@type":"@id", "@id":"prov:wasDerivedFrom" }, "mapping_set_title":{ "@id":"dcterms:title" }, "mapping_set_version":{ "@id":"owl:versionInfo" }, "mapping_source":{ "@type":"@id" }, "mappings":{ "@type":"@id" }, "mirror_from":{ "@type":"@id" }, "object_id":{ "@type":"@id", "@id":"owl:annotatedTarget" }, "object_match_field":{ "@type":"@id" }, "object_preprocessing":{ "@type":"@id" }, "object_source":{ "@type":"@id" }, "object_type":{ "@context":{ "@vocab":"@null", "text":"skos:notation", "description":"skos:prefLabel", "meaning":"@id" } }, "predicate_id":{ "@type":"@id", "@id":"owl:annotatedProperty" }, "predicate_modifier":{ "@context":{ "@vocab":"@null", "text":"skos:notation", "description":"skos:prefLabel", "meaning":"@id" } }, "predicate_type":{ "@context":{ "@vocab":"@null", "text":"skos:notation", "description":"skos:prefLabel", "meaning":"@id" } }, "publication_date":{ "@type":"xsd:date", "@id":"dcterms:created" }, "registry_confidence":{ "@type":"xsd:double" }, "reviewer_id":{ "@type":"@id" }, "see_also":{ "@id":"rdfs:seeAlso" }, "semantic_similarity_score":{ "@type":"xsd:double" }, "subject_id":{ "@type":"@id", "@id":"owl:annotatedSource" }, "subject_match_field":{ "@type":"@id" }, "subject_preprocessing":{ "@type":"@id" }, "subject_source":{ "@type":"@id" }, "subject_type":{ "@context":{ "@vocab":"@null", "text":"skos:notation", "description":"skos:prefLabel", "meaning":"@id" } }, "Mapping":{ "@id":"owl:Axiom" }, "HP":"http://purl.obolibrary.org/obo/HP_", "MP":"http://purl.obolibrary.org/obo/MP_", "orcid":"https://orcid.org/", "obo":"http://purl.obolibrary.org/obo/", } } ```

Click to view context in version 0.4.0

```json { "@context":{ "owl":"http://www.w3.org/2002/07/owl#", "rdf":"http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs":"http://www.w3.org/2000/01/rdf-schema#", "semapv":"https://w3id.org/semapv/vocab/", "skos":"http://www.w3.org/2004/02/skos/core#", "sssom":"https://w3id.org/sssom/", "HP":"http://purl.obolibrary.org/obo/HP_", "MP":"http://purl.obolibrary.org/obo/MP_", "obo":"http://purl.obolibrary.org/obo/", "orcid":"https://orcid.org/", } } ```

Is there another method to have the complete @context for JSON-LD file?

matentzn commented 9 months ago

@anitacaron thank you for the report; there is no test for the JSON serialisation other than checking that the mappings are present.

@cthoyt I missed this during a review of one of your PRs:

https://github.com/mapping-commons/sssom-py/commit/c31f44e4efc34301f3f12ccd0d14b57e483418f3

We need to undo this change urgently, as this breaks the JSON format; I started doing this here https://github.com/mapping-commons/sssom-py/pull/479

The problem is that the jsonld base from which we originally created the context does not exist anymore. Which means I will have to revive quite a bit of code that was previously removed unfortunately..

How I missed this I cant understand, another reason for small PRs moving forward. Sorry about that @anitacaron.

@cthoyt If I don't hear from you I will roll back the jsonld context related changes.

@hrshdhgd can you find me a valid JSON version of any linkml converted file format? I just want to look how the json files look like..

cthoyt commented 9 months ago

looking into this...

more context about what code you're running would be helpful

cthoyt commented 9 months ago

so is the issue that the get_jsonld_context function loaded up some LinkML artifact that had extra stuff besides the prefix map that we need to retain?

matentzn commented 9 months ago

This is the consequence of running sssom convert --format json - any example would do.

so is the issue that the get_jsonld_context function loaded up some LinkML artifact that had extra stuff besides the prefix map that we need to retain?

Yes.

cthoyt commented 9 months ago

@anitacaron i updated Nico's PR in https://github.com/mapping-commons/sssom-py/pull/479, it should solve the problem now with minimal changes, we just need to add a unit test to it.