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

All UUID created during Model.py/OntologyAnnotation.__init__() are duplicates #381

Closed
podonnellalidyne opened this issue Jan 18, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@podonnellalidyne
Copy link

podonnellalidyne commented Jan 18, 2021

While parsing isaTab to isaJson, ontologies loaded into the OntologyAnnotation Class have the same @id value

This is because the id method parameter is only evaluated once in python, so it creates a single uuid.uuid4() that is set to all ontologies as the @id param, unless a new id param is passed in. passing in _id = none and then setting the variable to uuid4() if the method param is None fixes this issue. However if then something were passed in in the id value, all future id fields would have that same passed in value, as the optional variable reference would no longer point to None.

Currently:

def __init__(self, term='', term_source=None, term_accession='',
                 comments=None, id_=str(uuid.uuid4())) :
        super().__init__(comments)
        self.__term = term
        self.__term_source = term_source
        self.__term_accession = term_accession
        self.id = id_

This fixes then issue

def __init__(self, term='', term_source=None, term_accession='',
                 comments=None, id_ = None) :
        super().__init__(comments)
        self.__term = term
        self.__term_source = term_source
        self.__term_accession = term_accession
        self.id = str(uuid.uuid4()) if not id_ else id_

Ideally because of the way python evaluates these optional params, maybe the _id param should be required, and evaluates to something every time, or should be removed from init() and can be set after the fact, to ensure there are no inadvertent duplicate values.

@Zigur Zigur self-assigned this Jan 19, 2021
@Zigur Zigur added the bug label Jan 19, 2021
@Zigur Zigur added this to the 0.12 milestone Jan 19, 2021
@Zigur
Copy link
Contributor

Zigur commented Jan 19, 2021

Thanks for noticing this @podonnellalidyne. We'll be fixing the code accordingly and include this bugfix into the next release.

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

No branches or pull requests

2 participants