You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an abstract class (Abstract) in which an attribute (custom) has the type of a custom class (Custom). In a child class of the abstract class (Implementation), I want to define the type of an attribute (attr3) in the custom class. However, I get an error when I try to validate. Here's the code (InheritanceTest.yaml):
id: https://example.org/InheritanceTest
name: InheritanceTest
description: |-
A test for how inheritance works in LinkML.
prefixes:
linkml: https://w3id.org/linkml/
imports:
- linkml:types
default_range: string
classes:
Custom:
abstract: true
attributes:
attr3:
Abstract:
abstract: true
attributes:
attr1:
attr2:
custom:
range: Custom
CustomImpl:
is_a: Custom
slot_usage:
attr3: float
Implementation:
tree_root: true
is_a: Abstract
slot_usage:
attr1:
range: integer
custom:
range: CustomImpl
Here's the instance I try to validate (InheritanceInstance.yaml):
attr1: 1
attr2: world
custom:
attr3: 3.14
I validate with linkml-validate -s InheritanceTest.yaml InheritanceInstance.yaml. I get the error [ERROR] [InheritanceInstance.yaml/0] 3.14 is not of type 'string' in /custom/att3. Is what I'm trying to do possible in LinkML?
A related question. Is there a way to identify objects with prefixes in their names? For example, the file above imports linkml:types. Can I identify the types using a C++-like notation such as linkml::integer. Here's my use case: I'd like to be able to use the same class name in 2 different schema files and import 1 to use in the other. To distinguish them, it'd be useful to attach a prefix or a namespace to the imported class.
The text was updated successfully, but these errors were encountered:
mszulcz-mitre
added
the
bug
Something that should work but isn't, with an example and a test case.
label
Apr 1, 2024
I have an abstract class (
Abstract
) in which an attribute (custom
) has the type of a custom class (Custom
). In a child class of the abstract class (Implementation
), I want to define the type of an attribute (attr3
) in the custom class. However, I get an error when I try to validate. Here's the code (InheritanceTest.yaml
):Here's the instance I try to validate (
InheritanceInstance.yaml
):I validate with
linkml-validate -s InheritanceTest.yaml InheritanceInstance.yaml
. I get the error[ERROR] [InheritanceInstance.yaml/0] 3.14 is not of type 'string' in /custom/att3
. Is what I'm trying to do possible in LinkML?A related question. Is there a way to identify objects with prefixes in their names? For example, the file above imports
linkml:types
. Can I identify the types using a C++-like notation such aslinkml::integer
. Here's my use case: I'd like to be able to use the same class name in 2 different schema files and import 1 to use in the other. To distinguish them, it'd be useful to attach a prefix or a namespace to the imported class.The text was updated successfully, but these errors were encountered: