Skip to content

API crashes on import when commonforms dependencies are missing #345

@SahilRakhaiya05

Description

@SahilRakhaiya05

While setting up the project in a clean environment, I noticed that just importing api.main crashes if dependencies like cv2, numpy, or ultralytics are not installed.

After debugging, this seems to come from a top-level import in src/file_manipulator.py:

from commonforms import prepare_form

Since commonforms pulls in heavy native dependencies at import time, the API fails to even start — even if that functionality is not used.

Impact

  • API cannot start in minimal environments
  • CI / Docker builds can fail
  • makes onboarding harder for new contributors

Possible fix

Move the import inside the function where it’s used (lazy import) and handle missing dependency with a clear error message.

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