SynBioDex / pySBOL2

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

Update pysbol2 conda package #417

Closed kenza12 closed 2 years ago

kenza12 commented 2 years ago

Hi, I'm trying to update the conda package of pysbol2 to the latest tagged version (v1.4) which is a dependency for sbol-utilities (already discussed here: https://github.com/SynBioDex/SBOL-utilities/issues/121). I got some errors while running the tests with pytest. Some links are not found and the tool path'/usr/bin/java'is not found too. In my tests, I added java (openjdk) to the dependencies and I changed '/usr/bin/java' to 'java'in sbol2/config.py, in this line ConfigOptions.JAVA_LOCATION.value: '/usr/bin/java' to make it work.

Is it possible for you to check these tests in order to update these not found links (e.g. http://sd2e.org/parent/child/1 and https://sbols.org/CRISPR_Example/foo) and the java error by replacing /usr/bin/javaby java. Finally, to add a new tag or update to the latest version v1.5 (according to the setup.py) including these modifications.

Thank you.

Best wishes,

Kenza BAZI-KABBAJ

test/test_identified.py:339: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.10/site-packages/sbol2/property.py:778: in get
    return self.__getitem__(uri)
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.10/site-packages/sbol2/property.py:641: in __getitem__
    return self.get_uri(rdflib.URIRef(id))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <sbol2.property.OwnedObject object at 0x7f86c7031870>
id = 'http://sd2e.org/parent/child/1'

    def get_uri(self, id):
        id = str(id)
        if Config.getOption(ConfigOptions.VERBOSE.value) is True:
            print('SBOL compliant URIs are set to ' +
                  Config.getOption(ConfigOptions.SBOL_COMPLIANT_URIS.value))
            print('SBOL typed URIs are set to ' +
                  Config.getOption(ConfigOptions.SBOL_TYPED_URIS.value))
            print('Searching for ' + id)
        # Search this property's object store for the uri
        object_store = self._sbol_owner.owned_objects[self._rdf_type]
        for obj in object_store:
            if id == obj.identity:
                return obj
        # Now assume the search string is a persistent identity
        obj = self.find_persistent_identity(id)
        if obj is not None:
            return obj
        # If searching by the full URI fails, assume the user is searching
        # for an SBOL-compliant URI using the displayId only
        # Form compliant URI for child object
        parent_obj = self._sbol_owner
        resource_namespaces = []
        resource_namespaces.append(getHomespace())
        if parent_obj.doc is not None:
            for ns in parent_obj.doc.resource_namespaces:
                resource_namespaces.append(ns)
        # Check for regular, SBOL-compliant URIs
        obj = self.find_resource(id, resource_namespaces,
                                 object_store, parent_obj, typedURI=False)
        if obj is not None:
            return obj
        else:
            obj = self.find_resource(id, resource_namespaces,
                                     object_store, parent_obj, typedURI=True)
            if obj is not None:
                return obj
            else:
                msg = 'Object {} not found'.format(id)
>               raise SBOLError(SBOLErrorCode.NOT_FOUND_ERROR, msg)
E               sbol2.sbolerror.SBOLError: (<SBOLErrorCode.NOT_FOUND_ERROR: 2>, 'Object http://sd2e.org/parent/child/1 not found')
test/test_identified.py:299: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.10/site-packages/sbol2/identified.py:268: in copy
    self.doc.add(new_obj)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <sbol2.document.Document object at 0x7f86c7517070>
sbol_obj = <sbol2.componentdefinition.ComponentDefinition object at 0x7f86c693f160>

    def add(self, sbol_obj):
        """
        Register an object in the Document.

        :param sbol_obj: The SBOL object(s) you want to serialize.
            Either a single object or a list of objects.
        :return: None
        """
        # Check for uniqueness of URI
        identity_uri = sbol_obj.identity
        if identity_uri in self.SBOLObjects:
>           raise SBOLError(SBOLErrorCode.SBOL_ERROR_URI_NOT_UNIQUE,
                            'Cannot add ' + sbol_obj.identity +
                            ' to Document. An object with this identity '
                            'is already contained in the Document')
E           sbol2.sbolerror.SBOLError: (<SBOLErrorCode.SBOL_ERROR_URI_NOT_UNIQUE: 17>, 'Cannot add http://sbols.org/CRISPR_Example/foo to Document. An object with this identity is already contained in the Document')

../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.10/site-packages/sbol2/document.py:218: SBOLError
>               raise child_exception_type(errno_num, err_msg, err_filename)
E               FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/java'
tcmitchell commented 2 years ago

Hi @kenza12 , and thanks in advance for working on the conda packaging. We appreciate your help.

I think I see two different issues here. I've broken them apart into:

  1. Default java executable path
  2. Unit test errors

If I've missed something, please let me know.

Default Java executable

The java settings are a very recent addition by @jakebeal . I had some concerns about /usr/bin/java at the time and we didn't have enough use to require a change. I think if you want to change the default value of JAVA_LOCATION from /usr/bin/java to java, and @jakebeal agrees to the change, we can incorporate that. I would appreciate it if you could open a specific issue for that change, and submit a pull request for it so that @jakebeal can test in his environment.

Unit test errors

We use unittest for pySBOL2. It succeeds in my environment and it succeeds in the GitHub action we have set up for this package. I don't understand why pytest fails when unittest succeeds on some of these tests. I suggest you stick with unittest unless you want to debug pytest-specific issues with our unit tests. We would welcome a contribution for that, and do not plan to undertake that effort ourselves. You can see the unittest invocation in our GitHub build/test action:

python -m unittest discover -s test
kenza12 commented 2 years ago

Hi @tcmitchell ,

Thank you for your detailed answer.

For Java, I just opened a specific issue and submitted a PR.

For unit tests, I used your command line with unittest and it's indeed working. Unfortunately I don't have enough time to debug the pytest errors. So, I will use unittest instead of pytest.

Thank you very much.

tcmitchell commented 2 years ago

PR #418 has been merged, and switching to python3 -m unittest avoids the problem of the missing URIs. I think this issue is complete. If I'm mistaken, please reopen this issue. If new issues arise, please file new issues. And once again, thank you very much for doing the conda packaging!

kenza12 commented 2 years ago

Nice ! Thanks a lot ! Just one last thing, can you add (or update) a tag like v1.4: https://github.com/SynBioDex/pySBOL2/releases/tag/v1.4 including the JAVA modification. Conda use a tagged source code (as an archive) to ensure that it can be verified.

tcmitchell commented 2 years ago

@kenza12 I have released version 1.4.1 with your java path bug fix. The tag is "v1.4.1".

kenza12 commented 2 years ago

Ok perfect, thank you @tcmitchell !