Skip to content

refactor: unify registry bootstrap and remove silent exception swallowing - #202

Merged
TATP-233 merged 1 commit into
mainfrom
fix/issue-166-unify-registry-bootstrap
Apr 10, 2026
Merged

TATP-233 merged 1 commit into
mainfrom
fix/issue-166-unify-registry-bootstrap

Conversation

@TATP-233

Copy link
Copy Markdown
Collaborator

Summary

Fixes #166

This PR unifies the registry bootstrap implementation and removes the silent exception swallowing behavior.

Changes

1. Refactored ensure_registries() in src/unilab/utils/algo_utils.py

  • Fail loud by default: Changed from except Exception: pass to raising exceptions by default
  • Added optional_packages parameter: Allows specifying packages that may not be present (failures are logged as warnings)
  • Added fail_on_error parameter: Allows non-optional packages to fail gracefully with warnings when set to False
  • Improved error messages: Clear guidance on how to fix import errors

2. Removed duplicated bootstrap logic

  • scripts/play_interactive.py: Now imports ensure_registries from unilab.training instead of having its own copy-pasted implementation

3. Added comprehensive tests

New test cases in tests/utils/test_algo_utils.py:

  • test_fail_on_error_default_raises: Verifies default fail-loud behavior
  • test_fail_on_error_false_logs_warning: Verifies graceful degradation mode
  • test_optional_package_logs_warning: Verifies optional packages log warnings
  • test_mixed_optional_and_required: Verifies mixed usage works correctly
  • test_empty_packages_list: Verifies empty list is a no-op

Backward Compatibility

  • Default behavior changes from silent swallow to fail-loud (intentional breaking change per issue requirements)
  • Existing scripts using ensure_registries() without arguments continue to work
  • Optional modules can be explicitly marked to maintain graceful degradation

Validation

  • make test passes (373 passed, 5 skipped)
  • All new test cases pass

Related

…wing (fixes #166)

- Refactor ensure_registries() to fail loud by default
- Add optional_packages parameter for graceful degradation
- Add fail_on_error parameter for flexible error handling
- Remove duplicated ensure_registries() from play_interactive.py
- Add comprehensive tests for new behavior
- Scripts now use unified ensure_registries from unilab.training
@TATP-233
TATP-233 merged commit 9677c2b into main Apr 10, 2026
5 checks passed
@TATP-233
TATP-233 deleted the fix/issue-166-unify-registry-bootstrap branch April 10, 2026 09:21
Jaui7 pushed a commit that referenced this pull request Apr 14, 2026
…ootstrap

refactor: unify registry bootstrap and remove silent exception swallowing
TATP-233 added a commit that referenced this pull request May 4, 2026
…ootstrap

refactor: unify registry bootstrap and remove silent exception swallowing
TATP-233 added a commit that referenced this pull request May 30, 2026
…ootstrap

refactor: unify registry bootstrap and remove silent exception swallowing
TATP-233 added a commit that referenced this pull request Sep 4, 2026
…ootstrap

refactor: unify registry bootstrap and remove silent exception swallowing
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.

Work: 统一 registry bootstrap 并移除静默吞异常

1 participant