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/
42 stars 5 forks source link

Option to not write "from_schema" slots in sheets2linkml rendered yaml #42

Closed putmantime closed 1 year ago

putmantime commented 2 years ago

It doesn't appear to be possible to silence the "from_schema" in sheets2linkml command. It is very redundant and causes the linkml yaml to balloon. It would be great to have a parameter where this could be toggled on or off defending on how suitable it is for the given model.

Example:


  laboratory_procedure:
    name: laboratory_procedure
    from_schema: https://w3id.org/include_portal_v1_schema
  parent_sample_id:
    name: parent_sample_id
    from_schema: https://w3id.org/include_portal_v1_schema
  parent_sample_type:
    name: parent_sample_type
    from_schema: https://w3id.org/include_portal_v1_schema
  sample_availability:
    name: sample_availability
    from_schema: https://w3id.org/include_portal_v1_schema
  sample_id:
    name: sample_id
    from_schema: https://w3id.org/include_portal_v1_schema
  sample_type:
    name: sample_type
    from_schema: https://w3id.org/include_portal_v1_schema
  volume:
    name: volume
    from_schema: https://w3id.org/include_portal_v1_schema
  volume_unit:
    name: volume_unit
    from_schema: https://w3id.org/include_portal_v1_schema
  access_url:
    name: access_url
    from_schema: https://w3id.org/include_portal_v1_schema
  data_access:
    name: data_access```
cmungall commented 2 years ago

There is a flag here, inject_metadata, default True:

https://github.com/linkml/linkml-runtime/blob/a1d2c0c728ed4d260869c877a033e2827e5173ef/linkml_runtime/utils/schemaview.py#L150-L183

But this may have some side effects if this is not stored - schemaview works with an import closure by default and the semantics of some slots may be relative to the containing schema; e.g:

https://github.com/linkml/linkml-runtime/blob/a1d2c0c728ed4d260869c877a033e2827e5173ef/linkml_runtime/utils/schemaview.py#L787

I think this should be redesigned such we don't rely on injection but instead on a separate map of (unique) elements to schemas; this is essentially what is done here: https://github.com/linkml/linkml-runtime/blob/a1d2c0c728ed4d260869c877a033e2827e5173ef/linkml_runtime/utils/schemaview.py#L781-L788

so I think we should be fine if we modify the logic here

But we will want lots more tests here

in the interim I would just add something here: https://github.com/linkml/linkml-runtime/blob/main/linkml_runtime/utils/schema_as_dict.py

You will likely want to use this anyway, to avoid the repetition of name as both a key and a slot

sierra-moxon commented 1 year ago

it looks like schema_as_dict is working now, @putmantime? closing for now; please reopen if this is still an issue?