Skip to content
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

[wip] linkml version #455

Closed
wants to merge 4 commits into from
Closed

Conversation

djarecka
Copy link
Member

@djarecka djarecka commented Feb 2, 2024

This is the linkml model with semi-automatically generated shacl, context and pydantic. I will generate a separate PR with full scripts on how to generate the formats, but just want to show the current state and discuss some issues that I still have.

After I understood the process more the additional changes to the context and shacl files after linkml generators are not as big:
SHACL:

  • sh:class I have to either change to sh:datatype or sh:node
  • I'm removing some sh:nodeKind sh:BlankNode (not sure if all were causing problems but some did)
  • I'm also using specific branch from linkml, that is not merged yet
    I will try to talk about the issues next week during the hackathon

CONTEXT:

  • adding "@container": "@language" in several places to be able to sue this shorter syntax for langString

EXAMPLES:
There are tiny changes to the examples that are required to pass the shack validation with reproschema (i.e. reproschema -l DEBUG validate --shapefile ...):

  • fix the bug with valueRequired
  • imageUrl to image (i believe i was told that imageUrl is not used anywhere else)

Issues that still have to be discussed:

  • I could not find a way to represent ui the same way as it was, I've decided for now to separate another class UI, since this allow me to pass shacl validation. I've started conversation with the linkml community here: Add equivalent to pydantic AliasPaths or jsonld @nest to allow for nesting intermediate structures linkml/linkml#1846

  • I'm still not completely happy about the langString. The shacl validation work after I added "@container": "@language" to the context, but I'm not sure what should be the best approach for validation with pydantic. My first approach is to try to add text and lang field to LangString and to convert the format when reading from:

{
        "en": "Little interest or pleasure in doing things",
        "es": "Poco interés o placer en hacer cosas"
    },

