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

Improve class generation across namespace dependencies #557

Merged
merged 3 commits into from
Apr 8, 2021

Conversation

rly
Copy link
Contributor

@rly rly commented Apr 8, 2021

Motivation

Proposed modification of #555 to handle the failing test and improve cross-namespace class generation. Merging would be into the enh/get_class_fix branch used by #555.

Scenario:
Namespace N1 contains group type A.
Namespace N2 contains group type B extends A. If class A for type A in namespace N1 does not exist, then the TypeMap now generates this class A, maps type A in namespace N1 to this class A, and maps type A in namespace N2 to the same class A.
Namespace N3 contains group type C which includes subgroup type A. The TypeMap now uses the same class A for all three namespaces.

The order of calling get_class on classes and their dependencies thus does not matter.

Note: If get_class is called such that a class is dynamically generated for class A, and later a custom API class is mapped to class A, then the two class As will not be the same, which could lead to unexpected behavior. This is not new behavior -- I just mention that this could happen.

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running flake8 from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

@rly rly changed the title do not autogenerate classes when loading namespace Improve class generation across namespace dependencies Apr 8, 2021
@rly rly requested a review from ajtritt April 8, 2021 09:08
Copy link
Contributor

@oruebel oruebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

src/hdmf/build/manager.py Outdated Show resolved Hide resolved
tests/unit/build_tests/test_classgenerator.py Show resolved Hide resolved
@ajtritt ajtritt merged commit f1d7ac2 into enh/get_class_fix Apr 8, 2021
@ajtritt ajtritt deleted the enh/get_class_fix2 branch April 8, 2021 18:21
ajtritt added a commit that referenced this pull request Apr 9, 2021
* do not autogenerate  classes when loading namespace

* Improve class generation across namespace dependencies (#557)

* Check dependent types, gen classes for them, and link them

* Add comment

* Update src/hdmf/build/manager.py

Co-authored-by: Andrew Tritt <[email protected]>

* add tests for convoluted extension scenario

* generate class if necessary

* make namespace an optional argument

* satisfy flake8

Co-authored-by: Ryan Ly <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants