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

is_a vs mixins #5

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ classes:
is_a: Checklist
mixin: true
slots:
- conflicting
- adapters
- alt
- annot
Expand Down Expand Up @@ -127,6 +128,8 @@ classes:
- tax_class
- temp
slot_usage:
conflicting:
pattern: ^[a-zA-Z]+$
adapters:
recommended: true
alt:
Expand Down Expand Up @@ -193,6 +196,7 @@ classes:
title: soil
is_a: Extension
slots:
- conflicting
- agrochem_addition
- al_sat
- al_sat_meth
Expand Down Expand Up @@ -251,6 +255,8 @@ classes:
- water_cont_soil_meth
- water_content
slot_usage:
conflicting:
pattern: ^[0-9]+$
crop_rotation:
string_serialization: '{boolean};{Rn/start_time/end_time/duration}'
depth:
Expand Down Expand Up @@ -306,6 +312,9 @@ slots:
inlined: true
inlined_as_list: true

conflicting:
description: intentionally set to incompatible states between a Checklist and an Extension

adapters:
annotations:
Expected_value: adapter A and B sequence
Expand Down
8 changes: 8 additions & 0 deletions src/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from pathlib import Path

# from ..mixs_missing_value_sandbox import *

THIS_PATH = Path(__file__).parent

SCHEMA_DIRECTORY = THIS_PATH.parent / "mixs_missing_value_sandbox" / "schema"
MAIN_SCHEMA_PATH = SCHEMA_DIRECTORY / "mixs_missing_value_sandbox.yaml"
50 changes: 50 additions & 0 deletions src/scripts/mims_and_soil_slots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import pprint
from pathlib import Path

from linkml_runtime import SchemaView
from linkml_runtime.dumpers import yaml_dumper

# from ..mixs_missing_value_sandbox import *

THIS_PATH = Path(__file__).parent

SCHEMA_DIRECTORY = THIS_PATH.parent / "mixs_missing_value_sandbox" / "schema"
MAIN_SCHEMA_PATH = SCHEMA_DIRECTORY / "mixs_missing_value_sandbox.yaml"

schema_view = SchemaView(MAIN_SCHEMA_PATH)

current_checklist = "Mims"
current_extension = "Soil"

checklist_slots = schema_view.get_class(current_checklist).slots

extension_slots = schema_view.get_class(current_extension).slots

checklist_extension_slots = set(checklist_slots).intersection(set(extension_slots))
checklist_extension_slots = list(checklist_extension_slots)
checklist_extension_slots.sort()

checklist_usages = schema_view.get_class(current_checklist).slot_usage
extension_usages = schema_view.get_class(current_extension).slot_usage
for slot in checklist_extension_slots:
global_definition = schema_view.get_slot(slot)
checklist_modifies = slot in checklist_usages
extension_modifies = slot in extension_usages
if checklist_modifies or extension_modifies:
if checklist_modifies:
print(f"{slot} slot's usage in {current_checklist}:")
print(yaml_dumper.dumps(checklist_usages[slot]))
else:
print(f"{current_checklist} uses the global definition for {slot}")
# print(yaml_dumper.dumps(global_definition))
if extension_modifies:
print(f"{slot} slot's usage in {current_extension}:")
print(yaml_dumper.dumps(extension_usages[slot]))
else:
print(f"{current_extension} uses the global definition for {slot}")
# print(yaml_dumper.dumps(global_definition))
print(f"Induced slot {slot} in {current_checklist}{current_extension}\n")
print(yaml_dumper.dumps(schema_view.induced_slot(slot, f"{current_checklist}{current_extension}")))
else:
print(f"{slot} not modified by {current_checklist} or {current_extension}\n")
print("----")
Loading