linkml / schemasheets

Structure your data in a FAIR way using google sheets or TSVs. These are then converted to LinkML, and from there other formats
https://linkml.io/schemasheets/
43 stars 5 forks source link

model examples #23

Closed turbomam closed 2 years ago

turbomam commented 2 years ago

I will be editing schemasheets/schemamaker.py, based on the Annotations code block around line 303

was:

clone from scheammaker ~ 303

cmungall commented 2 years ago

this is a bit cryptic!

turbomam commented 2 years ago

I don't know what problem I was having with examples in the past. schemasheets seems to handle single and multiple, delimited examples fine now. I did not add any new code, just working examples.

turbomam commented 2 years ago

Ahh... I was getting an error when creating a SchemaView from a YAML file, created by schemasheets, from a TSV with an examples column

From sheets_and_friends/sheets_and_friends/shuttle.py:

Traceback (most recent call last): File "", line 1, in File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/click/core.py", line 1128, in call return self.main(args, kwargs) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/click/core.py", line 754, in invoke return __callback(args, kwargs) File "/home/mark/gitrepos/sheets_and_friends/sheets_and_friends/shuttle.py", line 42, in do_shuttle shuttle.prepare_dest_schema() File "/home/mark/gitrepos/sheets_and_friends/sheets_and_friends/shuttle.py", line 75, in prepare_dest_schema current_view = SchemaView(self.recipient_model_fp) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/utils/schemaview.py", line 102, in init schema = load_schema_wrap(schema) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/utils/schemaview.py", line 56, in load_schema_wrap schema = yaml_loader.load(path, target_class=SchemaDefinition, kwargs) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/loaders/loader_root.py", line 85, in load results = self.load_any(*args, kwargs) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/loaders/yaml_loader.py", line 25, in load_any return self.load_source(source, loader, target_class, accept_header="text/yaml, application/yaml;q=0.9", File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/loaders/loader_root.py", line 66, in load_source return target_class(data_as_dict) File "", line 50, in init File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/meta.py", line 402, in post_init__ self._normalize_inlined_as_dict(slot_name="classes", slot_type=ClassDefinition, key_name="name", keyed=True) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 100, in _normalize_inlined_as_dict self._normalize_inlined(slot_name, slot_type, key_name, keyed, False) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 200, in _normalize_inlined form_1({k: v}) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 153, in form_1 order_up(key, slot_type(**as_dict(raw_obj))) File "", line 59, in init File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/meta.py", line 1348, in post_init self._normalize_inlined_as_dict(slot_name="slot_usage", slot_type=SlotDefinition, key_name="name", keyed=True) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 100, in _normalize_inlined_as_dict self._normalize_inlined(slot_name, slot_type, key_name, keyed, False) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 200, in _normalize_inlined form_1({k: v}) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 153, in form_1 order_up(key, slot_type(**as_dict(raw_obj))) File "", line 84, in init File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/meta.py", line 1221, in post_init super().post_init(**kwargs) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/meta.py", line 638, in post_init super().post_init(**kwargs) File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/meta.py", line 297, in post_init__ self.examples = [v if isinstance(v, Example) else Example(as_dict(v)) for v in self.examples] File "/home/mark/.cache/pypoetry/virtualenvs/sheets-and-friends-eIKNSve2-py3.9/lib/python3.9/site-packages/linkml_runtime/linkml_model/meta.py", line 297, in self.examples = [v if isinstance(v, Example) else Example(as_dict(v)) for v in self.examples] TypeError: linkml_runtime.linkml_model.meta.Example() argument after ** must be a mapping, not extended_str

turbomam commented 2 years ago

closed by #24

turbomam commented 2 years ago

Could improve PR with a test instead of an example in the Makefile