main to feat#145
Open
DeepKnowledge1 wants to merge 2 commits into
Open
Conversation
#144) ## Problem The `GitStatusChecker` was instantiated and executed at **module level** in `train.py`: ```python # Ran on every import — even for --help checker = GitStatusChecker() checker.check_status() ``` This caused two issues: 1. **Docker crash** — `git 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 ```python 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issue
Fixes #
📝 Description
🔄 Type of Change
🧪 Hardware & Matrix Testing
I have successfully built and tested this code using
uvon:anomavision[cpu](Standard/Edge)anomavision[cu121](CUDA 12.1)anomavision[cu124](CUDA 12.4)anomavision[cu118](CUDA 11.8)Host OS used for testing:
✅ Developer Checklist
uv run pytestand all unit tests pass locally.pyproject.toml, I have runuv lock --python 3.10and committed the updateduv.lockfile.📸 Screenshots / Visual Proof (Optional)