-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validation issues #532
Comments
Hi @hongcui It looks like you are trying to validate JSON-LD instance data using LinkML. I think there are a couple of different things going on here
I can advise on you paths forward but it may help to know more about your overall requirements and strategy. Do you have requirements to use jsonld specifically? If you do, that's fine, linkml is appropriate, but there are things to be aware of. I fixed your JSON-LD by adding a context (in fact this context was generated by {
"@context": {
"isam": "http://resource.isamples.org/schema/",
"linkml": "https://w3id.org/linkml/",
"@vocab": "http://resource.isamples.org/schema/",
"relatedResource": {
"@type": "@id"
}
},
"@id": "metadata/21547/Car2PIRE_0334",
"relatedResource":[ {
"target": "ark:/21547/Cat2INDO106431.1",
"relationship": "derived"
}]
} Riot/jsonld playground generates what I think is your intended Turtle: @prefix isam: <http://resource.isamples.org/schema/> .
@prefix linkml: <https://w3id.org/linkml/> .
<file:///Users/cjm/repos/linkml/tests/test_issues/input/metadata/21547/Car2PIRE_0334>
isam:relatedResource _:b0 .
_:b0 isam:relationship "derived" ;
isam:target "ark:/21547/Cat2INDO106431.1" .
(I expect that is not the URI you expect for the sample record, but that can be addressed separately) Let me know if I am on the right track here... One thing to be aware of if you are using jsonld is that there are many possible ways to serialize the same RDF structure as JSON. See the list of qualifiers here: |
Here is a quick fix for you just now Use this as your jsonld: {
"@context": {
"isam": "http://resource.isamples.org/schema/",
"linkml": "https://w3id.org/linkml/",
"@vocab": "http://resource.isamples.org/schema/",
"relatedResource": {
"@type": "@id"
}
},
"@id": "metadata/21547/Car2PIRE_0334",
"@type": "isam:PhysicalSampleRecord",
"relatedResource":[ {
"target": "ark:/21547/Cat2INDO106431.1",
"relationship": "derived"
}]
} Convert this to turtle using a tool like riot: riot --output turtle linkml_issue_532_data.jsonld > linkml_issue_532_data.ttl you can see what the equivalent direct json (note: not the same structure as json-ld for the aforementioned reasons): linkml-convert --no-validate -s linkml_issue_532.yaml linkml_issue_532_data.ttl > linkml_issue_532_data.json {
"id": "file:///Users/cjm/repos/linkml/tests/test_issues/input/metadata/21547/Car2PIRE_0334",
"relatedResource": [
{
"target": "ark:/21547/Cat2INDO106431.1",
"relationship": "derived"
}
]
} This validates as expected:
Now I appreciate that splitting your workflow into these steps is annoying, it's necessary with the current release as we're lacking some convenience functions for recognizing jsonld in the command line wrapper. The next release will make this all easier and more intuitive. One final thing, for reasons I'll go into later, you should declare your multivalued slot So this schema should work: id: http://resource.isamples.org/schema/0.3
name: physicalSample
description: Schema for documenting physical samples
license: https://creativecommons.org/publicdomain/zero/1.0/
version: 20211022
prefixes:
linkml: https://w3id.org/linkml/
isam: http://resource.isamples.org/schema/
default_prefix: isam
imports:
- linkml:types
default_range: string
classes:
PhysicalSampleRecord:
description: This is a data object that is a digital representation of a physical
sample. It provides descriptive properties for any iSamples physical sample.
slots:
- id
- relatedResource
SampleRelation:
description: Object specifying relationships to other samples, (particularly between
subsamples and parent samples), or beteen samples and other related
information, e.g. publications using data from the sample or providing
background information to understand the sample.
slots:
- target
- relationship
slot_usage:
target:
required: true
relationship:
required: true
slots:
id:
identifier: true
relatedResource:
range: SampleRelation
description: link to related resource with relationship property to indicate
nature of connection. Target should be identifier for a resource.
multivalued: true
inlined_as_list: true ### necessary: see https://github.com/linkml/linkml/pull/488
relationship:
range: string
description: term to identify realationship between host sample and the sample
relation target. Should be controlled vocabulary (ScopedName). for now
start with string, 'derivedFrom'.
target:
range: string
description: identifier for the target resource in the relationship. Start
with string, should be Identifier object.
|
Made command line utils aware of json-ld as a format, and pass it accordingly. This removes the necessity to first convert from json-ld to rdf using an external tool, see also #532
Made command line utils aware of json-ld as a format, and pass it accordingly. This removes the necessity to first convert from json-ld to rdf using an external tool, see also #532
Thank you @cmungall |
If you upgrade to 1.1.15, the command line wrappers now recognize json-ld, so you can do this: linkml-validate -s linkml_issue_532.yaml linkml_issue_532_data.jsonld and this should validate correctly (you will still need to add the |
Hi @hongcui do you have further questions or shall we close this? |
Describe the bug
We expect the given json file (simp.json.txt) should be validated against the given yaml schema (simp.yaml.txt), but it did not. Not sure if this is a bug or something we did wrong.
To Reproduce
Steps to reproduce the behavior:
linkml-validate -s simp.yaml simp.json
Expected behavior
Expected no error.
Screenshots
![error](https://user-images.githubusercontent.com/831423/147001138-7b220cb7-fada-4746-b8f9-b9881d9709ca.jpg)
Desktop (if applicable, please complete the following information):
Additional context
Changing "required" to false in yaml would validate the instance (relatedResource), but why?
slot_usage: relationship: required: false target: required: false
The order in which properties are listed under slot_usage actually affects the reported error, why?
The text was updated successfully, but these errors were encountered: