Skip to content

Fix user-facing API bugs - #175

Open
MarcelRosier wants to merge 3 commits into
mainfrom
163-fix-user-facing-api-bugs-preprocessing-missingmri-logging
Open

Fix user-facing API bugs#175
MarcelRosier wants to merge 3 commits into
mainfrom
163-fix-user-facing-api-bugs-preprocessing-missingmri-logging

Conversation

@MarcelRosier

@MarcelRosier MarcelRosier commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes the user-facing API issues tracked in #163:

  • Dispatch preprocess_for_challenge by concrete challenge-specific Algorithms enum subclasses and reject raw string values.
  • Raise descriptive FileNotFoundError exceptions for missing MRI outputs in MissingMRI inference.
  • Preserve user-configured Loguru handlers when importing BraTS.
  • Use lazy output lookup and restore logging state in tests.
  • Keep the tutorial logging example compatible with the package default logging state.

Verification

  • uv run --python 3.9 pytest
  • uv run ruff check .
  • uv run ruff format --check .
  • mkdocs build --strict

Closes #163

Copilot AI left a comment

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.

Pull request overview

This PR addresses several user-facing API issues in the BraTS orchestrator by making preprocessing dispatch stricter and explicit, improving MissingMRI failure behavior when container outputs are missing, and preventing import brats from wiping out user-configured Loguru handlers.

Changes:

  • Updated preprocess_for_challenge to dispatch via explicit isinstance checks on supported Algorithms enum subclasses and to reject raw (non-enum) inputs with a TypeError.
  • Replaced StopIteration-style failures in MissingMRI output handling with descriptive FileNotFoundErrors for both single and batch inference.
  • Adjusted package import-time logging behavior to preserve user Loguru handlers, and added/updated tests covering these behaviors.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
brats/preprocessing.py Makes preprocessing dispatch explicit by enum subclass and rejects non-enum inputs.
brats/core/brats_algorithm.py Raises descriptive FileNotFoundError when MissingMRI outputs are absent.
brats/__init__.py Disables brats namespace logging without removing user-installed Loguru handlers.
tests/test_preprocessing.py Adds tests for preprocessing dispatch correctness and raw-value rejection.
tests/core/test_missing_mri_algorithms.py Adds tests asserting MissingMRI inference raises FileNotFoundError on missing outputs.
tests/utils/test_logging.py Adds a regression test ensuring user Loguru handlers survive import brats / reload.
tests/utils/test_data_handling.py Enables brats logging in a test to ensure log files are non-empty under the new default-disable behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread brats/core/brats_algorithm.py Outdated
Comment thread brats/core/brats_algorithm.py Outdated
Comment thread tests/utils/test_data_handling.py Outdated
Comment thread brats/preprocessing.py
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.

Fix MissingMRI output errors, preserve Loguru handlers, and clarify preprocessing dispatch

2 participants