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

linkml2sheets doesn't work when given a directory of templates #69

Closed turbomam closed 1 year ago

turbomam commented 1 year ago

@putmantime and I have observed that running linkml2sheets on a directory of templates doesn't work, even when all of the individual templates do work

the linkml2sheets help gives this example:

linkml2sheets -s my_schema.yaml sheets/*.tsv -d sheets --overwrite

In the nmdc-schema repo, the following two work

schemasheets/tsv_output/slots.tsv: clean_schemasheets
    linkml2sheets \
        --schema src/schema/nmdc.yaml \
        --output-directory schemasheets/tsv_output/ \
        schemasheets/templates/slots.tsv

schemasheets/tsv_output/classes.tsv: clean_schemasheets
    linkml2sheets \
        --schema src/schema/nmdc.yaml \
        --output-directory schemasheets/tsv_output/ \
        schemasheets/templates/classes.tsv

but this doesn't work

schemasheets/tsv_output/all.tsv: clean_schemasheets
    linkml2sheets \
        --schema src/schema/nmdc.yaml \
        --output-directory schemasheets/tsv_output/ \
        schemasheets/templates/*.tsv

Even though

ls -l schemasheets/templates 

-rw-r--r--@ 1 MAM staff 71 Aug 16 17:22 classes.tsv -rw-r--r--@ 1 MAM staff 58 Aug 16 17:26 prefixes.tsv -rw-r--r--@ 1 MAM staff 2005 Aug 16 18:01 slots.tsv

The error is

Traceback (most recent call last): File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/nmdc-schema-MTtWF7zd-py3.9/bin/linkml2sheets", line 8, in sys.exit(export_schema()) File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/nmdc-schema-MTtWF7zd-py3.9/lib/python3.9/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/nmdc-schema-MTtWF7zd-py3.9/lib/python3.9/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/nmdc-schema-MTtWF7zd-py3.9/lib/python3.9/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/nmdc-schema-MTtWF7zd-py3.9/lib/python3.9/site-packages/click/core.py", line 760, in invoke return __callback(args, **kwargs) File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/nmdc-schema-MTtWF7zd-py3.9/lib/python3.9/site-packages/schemasheets/schema_exporter.py", line 297, in export_schema exporter.export(sv, specification=f, to_file=outpath) File "/Users/MAM/Library/Caches/pypoetry/virtualenvs/nmdc-schema-MTtWF7zd-py3.9/lib/python3.9/site-packages/schemasheets/schema_exporter.py", line 90, in export writer.writerow(row) File "/usr/local/Cellar/python@3.9/3.9.13_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/csv.py", line 154, in writerow return self.writer.writerow(self._dict_to_list(rowdict)) File "/usr/local/Cellar/python@3.9/3.9.13_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/csv.py", line 149, in _dict_to_list raise ValueError("dict contains fields not in fieldnames: " ValueError: dict contains fields not in fieldnames: 'class' make: *** [schemasheets/tsv_output/all.tsv] Error 1

cmungall commented 1 year ago

Are you sure this is different from:

what output do you get if the prefixes tsv is not in the directory?

sierra-moxon commented 1 year ago

closing as a duplicate of #70.

turbomam commented 1 year ago

I think they are different issues and will write tests.