Skip to content

nnUNet Writes Into Current Directory By Default #8886

Description

@ericspod

This was flagged by Coderabbit and should be addressed. nnUNet will write test data to the current directory during testing, this should be changed to writing to a temporary directory in tests. This avoids leaving a mess in the user's current directory.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep the generated nnUNet paths inside self.test_dir.

nnUNetV2Runner.__init__ creates nnunet_raw, nnunet_preprocessed, and nnunet_results immediately. With the current ./... values, these tests write into the repo cwd instead of the temp directory, so state leaks across tests and tearDown() does not clean it up.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integration/test_integration_nnunetv2_runner.py` around lines 110 -
148, The test YAMLs currently use relative paths (./data, ./work, ./nnUNet_raw,
./nnUNet_preprocessed, ./nnUNet_results) so nnUNetV2Runner.__init__ creates
directories in the repo cwd; update the YAML strings (good_yml_content1,
good_yml_content2, injecting_yml_content) to build all generated paths inside
the test temp dir (use self.test_dir) for keys dataroot, datalist, work_dir,
nnunet_raw, nnunet_preprocessed, and nnunet_results so the runner creates those
folders under self.test_dir and tearDown can clean them up (also ensure the
injected dataset_name_or_id test keeps the path substitution to self.test_dir).

Originally posted by @coderabbitai[bot] in #8885 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions