SynBioDex / pySBOL2

A pure Python implementation of the SBOL standard.
Apache License 2.0
20 stars 6 forks source link

Validator errors on empty document #401

Closed jakebeal closed 3 years ago

jakebeal commented 3 years ago

When a document has no content, the validator errors; and empty document should be valid

doc = sbol2.Document()
doc.exportToFormat('GenBank','tmp.gb')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/sbol2/document.py", line 1007, in exportToFormat
    raise SBOLError(SBOLErrorCode.SBOL_ERROR_INVALID_ARGUMENT, msg)
sbol2.sbolerror.SBOLError: (<SBOLErrorCode.SBOL_ERROR_INVALID_ARGUMENT: 12>, 'Validator returned no content')
tcmitchell commented 3 years ago

This looks like a misinterpretation of the results of running the online validator, which takes care of format translation. The documentation isn't great about possible return values, however I think the valid field is the key. If valid is True, then we should assume that the translation was successful, regardless of the content of result. In the case of an empty document the translation to "GenBank" format results in an empty file.

@jakebeal Will it be confusing if the format translation to GenBank results in an empty file? Or do you expect some sort of an indication that the translation resulted in no content?

jakebeal commented 3 years ago

In this case, I am indeed expecting an empty file: this case comes up in an automated build toolchain if nothing has been designated for build yet.

Currently, my workaround is a special case where check if I'd get this error and manually write an empty file.