Skip to content

fix(train): move GitStatusChecker out of module level to prevent Dock…#144

Merged
DeepKnowledge1 merged 1 commit into
mainfrom
fix/move-git-status-checker-to-main
May 5, 2026
Merged

fix(train): move GitStatusChecker out of module level to prevent Dock…#144
DeepKnowledge1 merged 1 commit into
mainfrom
fix/move-git-status-checker-to-main

Conversation

@DeepKnowledge1
Copy link
Copy Markdown
Owner

Problem

The GitStatusChecker was instantiated and executed at module level in train.py:

# Ran on every import — even for --help
checker = GitStatusChecker()
checker.check_status()

This caused two issues:

  1. Docker crashgit fetch fails inside containers that have no git remote, no SSH keys, or no git binary. Because subprocess.run uses check=True, it raises CalledProcessError and kills the process before training starts.
  2. Import side effect — any code that imports anomavision.train (including cli.py building the argument parser for --help) would trigger a network call unconditionally.

Fix

Moved the git check inside main() with two additional guards:

  • Only runs if actually inside a git repository (checker.is_repo())
  • Wrapped in try/except so a git failure never blocks training
try:
    checker = GitStatusChecker()
    if checker.is_repo():
        checker.check_status()
except Exception:
    pass  # Never block training over a git check

Impact

  • Fixes CLI commands not being accessible in Docker (related to #<issue_number>)
  • No change to training behavior
  • Git status check still runs when training locally inside a valid repo

Testing

  • anomavision train --help works inside Docker without errors
  • anomavision train --config config.yml runs successfully
  • Git status check still prints when running locally in a valid repo

@DeepKnowledge1 DeepKnowledge1 merged commit 5cfda81 into main May 5, 2026
5 checks passed
@DeepKnowledge1 DeepKnowledge1 deleted the fix/move-git-status-checker-to-main branch May 6, 2026 04:51
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