-
Notifications
You must be signed in to change notification settings - Fork 106
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
Ambiguous attributes should not be accepted ? #2403
Ambiguous attributes should not be accepted ? #2403
Comments
+1 from me |
Totally agree. I don't think that we should ever return an attribute there, but returning an empty SlotDefinition that just has the name is just confusing. I think that method should have if we wanted to preserve that behavior it seems like it should be in a |
@sneakers-the-rat I always got the impression that attributes were introduced to ease OOP developers into the LinkML/ontology paradigm as getting your head around the fact that a slot is a unique property that can be assigned to any class is complicated at first for us (OOP developers). Meaning that I imagined that attributes were transformed into slots but it's not exactly the case. I find it hard to justify separating attributes and slots, can someone clarify why attributes exist so we can be on the same page ? 😊 |
for me personally as someone who is an outside observer and was not part of 99.999% of the metamodel's creation, i think attributes make both semantic and syntactic sense - bridging OOP and other paradigms that might be more slot-forward is a genuine achievement and needs some glue between the impedance mismatches somewhere, and attributes are a pretty intuitive compromise among possible universes i think. Semantically, things exist, and things sometimes have properties that are private/unique to them. It makes sense to differentiate between "things that could be true of anything" and "things that can only apply to this thing." I think this is especially true when thinking about the practicalities of linked data, where being able to to incremental refinement is a pretty natural modeling desire, but without a shorthand for "refinement of this thing within the context of this other thing" we would be left in RDF-soup land having to parse a million gradations of a slot disembodied from context. In the world where i was dictator of linkml, i would make it canonical for all slots and attributes used within a class to have implicit uris of Syntactically i think it also makes sense to differentiate between the two cases above^ (unchanged/vs. changed) as well as from an authorship POV: I myself often switch between defining everything as slots and wanting to define things within the context of a class. I think it can be easy to underrate the lowered cognitive barriers for researchers/data-havers generally who aren't used to the cognitive inversion of "predicates first" in RDF universe, and having a syntactic olive branch back to OOP thinking that has a smooth transition into predicate-land is especially easy to underrate. Also syntactically, I have a known difference of preference between nominal/structural typing, where linkml is very much a nominally-typed system but i often want to edge towards structural typing (and am often wrong, as i am seeing while implementing rustgen how nice it is to not have to worry about structural type inference). So to me getting rid of the metamodel slot named classes:
MyClass:
slots:
pure_slot:
pure_slot_2:
attribute_or_modified_slot:
description: "idk i changed it somehow"
max_cardinality: 5 # always a good idea or equivalently classes:
MyClass:
slots:
- pure_slot
- pure_slot_2
- name: attribute_or_modified_slot
description: idk i changed it somehow
max_cardinality: 5 anyway, getting back to the issue at hand - i can be reductive sometimes in thinking that "schemaview is all that matters" as the thing that materializes schema, but i think here it would definitely be good to make schemaview be a bit of a semantic guide, differentiating between |
I'll add something to the FAQ about this. There are nuances here... |
@sneakers-the-rat about this sentence:
I had that understanding at the beginning but when I started using the JSON-LD context generator I realized that there wasn't any support for the concept of class scoped attributes as attributes are defined at a global level. That brought me to questioning how LinkML can stay generic/universal: should it stop the generation at the limits of the LinkML model or should the LinkML model evolve to support almost any intricacy of every output generator it proposes at the risk of having dead LinkML markup in certain cases ? |
Closes linkml/linkml#2403 Signed-off-by: Vincent Kelleher <[email protected]>
Closes linkml/linkml#2403 Signed-off-by: Vincent Kelleher <[email protected]>
Closes linkml/linkml#2403 Signed-off-by: Vincent Kelleher <[email protected]>
Closes linkml/linkml#2403 Signed-off-by: Vincent Kelleher <[email protected]>
Closes linkml/linkml#2403 Signed-off-by: Vincent Kelleher <[email protected]>
FYI I've raised this pull request 👉 linkml/linkml-runtime#352 |
Closes linkml/linkml#2403 Signed-off-by: Vincent Kelleher <[email protected]>
I've just found this same limitation and in looking at linkml/linkml-runtime#352 it seems the aim is to throw errors/warnings on redefinition, but not (yet?) implement scoped contexts? Generating scoped contexts (typically + It'd be great to see scoped contexts as an option ideally with Great work on LinkML regardless! |
@BigBlueHat would you be willing to open a new issue describing what you'd like the JSON-LD generator to do re: scoped contexts/what the application for that is in a bit more detail? Selfishly i'm a bit curious to see how these would be used and how that relates both to security and how we could use it for modeling attributes, but also i think it's a sufficiently different thing from this issue that it's worth standing on its own if it's a general need ppl are having :) |
@sneakers-the-rat definitely happy to share--as I continue to hunt for tooling to bridge the gaps and ease developer pain...and LinkML gets very close to that already! Here is a small(ish), but pretty typical example of the sort of context we create regularly: {
"@context": {
"@protected": true,
"image": {"@id": "https://schema.org/image", "@type": "@id"},
"BirthCertificateCredential": "https://examples.vcplayground.org/vocabs/birth-certificate-vc-v2#BirthCertificateCredential",
"BirthCertificate": {
"@id": "https://examples.vcplayground.org/vocabs/birth-certificate-vc-v2#BirthCertificate",
"@protected": true,
"@context": {
"identifier": "https://schema.org/identifier",
"children": "https://schema.org/children",
"parent": "https://schema.org/parent",
"certifyingAuthority": {
"@id": "https://examples.vcplayground.org/vocabs/birth-certificate-vc-v2#certifyingAuthority",
"@type": "@id"
},
"registrar": {
"@id": "https://examples.vcplayground.org/vocabs/birth-certificate-vc-v2#registrar",
"@type": "@id"
}
}
},
"Organization": {
"@id": "https://schema.org/Organization",
"@type": "@id"
},
"Person": {
"@id": "https://schema.org/Person",
"@type": "@id"
},
"givenName": "https://schema.org/givenName",
"additionalName": "https://schema.org/additionalName",
"familyName": "https://schema.org/familyName",
"gender": "https://schema.org/gender",
"birthDate": "https://schema.org/birthDate",
"birthPlace": "https://schema.org/birthPlace",
"roleName": "https://schema.org/roleName",
"jobTitle": "https://schema.org/jobTitle"
}
} That is currently used in https://github.com/credential-handler/vc-examples/blob/main/credentials/birth-certificate-vc-v2/credential.json The above credential's context is: "@context": [
"https://www.w3.org/ns/credentials/v2",
"https://examples.vcplayground.org/contexts/birth-certificate-vc-v2/v1rc1.json"
], You'll note in the above context that it is itself marked as The LinkML schemas already look pretty similar to that, but if I create something that matches the above context and then generate a context file...the generated one currently lacks all the key affordances I need. Key issues the generated context has are:
I also wasn't sure how best to do the mapping to external vocabulary terms--as you likely noticed we cherry pick terms from schema.org (or elsewhere) rather than including other (often massive vocabularies with terms way beyond the scope of what's needed). Relatedly, the resulting data documents all depend on LinkML seems very close to what I'd like to use to generate what amounts to a mix of context documentation (i.e. how to write the JSON data documents) and generate any additional vocabulary ephemera (for RDF devs who need/want it). That's the ideal blend I'm hoping to find. Sorry that was lengthy...and maybe a bit off topic. 😉 Happy to continue discussing! |
Describe the bug
In a case where a schema has ambiguous class attributes, the
SchemaView.get_slot(...)
method should throw an exception rather than returning the first attribute it can find with less details about it.Here is the test case I used to reproduce the issue :
In my case, the unexpected behaviour comes from this part of the code base which returns a
SlotDefinition
with its name only.I would imagine that attributes are made to bring ease of use but in the case above the user should be forced to define a slot instead through an exception.
What do you think ?
The text was updated successfully, but these errors were encountered: