Skip to content

test: isolate _config in all tests#1549

Merged
jmartin-tech merged 2 commits intoNVIDIA:mainfrom
jmartin-tech:fix/isolate-config-in-tests
Jan 20, 2026
Merged

test: isolate _config in all tests#1549
jmartin-tech merged 2 commits intoNVIDIA:mainfrom
jmartin-tech:fix/isolate-config-in-tests

Conversation

@jmartin-tech
Copy link
Collaborator

The _config namespace is utilized globally. This revision ensures a clean configuration environment exists before each test and ensures post test cleanup of files connected to config that may have been created during the test.

Verification

List the steps needed to make sure this thing works

  • Verify automation tests complete without warnings of orphaned files

Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
Copy link
Collaborator

@leondz leondz left a comment

Choose a reason for hiding this comment

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

there may be relevant deficiencies in the scope of importlib.reload(), otherwise lgtm, nice prune

def reload():
import importlib

importlib.reload(_config)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this sufficient? Do we not want to unload first with del _config?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Per python docs:

The argument must be a module object, so it must have been successfully imported before.

I agree there may be an edge case not yet handled based on the details offered in the linked docs, but I suspect this provides a good baseline to build on.

Copy link
Collaborator

Choose a reason for hiding this comment

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

it does. Saw this in the docs and didn't see a reason not to gc the older version:

  • As with all other objects in Python the old objects are only reclaimed after their reference counts drop to zero.
  • The names in the module namespace are updated to point to any new or changed objects.
  • Other references to the old objects (such as names external to the module) are not rebound to refer to the new objects and must be updated in each namespace where they occur if that is desired.

https://docs.python.org/3/library/importlib.html#importlib.reload

Copy link
Collaborator Author

@jmartin-tech jmartin-tech Jan 19, 2026

Choose a reason for hiding this comment

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

A call to del may remove the object as no longer considered successfully imported, as garbage collection is not always predictable in terms of timing. Can do some testing, however I am not currently comfortable marking a required to exist item with del prior to replacement by importlib. We might be able to add an additional reference and offer that to del after a the reload however I suspect that may actually introduce more possible race conditions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I respect the reservation. I wonder if python supports making these two operations into an atomic txn. Or if .reload() is even possible after del()?

Signed-off-by: Jeffrey Martin <jemartin@nvidia.com>
@jmartin-tech jmartin-tech changed the title isolate _config in all tests test: isolate _config in all tests Jan 20, 2026
@jmartin-tech jmartin-tech added the tests Testing-related label Jan 20, 2026
@jmartin-tech jmartin-tech merged commit adfddec into NVIDIA:main Jan 20, 2026
16 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tests Testing-related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants