Skip to content

Quality: Broken optional dependency handling for PyTorch#660

Open
tuanaiseo wants to merge 1 commit intoyzhao062:masterfrom
tuanaiseo:contribai/improve/quality/broken-optional-dependency-handling-for-
Open

Quality: Broken optional dependency handling for PyTorch#660
tuanaiseo wants to merge 1 commit intoyzhao062:masterfrom
tuanaiseo:contribai/improve/quality/broken-optional-dependency-handling-for-

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

pyod/models/gaal_base.py tries to handle missing torch with a try/except, but immediately performs an unconditional import torch afterwards. If PyTorch is not installed, the module still crashes at import time, and the printed message is misleading.

Severity: high
File: pyod/models/gaal_base.py

Solution

Remove the second unconditional import torch and raise a clear ImportError with actionable installation guidance, or gate GAAL-specific code behind lazy imports.

Changes

  • pyod/models/gaal_base.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

`pyod/models/gaal_base.py` tries to handle missing `torch` with a `try/except`, but immediately performs an unconditional `import torch` afterwards. If PyTorch is not installed, the module still crashes at import time, and the printed message is misleading.

Affected files: gaal_base.py

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
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.

1 participant