Skip to content

Clear stale task tags when overriding factories - #573

Open
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/tagged-tasks-clear-overridden-tags
Open

sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/tagged-tasks-clear-overridden-tags

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Fixes #572.

Failure

TaggedTasks(allow_overriding_keys=True) permits a new factory to replace an existing one with the same function name. Previously, add() updated the primary task map and inserted the replacement into its new tags, but did not remove registrations under its old tags. A factory re-registered under new therefore remained discoverable through tagged('old'), even though its current registration did not include old.

Overriding with no tags also left obsolete entries in tags(). Because the tag index holds factory references, this could retain replaced callables and produce incorrect tag-based task selections.

Change

When overriding an existing key, remove that key from all previous tag memberships before installing the replacement. Remove tag buckets that become empty. Then add the new factory under the newly supplied tags.

The change preserves the registration order in the primary task map and leaves all other factories untouched. The existing duplicate-name rejection with allow_overriding_keys=False is unchanged.

Validation

  • Three new regression tests failed against unchanged main: stale tags after changed registration, obsolete tags after an untagged replacement, and unwanted membership when another factory shares an old tag.
  • Four new tests pass with the fix, including a registration-order control.
  • Broader containers, rewards and xml_tools utility test selection: 50 passed on Python 3.12/macOS.
  • Ruff correctness checks (E4, E7, E9, F), Python compilation and git diff --check pass.

Scope

Only replacement registrations change. New registrations, lookups, tag intersections and the no-overrides mode retain their behaviour. The broader physics and rendering test suites were not run for this utility-level change.

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.

TaggedTasks overrides retain stale tag memberships

1 participant