Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYNBICT: Not Found Error in copy_component_definition #138

Closed
tcmitchell opened this issue Apr 1, 2020 · 5 comments
Closed

SYNBICT: Not Found Error in copy_component_definition #138

tcmitchell opened this issue Apr 1, 2020 · 5 comments
Assignees
Milestone

Comments

@tcmitchell
Copy link
Collaborator

SYNBICT fails with a SBOL NOT_FOUND_ERROR in all three unit tests. Two appear to be the same error, one is an error looking for a different object. Here is an example:

======================================================================
ERROR: test_pruning_annotating (test.test_curation.CurationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/SYNBICT/test/test_curation.py", line 28, in test_pruning_annotating
    annotated_identities = feature_annotater.annotate(target_construct_library, MIN_TARGET_LENGTH)
  File "/SYNBICT/sequences_to_features/sequences_to_features.py", line 422, in annotate
    len(target.nucleotides))
  File "/SYNBICT/sequences_to_features/sequences_to_features.py", line 395, in __process_feature_matches
    FeatureLibrary.copy_component_definition(feature_definition, feature_doc, target_doc)
  File "/SYNBICT/sequences_to_features/sequences_to_features.py", line 239, in copy_component_definition
    sink_doc.getComponentDefinition(comp_definition.identity)
  File "/SBOL/sbol/document.py", line 349, in getComponentDefinition
    return self.componentDefinitions.get(uri)
  File "/SBOL/sbol/property.py", line 592, in get
    return self.__getitem__(uri)
  File "/SBOL/sbol/property.py", line 492, in __getitem__
    return self.get_uri(rdflib.URIRef(id))
  File "/SBOL/sbol/property.py", line 545, in get_uri
    raise SBOLError(msg, SBOLErrorCode.NOT_FOUND_ERROR)
sbol.sbolerror.SBOLError: ('Object https://synbiohub.programmingbiology.org/public/Cello_Parts/pBAD/1 not found', <SBOLErrorCode.NOT_FOUND_ERROR: 2>)
@tcmitchell tcmitchell added this to the beta milestone Apr 1, 2020
@tcmitchell
Copy link
Collaborator Author

There are a number of places in FeatureLibrary.copy_component_definition that catch RuntimeError which I find worrisome. Should SBOL be mimicking runtime errors thrown by pySBOL? Should a client library be relying on seeing a RuntimeError?

@tcmitchell
Copy link
Collaborator Author

RuntimeError is apparently caught because that's what pySBOL raises if a component definition is not found:

>>> import sbol
>>> doc = sbol.Document()
>>> doc.getComponentDefinition('http://example.com/foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/sbol/libsbol.py", line 15533, in getComponentDefinition
    return _libsbol.Document_getComponentDefinition(self, uri)
RuntimeError: Object http://example.com/foo not found

This feels like a case of inadvertent API. I doubt anyone thought raising a RuntimeError was a good way to signal that an item was not found. But it has apparently become part of the pySBOL API.

We won't be supporting this part of the API going forward.

@bbartley
Copy link
Collaborator

bbartley commented Apr 2, 2020

This relates to #21 whether we want to be throwing Python Exceptions or our own custom Exceptions.

Also the pattern of using a thrown exception to check if an object is contained in the Document is not ideal. Recent versions of pySBOL support use of the in operator.

@tcmitchell
Copy link
Collaborator Author

tcmitchell commented Apr 2, 2020

I have temporarily added a block at the beginning of the file to figure out which type of error to catch:

# Set up the not found error for catching                                                                               
try:
    # SBOLError is in the native python module                                                                          
    NotFoundError = SBOLError
except NameError:
    # The swig wrapper raises RuntimeError on not found                                                                 
    NotFoundError = RuntimeError

And then replace except RuntimeError with except NotFoundError, which works across the two libraries.

That got me to the next error.

@tcmitchell tcmitchell self-assigned this Apr 2, 2020
@tcmitchell
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants