Skip to content

Move to nose2 only#6146

Open
klecki wants to merge 19 commits intoNVIDIA:mainfrom
klecki:nose2-only
Open

Move to nose2 only#6146
klecki wants to merge 19 commits intoNVIDIA:mainfrom
klecki:nose2-only

Conversation

@klecki
Copy link
Copy Markdown
Contributor

@klecki klecki commented Dec 22, 2025

Use nose2 as the only testing framework. Drop nose.

Category: Other

Description:

Remove the WARs used to keep nose alive.

nose2 supports the yield-style test discovery by default @attr has a different filtering syntax (-A) and just checks for presence of truthy test_foo.attribute_name. A decorator uses this mechanism for backward compatibility.

nose2 splits with_setup(setup, teardown) into two separate decorators, a backward compatible decorator is added.

nottest sets special attribute.

SkipTest from unittest is recommended to be used directly (with the same functionality).

Test scripts are adjusted with minimal changes to run through nose2. Followup cleanup can be used for renaming.

Replace unsupported -m regex by attributes

Additional information:

Affected modules and functionalities:

Key points relevant for the review:

Tests:

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: N/A

Comment thread dali/test/python/nose_utils.py Fixed
Comment thread dali/test/python/nose_utils.py Fixed
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Dec 22, 2025

Greptile Summary

This PR completes the migration from nose to nose2 as the sole Python test runner for DALI. It removes the nose_wrapper shim (and all the imp/pkg_resources compatibility hacks it required), rewrites nose_utils.py using only unittest primitives, introduces a new nose2_attrib_generators plugin to attribute-filter generator-style tests before they are invoked, and updates all 50+ CI shell scripts to use python_new_invoke_test with -A attribute filters instead of --attr.

Confidence Score: 5/5

Safe to merge; all previously flagged P1 issues have been resolved, and the one remaining finding is a minor P2 about plain-class setUp lifecycle.

Prior blocking issues (missing sanitizer_skip attributes, --attr vs -A syntax, .1 vs :1 parameterized selector, missing comma in attribute expressions) are all resolved in the current HEAD. The only open finding is a P2 concern about TestTFDatasetMultiGPU and similar plain classes not inheriting unittest.TestCase, which may affect setUp call guarantees when tests are loaded by explicit name — not a hard blocker.

dali/test/python/test_dali_tf_dataset_eager.py — verify setUp is called for plain-class tests invoked by explicit name via nose2.

Important Files Changed

Filename Overview
dali/test/python/nose2_attrib_generators.py New nose2 plugin that monkey-patches the Generators plugin to apply -A attribute filters before calling generator functions; comment added explaining the intentional duplication of nose2's internal parsing logic.
dali/test/python/nose_utils.py Massively simplified by dropping all nose/imp/pkg_resources shims; replaces nose APIs with pure unittest equivalents (SkipTest, attr, nottest, assert_raises, assert_warns). Logic looks correct.
dali/test/python/test_dali_tf_dataset_eager.py Refactored free functions with with_setup into plain classes with setUp; TestTFDatasetMultiGPU does not inherit unittest.TestCase, raising a P2 concern about setUp lifecycle when loaded by explicit name.
dali/test/python/unittest.cfg Added nose2_attrib_generators plugin before nose2.plugins.attrib so generator functions are filtered by attributes before being called.
qa/test_template_impl.sh Drops python_invoke_test/python_test_runner (nose) variables entirely; nose2 is now the sole runner; pip_packages trimmed to nose2 nose2-test-timer.
qa/nose_wrapper/main.py Deleted — the nose wrapper shim (including inspect.getargspec patch and run_exit) is no longer needed.
qa/TL0_python-self-test-core/test_body.sh Migrated all invocations from python_invoke_test --attr to python_new_invoke_test -A; mxnet attribute removed; parameterized test uses correct :1 colon separator.
qa/TL1_tensorflow_dataset/test_impl.sh Migrated TF-dataset multi-GPU test invocations to nose2 module-path syntax; _test_tf_dataset_multigpu_mirrored_strategy now correctly referenced under TestTFDatasetMultiGPU class.
qa/TL0_python_self_test_frameworks/test_pytorch.sh Replaced -m regex test-name filter with -A pytorch attribute filter; tests must now carry @attr('pytorch') to be discovered.
dali/test/python/test_fw_iterators.py Removed ~1140 lines of MXNet-specific iterator tests (mxnet attribute gated), consistent with the mxnet filter removal across CI scripts.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[CI shell script] -->|python_new_invoke_test -A filter module.Class.method| B[python -m nose2]
    B --> C{unittest.cfg plugins}
    C --> D[nose2_attrib_generators\nAttributeGeneratorFilter]
    C --> E[nose2.plugins.attrib\nAttributeSelector]
    C --> F[nose2.plugins.collect]
    D -->|handleArgs: monkey-patches| G[Generators plugin\n_testsFromGeneratorFunc]
    G -->|check @attr tags before calling| H{Attribute match?}
    H -- No --> I[return empty list\nskip generator]
    H -- Yes --> J[call generator - yield tests]
    E -->|moduleLoadedSuite: filter| K[Individual test methods\nwith @attr tags]
    J --> K
    K --> L[Run tests]
Loading

Reviews (22): Last reviewed commit: "Fix" | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. dali/test/python/nose_utils.py, line 129-130 (link)

    style: creating a new TestCase instance for each assertion call is unconventional

    Consider creating a module-level instance once:

    Then define tc at module level (after imports) and reuse it in both assert_raises and assert_warns

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

25 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (2)

  1. dali/test/python/test_functional_api.py, line 22 (link)

    logic: This file still imports nose directly and uses nose.tools.eq_ on line 188. Since nose is being removed as a dependency, this will cause an import error.

  2. dali/test/python/test_functional_api.py, line 188 (link)

    logic: Replace nose.tools.eq_ with standard assertion or use assert_equals from nose_utils

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

28 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. dali/test/python/nose_utils.py, line 68 (link)

    syntax: missing self parameter - instance methods must have self as first parameter

29 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@klecki
Copy link
Copy Markdown
Contributor Author

klecki commented Dec 22, 2025

!build

@dali-automaton
Copy link
Copy Markdown
Collaborator

CI MESSAGE: [40627092]: BUILD STARTED

@dali-automaton
Copy link
Copy Markdown
Collaborator

CI MESSAGE: [40627092]: BUILD FAILED

@klecki
Copy link
Copy Markdown
Contributor Author

klecki commented Dec 22, 2025

!build

Comment thread dali/test/python/nose_utils.py Fixed
@dali-automaton
Copy link
Copy Markdown
Collaborator

CI MESSAGE: [40628704]: BUILD STARTED

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. dali/test/python/nose_utils.py, line 83-85 (link)

    style: Consider using the module-level _test_case instance instead of creating a new empty_case() for each assertion:

    This is more efficient and aligns with how assert_raises and assert_warns are implemented.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

29 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread dali/test/python/nose_utils.py Outdated
Comment thread qa/TL0_python-self-test-core/test_body.sh
Comment thread qa/TL0_python-self-test-core/test_body.sh
Comment thread qa/TL0_python-self-test-readers-decoders/test_body.sh
Comment thread qa/TL0_python-self-test_tegra/test_body.sh
Comment thread qa/TL1_python-self-test-slow/test.sh
Comment thread qa/TL1_python-self-test_conda/test_body.sh Outdated
Comment thread qa/test_template_impl.sh
@JanuszL JanuszL self-assigned this Dec 22, 2025
@JanuszL
Copy link
Copy Markdown
Contributor

JanuszL commented Dec 22, 2025

Do we need to touch unittest_failure.cfg, unittest_slow.cfg or unittest.cfg as well?

@dali-automaton
Copy link
Copy Markdown
Collaborator

CI MESSAGE: [40628704]: BUILD FAILED

Copy link
Copy Markdown
Contributor

@mzient mzient left a comment

Choose a reason for hiding this comment

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

The way the tests are first discovered and then run will most certainly prevent parallel external source from working (see test job 247483858) was the primary reason for not pursuing full transition to nose2 to date.
Perhaps you can move the troublesome tests to separate files to guarantee proper execution order.

Also, some of the tests used to generate vast amounts of data in the "discovery" stage, because yielding in nose didn't cause data accumulation. Please make sure that this is not the case any more - the tests might work when run one by one but case out-of-memory condition when multiple test files are run.

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. dali/test/python/nose_utils.py, line 74 (link)

    syntax: Missing self parameter in method definition

33 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Dec 30, 2025

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

klecki and others added 13 commits April 20, 2026 15:19
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
- nose_utils.py: consolidate double unittest import into single form
- test_dali_tf_es_pipelines.py: gen_tf_with_dali_external_source now
  yields a make_es_args factory instead of pre-built callback objects,
  so no data is created during test discovery
- test_dali_tf_dataset_graph.py: call make_es_args() at test run time
- test_external_source_parallel.py: _make_all_kinds_parallel_cases
  yields (epoch_size, ...) descriptors; ExtCallback/SampleCallbackBatched/
  SampleCallbackIterator are constructed inside test_all_kinds_parallel

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
test_numba_func_with_cond tests passed np.full(...) directly in
expected_out and were not updated when the descriptor format was
introduced in 839dfb1, causing a ValueError on unpack.

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Comment thread dali/test/python/test_dali_tf_dataset_graph.py Outdated
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Comment thread dali/test/python/test_dali_tf_dataset_eager.py Dismissed

if [ -z "$DALI_ENABLE_SANITIZERS" ]; then
${python_new_invoke_test} -A "!slow,!pytorch,!mxnet,!cupy" test_dali_variable_batch_size
${python_new_invoke_test} -A "!slow,!pytorch!cupy" test_dali_variable_batch_size
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
${python_new_invoke_test} -A "!slow,!pytorch!cupy" test_dali_variable_batch_size
${python_new_invoke_test} -A "!slow,!pytorch,!cupy" test_dali_variable_batch_size

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed

${python_new_invoke_test} -A "!slow,!pytorch!cupy" test_dali_variable_batch_size
else
${python_new_invoke_test} -A "!slow,!pytorch,!mxnet,!cupy,!numba" test_dali_variable_batch_size
${python_new_invoke_test} -A "!slow,!pytorch!cupy,!numba" test_dali_variable_batch_size
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
${python_new_invoke_test} -A "!slow,!pytorch!cupy,!numba" test_dali_variable_batch_size
${python_new_invoke_test} -A "!slow,!pytorch,!cupy,!numba" test_dali_variable_batch_size

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
@JanuszL
Copy link
Copy Markdown
Contributor

JanuszL commented Apr 20, 2026

!build

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Comment thread dali/test/python/test_dali_tf_exec2.py Fixed
@dali-automaton
Copy link
Copy Markdown
Collaborator

CI MESSAGE: [49014072]: BUILD STARTED

@dali-automaton
Copy link
Copy Markdown
Collaborator

CI MESSAGE: [49014072]: BUILD FAILED

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
@JanuszL
Copy link
Copy Markdown
Contributor

JanuszL commented Apr 20, 2026

!build

@dali-automaton
Copy link
Copy Markdown
Collaborator

CI MESSAGE: [49016580]: BUILD STARTED

@dali-automaton
Copy link
Copy Markdown
Collaborator

CI MESSAGE: [49016580]: BUILD FAILED

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.

7 participants