Today, if a slot has the any_of constraint defined on it, refscan completely disregards the slot's range.
|
# Determine the slot's "effective" range, by taking into account its `any_of` constraints (if defined). |
|
# |
|
# Note: The `any_of` constraints constrain the slot's "effective" range beyond that described by the |
|
# induced slot definition's `range` attribute. `SchemaView` does not seem to provide the result |
|
# of applying those additional constraints, so we do it manually here (if any are defined). |
|
# |
|
# Reference: https://github.com/orgs/linkml/discussions/2101#discussion-6625646 |
|
# |
|
names_of_eligible_target_classes: list[str] = [] |
|
if "any_of" in slot_definition and len(slot_definition.any_of) > 0: # use the `any_of` attribute |
|
for slot_expression in slot_definition.any_of: |
|
if slot_expression.range in schema_view.all_classes(): |
|
own_and_descendant_class_names = schema_view.class_descendants(slot_expression.range) |
|
names_of_eligible_target_classes.extend(own_and_descendant_class_names) |
|
else: # use the `range` attribute |
|
if slot_definition.range not in schema_view.all_classes(): # if it's not a class name, abort |
|
continue |
|
else: |
|
# Get the specified class name and the names of all classes that inherit from it. |
|
own_and_descendant_class_names = schema_view.class_descendants(slot_definition.range) |
|
names_of_eligible_target_classes.extend(own_and_descendant_class_names) |
I implemented it that way because I was under the impression that the any_of constraint was used to further constrain the slot's range, beyond the constraints already placed on the slot by the slot's range. In other words, I was under the impression any_of would always be a more specific set than range (in which case, I wondered why a schema author would bother specifying a range on that slot in the first place).
I'm creating this ticket to represent the task of getting an authoritative answer to the following question:
- Is ignoring the
range in the presence of any_of, consistent with how people proficient with LinkML would interpret a LinkML schema?
Related (upstream): linkml/linkml#2103
Today, if a slot has the
any_ofconstraint defined on it,refscancompletely disregards the slot'srange.refscan/refscan/refscan.py
Lines 168 to 188 in d7d0edd
I implemented it that way because I was under the impression that the
any_ofconstraint was used to further constrain the slot's range, beyond the constraints already placed on the slot by the slot'srange. In other words, I was under the impressionany_ofwould always be a more specific set thanrange(in which case, I wondered why a schema author would bother specifying arangeon that slot in the first place).I'm creating this ticket to represent the task of getting an authoritative answer to the following question:
rangein the presence ofany_of, consistent with how people proficient with LinkML would interpret a LinkML schema?Related (upstream): linkml/linkml#2103