anomalib icon indicating copy to clipboard operation
anomalib copied to clipboard

[Task]: Missing modules may fail silently

Open djdameln opened this issue 1 year ago • 3 comments

What is the motivation for this task?

Missing modules may go unnoticed due to the exception handling at the top of cli.py here.

When one of the imports in lines 28 to 35 fails due to a missing module, anomalib gives the following output, hiding the issue from the user:

anomalib train --model Padim --data MVTec
To use other subcommand using `anomalib install`
Usage: anomalib [-h] [-c CONFIG] [--print_config [=flags]] {install} ...
error: argument subcommand: invalid choice: 'train' (choose from 'install')

I guess this is intended to check if anomalib install has previously been called. But the above behaviour may also occur when anomalib install has been called, but a required package is missing in the environment. In this case it would be better to let the user know which package is missing.


To reproduce, add an import to one of the submodules of anomalib, e.g. add import missing_package to this file, and then try to call the training entrypoint of the CLI.

Describe the solution you'd like

The user should be notified about the missing module.

Additional context

No response

djdameln avatar Jun 26 '24 13:06 djdameln

On this, there are ways to enhance the log output and i will going to do that, @samet-akcay but what do you think about providing an additional anomalib doctor that is the command I suggested with otx install, which diagnoses which libraries are installed and whether each subcommand will work?

harimkang avatar Jul 31 '24 05:07 harimkang

@harimkang, I agree. doctor would be nice to have, which would be similar to brew doctor.

As can be seen from the recent issues, there are many users experiencing installation issues. doctor would be helpful to identify the potential issues

samet-akcay avatar Jul 31 '24 05:07 samet-akcay

I had the same output given to me by anomalib.

Took a while to find the issue due to the above, actual issue was:

from anomalib.engine import Engine Failing due to: ImportError: cannot import name '_encode_image' from 'ollama._client'

margalordyzd avatar Dec 06 '24 16:12 margalordyzd

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 13 '25 05:07 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Jul 27 '25 05:07 github-actions[bot]