Skip to content

Conversation

@rly
Copy link
Contributor

@rly rly commented Aug 12, 2025

Motivation

Fix #1301, work toward fixing NeurodataWithoutBorders/pynwb#1958

Also deprecates calling get_type_map with any 'extensions' arguments, a use case I have never seen. IMO it's easy for the rare user to just call load_namespaces on the type map than us maintain all this extra convenience logic that even we don't use.

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Does the PR clearly describe the problem and the solution?
  • Have you reviewed our Contributing Guide?
  • Does the PR use "Fix #XXX" notation to tell GitHub to close the relevant issue numbered XXX when the PR is merged?

@codecov
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 87.80488% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.63%. Comparing base (da877eb) to head (cb89a8b).
⚠️ Report is 24 commits behind head on dev.

Files with missing lines Patch % Lines
src/hdmf/container.py 86.36% 2 Missing and 1 partial ⚠️
src/hdmf/common/__init__.py 83.33% 1 Missing ⚠️
src/hdmf/term_set.py 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1302      +/-   ##
==========================================
- Coverage   91.70%   91.63%   -0.07%     
==========================================
  Files          42       42              
  Lines        9615     9613       -2     
  Branches     1940     1941       +1     
==========================================
- Hits         8817     8809       -8     
- Misses        519      522       +3     
- Partials      279      282       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

termset_path = os.path.join(CUR_DIR, config_termset_path['termset'])
termset = TermSet(term_schema_path=termset_path)
val = TermSetWrapper(value=val, termset=termset)
return val
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes here

  1. refactor the logic so that we have fewer nested if/else statements. Return breaks the if so we can dedent
  2. Updates configurator.path to configurator.paths

self.paths = []
if kwargs["paths"]:
for p in kwargs["paths"]:
self.load_type_config(p)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was confusing for path to be a list of paths, so change path to paths. It was also confusing for init to take only one path when there may be multiple paths you want to load, and so subsequent calls require calling load_type_config.

"""
config_path = kwargs['config_path']
type_map = kwargs['type_map'] or get_type_map()
type_map = kwargs['type_map'] or __TYPE_MAP
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to use the global type map here, not a copy of the global type map. This worked before because copying the global type map maintained a reference to the same type configurator, so the configurator was unintentionally global.

@rly
Copy link
Contributor Author

rly commented Aug 12, 2025

I added notes to aid review inline in the PR.

@rly rly requested a review from oruebel August 12, 2025 00:41
Comment on lines +141 to +143
# return the value if the data type for the container is not in the config
if data_type not in config_namespace['data_types']:
return val
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the warning here because not all data types used will be configured

Comment on lines +133 to +135
# return the value if the namespace for the container is not in the config
if self.namespace not in termset_config['namespaces']:
msg = "%s not found within loaded configuration." % self.namespace
return val
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the warning here because not all namespaces used will be configured

@rly
Copy link
Contributor Author

rly commented Aug 13, 2025

It is expected that PyNWB tests fail. They only worked because the TypeConfigurator was the same instance across copies and PyNWB was using copies of TypeMap when loading configurations. This is fixed in NeurodataWithoutBorders/pynwb#2121

@oruebel oruebel requested a review from stephprince August 13, 2025 16:34
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. @stephprince could you also take a look. The TypeMap stuff is pretty deep in the weeds and it would be good to get another pair of eyes on this just to make sure.

@rly
Copy link
Contributor Author

rly commented Aug 13, 2025

This also resolves NeurodataWithoutBorders/pynwb#1939

@rly rly merged commit b27e54c into dev Aug 13, 2025
27 of 29 checks passed
@rly rly deleted the fix_type_map_term_set_config branch August 13, 2025 20:59
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.

[Bug]: deepcopy of TypeMap uses same TypeConfig

4 participants