How to specify the LinkML equivalent of Union[List[int], str]
?
#2154
Replies: 5 comments 11 replies
-
Thanks, yes in fact in addition to monotonicity issues, there is an arbitrary restriction that |
Beta Was this translation helpful? Give feedback.
-
This, like arrays, makes me wonder if the types:
intlist:
is_a: integer
multivalued: true
slots:
x:
any_of:
- range: string
- range: intlist (Pseudocode bc I dont remember the type syntax offhand) |
Beta Was this translation helpful? Give feedback.
-
I agree this is more informative from a programming language perspective,
rather than a W3c/XSD/RDF perspective.
But forgetting the original question for the moment and taking a simpler
case of a list of ints;
we *could* allow multivalued in types; this would make the following
equivalent
```
types:
# INTLIST=List[int]
intlist:
typeof: integer
multivalued: true
slots:
x: ## x : INTLIST, or x: List[int]
range: intlist
```
and
```
slots:
x: ## x : List[int]
range: integer
multivalued: true
```
Which is fine from a programming language perspective, we're used to lots
of different ways to say the same things - I wonder if this adds too much
cognitive
overhead for a modeling language however (worth taking up to its own
top-level discussion?)
…On Sat, Jun 15, 2024 at 4:59 PM Jonny Saunders ***@***.***> wrote:
This, like arrays, makes me wonder if the types system is underused. It
makes sense to me to be able to declare a type that is a list of ints,
since it doesnt have semantic content like a slot but is just a type. so
then one would do something like
types:
intlist:
is_a: integer
multivalued: true
slots:
x:
any_of:
- range: string
- range: intlist
(Pseudocode bc I dont remember the type syntax offhand)
—
Reply to this email directly, view it on GitHub
<#2154 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMMOMZN7RPN4XW6G4K3E3ZHTIODAVCNFSM6AAAAABJC6F4X2VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TOOBUGEYDO>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Another example of the general problem I am facing is to express |
Beta Was this translation helpful? Give feedback.
-
btw, not responsive to the problem directly, and it would definitely be a hack, but at least with the pydantic generator you can get this kind of behavior like i said, definitely a hack, but might be a workaround pending an official fix |
Beta Was this translation helpful? Give feedback.
-
Consider the following Pydantic model.
I want to specify
Foo
as a class andx
as a slot in a LinkML schema, but I have trouble defining the slot for representingx
. In particular, I couldn't find a way to express the constraints imposed by theUnion[List[int], str]
type annotation in the Pydantic model in LinkML. I am aware that I can useany_of
to express a constraint on the range of a slot that allows one of a set of possible types. However, the use ofany_of
doesn't seem to allow "re-specification" of themultivalued
metamodel slot sinceany_of
has a range ofExpression
(and re-specification ofmultivalued
doesn't make sense because of monotonicity in LinkML schema).How I can accomplish what I want in LinkML?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions