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

Add _in_construct_mode to differentiate container init vs construct #751

Merged
merged 9 commits into from
Aug 4, 2022

Conversation

rly
Copy link
Contributor

@rly rly commented Aug 3, 2022

Motivation

Fix #750. This PR adds a new single-underscore-protected field in AbstractContainer called _in_construct_mode that is set to True if the object is being created by the ObjectMapper when constructing the object from builders read from a file and then reset to False after the object is done being created. Users creating the object will not interact with this field.

Subclasses of AbstractContainer can check _in_construct_mode to determine whether to raise a warning or error when encountering invalid data (we want to be able to read and fix data that is invalid but not create new data that is invalid).

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 requested review from ajtritt and oruebel August 3, 2022 21:52
@codecov
Copy link

codecov bot commented Aug 3, 2022

Codecov Report

Merging #751 (37505cd) into dev (a476142) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##              dev     #751   +/-   ##
=======================================
  Coverage   87.57%   87.57%           
=======================================
  Files          44       44           
  Lines        8834     8836    +2     
  Branches     2033     2033           
=======================================
+ Hits         7736     7738    +2     
  Misses        784      784           
  Partials      314      314           
Impacted Files Coverage Δ
src/hdmf/build/objectmapper.py 92.73% <100.00%> (+<0.01%) ⬆️
src/hdmf/container.py 90.14% <100.00%> (+0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us.

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Oliver Ruebel <oruebel@users.noreply.github.com>
src/hdmf/container.py Outdated Show resolved Hide resolved
Co-authored-by: Oliver Ruebel <oruebel@users.noreply.github.com>
src/hdmf/container.py Outdated Show resolved Hide resolved
rly and others added 4 commits August 4, 2022 10:21
Co-authored-by: Oliver Ruebel <oruebel@users.noreply.github.com>
Co-authored-by: Oliver Ruebel <oruebel@users.noreply.github.com>
Co-authored-by: Oliver Ruebel <oruebel@users.noreply.github.com>
@rly rly requested a review from oruebel August 4, 2022 17:38
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.

[Feature]: Differentiate between calling Container __init__ by user vs during object construction
2 participants