Skip to content

index_videos.py calls sys.exit() at import time on missing deps #9

Description

@niranjans

What

The dependency check at the top of src/framedex/index_videos.py runs at module import time and calls sys.exit(1) on a missing dependency:

try:
    import requests
    import whisperx
    import yaml
except ImportError as e:
    print(f"Missing dependency: {e}", file=sys.stderr)
    print("Run: uv pip install -e .", file=sys.stderr)
    sys.exit(1)

Because this sits at module top level, it fires the instant anything does import framedex.index_videos — including from framedex.index_videos import some_function.

Why it's a problem

  • A module shouldn't terminate the process. A failed import should raise ImportError and let the caller decide. Here the module unilaterally kills the whole program — that's the application's call, not a library file's.
  • The module can't be imported without the full heavy stack. Reusing or testing a single function from index_videos.py requires whisperx (→ torch, multi-GB) to be installed, even for code paths that never touch it.
  • It already forced a workaround. The pure helpers were extracted into framedex/parsing.py specifically so they could be unit-tested without tripping this sys.exit. The root wart still lives in index_videos.py.
  • Now that people are forking and building on framedex, anyone with a partial install or library use case hits an abrupt process exit instead of a clean, catchable error.

Proposed fix

Move the dependency check off module top level. Either:

  • Lazy import — import whisperx etc. inside the functions that use them. Importing the module becomes cheap and safe.
  • Or check inside main() — exiting the process from the CLI entry point is legitimate, because there you are the process.

CLI behavior is unchanged: running fdx with deps missing still prints the same clear error. It just stops being hostile to plain imports.

Severity

Real, not urgent — the CLI works fine today. Worth a clean fix in its own PR. Happy to take this if no one's on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions