sssom-py icon indicating copy to clipboard operation
sssom-py copied to clipboard

Updated SSSOM data model leads to broken code but does not provide helpful message

Open cthoyt opened this issue 3 years ago • 1 comments

The Biomappings (https://github.com/biopragmatics/biomappings) project exports its curated mappings into SSSOM, however the code hasn't been updated since before the SSSOM standard to have the "mapping justification" (see https://github.com/mapping-commons/sssom/pull/117) and therefore it's getting an error since this field is obviously missing:

Traceback (most recent call last):
  File "/home/runner/work/biomappings/biomappings/.tox/update/bin/biomappings", line 33, in <module>
    sys.exit(load_entry_point('biomappings', 'console_scripts', 'biomappings')())
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/runner/work/biomappings/biomappings/src/biomappings/cli.py", line 46, in update
    ctx.invoke(sssom)
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/runner/work/biomappings/biomappings/src/biomappings/export_sssom.py", line 99, in sssom
    msdf = from_sssom_dataframe(df, prefix_map=prefix_map, meta=META)
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/sssom/parsers.py", line 382, in from_sssom_dataframe
    mlist.append(_prepare_mapping(Mapping(**mdict)))
  File "<string>", line 42, in __init__
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/sssom_schema/datamodel/sssom_schema.py", line 258, in __post_init__
    self.MissingRequiredField("mapping_justification")
  File "/home/runner/work/biomappings/biomappings/.tox/update/lib/python3.9/site-packages/linkml_runtime/utils/yamlutils.py", line 250, in MissingRequiredField
    raise ValueError(f"{field_name} must be supplied")
ValueError: mapping_justification must be supplied

My problem here is that the error message is relatively unhelpful. This value error should say something about what data model is being constructed, something about the field itself besides the name, and also give some suggestions (especially if it's an enum). This issue may be more relevant for LinkML itself, but I'm posting it here first since

cthoyt avatar Aug 02 '22 11:08 cthoyt

Yeah makes sense. We should provide an error message that lists all the required fields of SSSOM and links to some page that mentions the transition from match_type to mapping_justification.

matentzn avatar Aug 02 '22 11:08 matentzn