to [{"lang": "en", "text": "Little interest or pleasure in doing things"}, {"lang": "es", "text": "Poco interés o placer en hacer cosas"}]
Would this be ok?

  • could you tell me why we sometimes use image with specific type? Could we just say that image is ether str (or urlor theImageObjectfromschema`?
    "image": {
        "@type": "ImageObject",
        "contentUrl": "http://example.com/sample-image.jpg"
    }

@djarecka djarecka requested a review from satra February 2, 2024 18:35
Copy link
Contributor

@satra satra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing some sh:nodeKind sh:BlankNode (not sure if all were causing problems but some did)

some are blank nodes and were intended to be. for example additionalProperties adds/replaces properties of an object, hence the object is in isAbout but the information container is a blank node. we can replace it with a uuid, but it is already contextualized within the graph of activity/protocol.

imageUrl to image (i believe i was told that imageUrl is not used anywhere else)
could we just say that image is ether str (or urlor theImageObjectfromschema`?

i left a comment about this that as far as i know jsonld doesn't/didn't allow multiple target types. also, i think we use imageURL in some of our lab protocols and/or the library.

I'm still not completely happy about the langString.

would be a good one to discuss with linkml community. however, the whole point was to have the jsonld representation be compact, hence we didn't want the more complex form. once we build tools so that humans don't have to edit json, i'd be fine with the change. but adding boilerplate was exactly what we were trying to avoid.

Comment on lines 24 to 27
title: addProperties
comments:
- An array of objects to describe the various properties added to assessments
and fields.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't see the comments in pydantic which will make it hard for people to use the code without referring to this document. i would suggest using description instead of comments throughout this schema.

Comment on lines 47 to 48
any_of:
- range: Thing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplify to range when not targeting Union.

Comment on lines 124 to 130
image:
title: image
comments:
- An image of the item. This can be a <a class="localLink" href="http://schema.org/URL">URL</a>
or a fully described <a class="localLink" href="http://schema.org/ImageObject">ImageObject</a>.
slot_uri: schema:image
range: uriorcurie
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a difference between this and imageURL in the current schema. image targets an object (a node in a graph), and imageURL targets a content url directly. since jsonld does not have (as far as i know) a way of representing multitargets, we created this separation.

as a result here it should at least be any_of, if we are to simplify to just an image. for the moment perhaps we can also add imageURL and not change the schema for this. i would like to minimize updating the library when we make this transition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you would like to add imageURL as a separate slot?

For the future, I understand you would like to have something like this?

image:
  any_of:
  - range: uriocurie
  - range: ImageObject

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right now there is som inconsistency (perhaps partially introduced by myself), in a way how different media are in the model, see for comparison audio and video. I've introduced videoObject since it was used in one of the example.

I could try to more consistent, or wait with this for later

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you would like to add imageURL as a separate slot?

yes

For the future, I understand you would like to have something like this?

yes

re: audio and video

audio/video/image in schema.org are all similar in that they support multiple targets. however, audio/video don't have a URL option while image does. so for now i would file an issue if that is not handled in the current schema.

@djarecka
Copy link
Member Author

djarecka commented Feb 3, 2024

I'm still not completely happy about the langString.

would be a good one to discuss with linkml community. however, the whole point was to have the jsonld representation be compact, hence we didn't want the more complex form. once we build tools so that humans don't have to edit json, i'd be fine with the change. but adding boilerplate was exactly what we were trying to avoid.

yes, happy to discuss it next week.

For now we can still keep the current jsonld format, but the python function that reads the jsonld would have to be doing the transformation.
I also have to add something to langString in the pydantic version, looks like linkml just creates an empty class

… and adding @language:en to context; bringing back imageUrl; splitting UI class to multiple classes for UI for Activity, Field and Protocol
@djarecka
Copy link
Member Author

@satra, here are examples of n-triples from the examples, I think they look good, but please take a look:

  • for item.jsonld
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.org/audio> _:c14n2 .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.org/description> "Q1 of example 1"@en .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.org/image> _:c14n3 .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.org/question> "Little interest or pleasure in doing things"@en .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.org/question> "Poco interés o placer en hacer cosas"@es .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.org/schemaVersion> "1.0.0-rc4"@en .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.org/version> "0.0.1"@en .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.repronim.org/additionalNotesObj> _:c14n0 .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.repronim.org/additionalNotesObj> _:c14n1 .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.repronim.org/responseOptions> _:c14n4 .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://schema.repronim.org/ui> _:c14n5 .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.repronim.org/Field> .
<http://localhost:8000/examples/activities/items/item1.jsonld> <http://www.w3.org/2004/02/skos/core#prefLabel> "item1"@en .
_:c14n0 <http://schema.repronim.org/column> "notes" .
_:c14n0 <http://schema.repronim.org/source> "redcap" .
_:c14n0 <http://schema.repronim.org/value> <http://example.com/iri-example> .
_:c14n1 <http://schema.repronim.org/column> "notes" .
_:c14n1 <http://schema.repronim.org/source> "redcap" .
_:c14n1 <http://schema.repronim.org/value> "some extra note"@en .
_:c14n2 <http://schema.org/contentUrl> <http://media.freesound.org/sample-file.mp4> .
_:c14n2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/example/AudioObject> .
_:c14n3 <http://schema.org/contentUrl> <http://example.com/sample-image.jpg> .
_:c14n3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/example/ImageObject> .
_:c14n4 <http://schema.org/maxValue> "3"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:c14n4 <http://schema.org/minValue> "0"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:c14n4 <http://schema.repronim.org/choices> _:c14n6 .
_:c14n4 <http://schema.repronim.org/choices> _:c14n7 .
_:c14n4 <http://schema.repronim.org/choices> _:c14n8 .
_:c14n4 <http://schema.repronim.org/choices> _:c14n9 .
_:c14n4 <http://schema.repronim.org/multipleChoice> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> .
_:c14n4 <http://schema.repronim.org/valueType> <http://www.w3.org/2001/XMLSchema#integer> .
_:c14n5 <http://schema.repronim.org/inputType> "radio" .
_:c14n6 <http://schema.org/name> "More than half the days"@en .
_:c14n6 <http://schema.org/name> "Más de la mitad de los días"@es .
_:c14n6 <http://schema.repronim.org/value> <http://example.com/choice3> .
_:c14n7 <http://schema.org/name> "Not at all"@en .
_:c14n7 <http://schema.org/name> "Para nada"@es .
_:c14n7 <http://schema.repronim.org/value> "0"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:c14n8 <http://schema.org/name> "Several days"@en .
_:c14n8 <http://schema.org/name> "Varios días"@es .
_:c14n8 <http://schema.repronim.org/value> "a"@en .
_:c14n9 <http://schema.org/name> "Casi todos los días"@es .
_:c14n9 <http://schema.org/name> "Nearly everyday"@en .
_:c14n9 <http://schema.repronim.org/value> "choice-with-lang"@en .
  • for protocol1.jsonld
<http://example.com/sample-readme.md> <http://schema.org/inLanguage> "en"@en .
<http://localhost:8000/examples/protocols/protocol1.jsonld> <http://schema.org/description> "example Protocol"@en .
<http://localhost:8000/examples/protocols/protocol1.jsonld> <http://schema.org/schemaVersion> "1.0.0-rc4"@en .
<http://localhost:8000/examples/protocols/protocol1.jsonld> <http://schema.org/version> "0.0.1"@en .
<http://localhost:8000/examples/protocols/protocol1.jsonld> <http://schema.repronim.org/landingPage> <http://example.com/sample-readme.md> .
<http://localhost:8000/examples/protocols/protocol1.jsonld> <http://schema.repronim.org/messages> _:c14n0 .
<http://localhost:8000/examples/protocols/protocol1.jsonld> <http://schema.repronim.org/ui> _:c14n1 .
<http://localhost:8000/examples/protocols/protocol1.jsonld> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.repronim.org/Protocol> .
<http://localhost:8000/examples/protocols/protocol1.jsonld> <http://www.w3.org/2004/02/skos/core#prefLabel> "Protocol1"@en .
<http://localhost:8000/examples/protocols/protocol1.jsonld> <http://www.w3.org/2004/02/skos/core#prefLabel> "Protocol1_es"@es .
_:c14n0 <http://schema.repronim.org/jsExpression> "item1 > 0"@en .
_:c14n0 <http://schema.repronim.org/message> "Test message: Triggered when item1 value is greater than 0"@en .
_:c14n1 <http://schema.repronim.org/addProperties> _:c14n2 .
_:c14n1 <http://schema.repronim.org/allow> <http://schema.repronim.org/AllowExport> .
_:c14n1 <http://schema.repronim.org/allow> <http://schema.repronim.org/AutoAdvance> .
_:c14n1 <http://schema.repronim.org/allow> <http://schema.repronim.org/DisableBack> .
_:c14n1 <http://schema.repronim.org/order> <http://localhost:8000/examples/activities/activity1.jsonld> .
_:c14n1 <http://schema.repronim.org/shuffle> "false"^^<http://www.w3.org/2001/XMLSchema#boolean> .
_:c14n2 <http://schema.repronim.org/isAbout> <http://localhost:8000/examples/activities/activity1.jsonld> .
_:c14n2 <http://schema.repronim.org/isVis> "true"^^<http://www.w3.org/2001/XMLSchema#boolean> .
_:c14n2 <http://schema.repronim.org/limit> "P1W/2020-08-01T13:00:00Z"@en .
_:c14n2 <http://schema.repronim.org/randomMaxDelay> "PT12H"@en .
_:c14n2 <http://schema.repronim.org/schedule> "R5/2008-01-01T13:00:00Z/P1Y2M10DT2H30M"@en .
_:c14n2 <http://schema.repronim.org/variableName> "activity1"@en .
_:c14n2 <http://www.w3.org/2004/02/skos/core#prefLabel> "Screening"@en .
_:c14n2 <http://www.w3.org/2004/02/skos/core#prefLabel> "Screening_es"@es .

@djarecka
Copy link
Member Author

and difference in the n-triples:

  • for item1:
7c7
<     sdo:audio [ a <http://example.org/example/AudioObject> ;
---
>     sdo:audio [ a sdo:AudioObject ;
10c10
<     sdo:image [ a <http://example.org/example/ImageObject> ;
---
>     sdo:image [ a <http://localhost:8000/examples/activities/items/ImageObject> ;
21a22
>     rs:inputType "radio" ;
26a28,30
>                 [ sdo:name "More than half the days"@en,
>                         "Más de la mitad de los días"@es ;
>                     rs:value <http://example.com/choice3> ],
32,36c36,37
<                     rs:value "a"@en ],
<                 [ sdo:name "More than half the days"@en,
<                         "Más de la mitad de los días"@es ;
<                     rs:value <http://example.com/choice3> ] ;
<             rs:multipleChoice false ;
---
>                     rs:value "a"@en ] ;
>             rs:multipleChoice "false"^^sdo:Boolean ;
38d38
<     rs:ui [ rs:inputType "radio" ] ;

  • for protocol
0a1
> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
9a11,21
>     rs:addProperties [ rs:isAbout <http://localhost:8000/examples/activities/activity1.jsonld> ;
>             rs:isVis true ;
>             rs:limit "P1W/2020-08-01T13:00:00Z"@en ;
>             rs:randomMaxDelay "PT12H"@en ;
>             rs:schedule "R5/2008-01-01T13:00:00Z/P1Y2M10DT2H30M"@en ;
>             rs:variableName "activity1"@en ;
>             skos:prefLabel "Screening"@en,
>                 "Screening_es"@es ] ;
>     rs:allow rs:AllowExport,
>         rs:AutoAdvance,
>         rs:DisableBack ;
13,25c25,26
<     rs:ui [ rs:addProperties [ rs:isAbout <http://localhost:8000/examples/activities/activity1.jsonld> ;
<                     rs:isVis true ;
<                     rs:limit "P1W/2020-08-01T13:00:00Z"@en ;
<                     rs:randomMaxDelay "PT12H"@en ;
<                     rs:schedule "R5/2008-01-01T13:00:00Z/P1Y2M10DT2H30M"@en ;
<                     rs:variableName "activity1"@en ;
<                     skos:prefLabel "Screening"@en,
<                         "Screening_es"@es ] ;
<             rs:allow rs:AllowExport,
<                 rs:AutoAdvance,
<                 rs:DisableBack ;
<             rs:order <http://localhost:8000/examples/activities/activity1.jsonld> ;
<             rs:shuffle false ] ;
---
>     rs:order ( <http://localhost:8000/examples/activities/activity1.jsonld> ) ;
>     rs:shuffle "false"^^sdo:Boolean ;

@djarecka
Copy link
Member Author

it moved to #456

@djarecka djarecka closed this Jun 14, 2024
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