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

Extra auto classgeneration on import of hdmf.common types #553

Closed
5 tasks done
oruebel opened this issue Apr 6, 2021 · 0 comments · Fixed by #555
Closed
5 tasks done

Extra auto classgeneration on import of hdmf.common types #553

oruebel opened this issue Apr 6, 2021 · 0 comments · Fixed by #555
Assignees
Labels
category: bug errors in the code or code behavior

Comments

@oruebel
Copy link
Contributor

oruebel commented Apr 6, 2021

Description

In the function TypeMap.get_container_cls function in hdmf.build.manager the internal helper function TypeMap.__get_container_cls call initially returns None for classes from hdmf.common. When importing a container class from hdmf.common this results in a sequence of calls where first Container classes are autogenerated and the later on the correct custom classes from hdmf.common are detected. When I add a print(cls, namespace, data_type) in TypeMap.get_container_cls and import DynamicTable I get the following:

from hdmf.common.table import DynamicTable
None hdmf-common Data
None hdmf-common Container
None hdmf-common SimpleMultiContainer
None hdmf-common VectorData
None hdmf-common VectorIndex
None hdmf-common ElementIdentifiers
None hdmf-common DynamicTableRegion
None hdmf-common DynamicTable
None hdmf-common AlignedDynamicTable
None hdmf-common CSRMatrix
<class 'hdmf.common.table.DynamicTable'> hdmf-common DynamicTable
<class 'hdmf.common.table.VectorData'> hdmf-common VectorData
<class 'hdmf.common.table.VectorIndex'> hdmf-common VectorIndex
<class 'hdmf.common.table.ElementIdentifiers'> hdmf-common ElementIdentifiers
<class 'hdmf.common.table.DynamicTableRegion'> hdmf-common DynamicTableRegion
<class 'hdmf.common.table.EnumData'> hdmf-experimental EnumData
<class 'hdmf.common.sparse.CSRMatrix'> hdmf-common CSRMatrix
<class 'hdmf.common.resources.ExternalResources'> hdmf-experimental ExternalResources
<class 'hdmf.common.multi.SimpleMultiContainer'> hdmf-common SimpleMultiContainer

I.e., there is a first round where TypeMap.__get_container_cls returns None which in turn triggers the automatic class generation and then in a second round the correct classes are found.

While the end-behavior for the user is correct but having classes autogenerated for all types seems like an unnecessary that could slow down import of HDMF. I found this behavior as part of PR #551 to integrate AlignedDynamicTable , because automatic class generation currently fails for this type (see Issue #554) and the behavior described in this issues triggers that behavior.

Steps to Reproduce

from hdmf.common.table import DynamicTable

Environment

Python Executable: Installed HDMF from latest dev
Python Version: Python  3.8
Operating System:  macOS
HDMF Version: dev

Checklist

  • Have you ensured the bug was not already reported ?
  • Have you included a brief and descriptive title?
  • Have you included a clear description of the problem you are trying to solve?
  • Have you included a minimal code snippet that reproduces the issue you are encountering?
  • Have you checked our Contributing document?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug errors in the code or code behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants