-
Notifications
You must be signed in to change notification settings - Fork 13
refactor(v2-review): fix timeout, extract auth module, fix security issues, update test suite #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
coketaste
wants to merge
11
commits into
develop
Choose a base branch
from
coketaste/v2-review-fix
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0c56710
refactor(v2-review): extract auth module, clean up credential loading…
coketaste d40b407
refactor(v2-review): extract shared login_to_registry and remove dead…
coketaste 70c5cb2
Resolved the comments of Github Copilot
coketaste 85774a3
fix(security): resolve GitHub Copilot review comments
coketaste c5c03f9
fix(timeout): handle None/0 sentinel so --timeout 0 disables timeout
coketaste e23ea68
test(v2-review): clean up test suite quality issues
coketaste 4c32e7d
Merge branch 'develop' into coketaste/v2-review-fix
coketaste c9161ea
fix(review): address Copilot review comments
coketaste ad4a270
chore: merge develop into coketaste/v2-review-fix
coketaste 7f0c617
docs(changelog): update [2.0.1] with all changes from coketaste/v2-re…
coketaste 8032bbb
fix(review): address additional Copilot review comments
coketaste File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Development Setup | ||
|
|
||
| ```bash | ||
| # Install in development mode with all dependencies | ||
| pip install -e ".[dev]" | ||
|
|
||
| # Optional: install Kubernetes support | ||
| pip install -e ".[all]" | ||
|
|
||
| # Setup pre-commit hooks | ||
| pre-commit install | ||
| ``` | ||
|
|
||
| ## Commands | ||
|
|
||
| ```bash | ||
| # Run all tests | ||
| pytest | ||
|
|
||
| # Run specific test file | ||
| pytest tests/unit/test_error_handling.py -v | ||
|
|
||
| # Run specific test class or function | ||
| pytest tests/unit/test_error_handling.py::TestErrorPatternMatching -v | ||
|
|
||
| # Run tests with coverage | ||
| pytest --cov=src/madengine --cov-report=html | ||
|
|
||
| # Skip slow tests | ||
| pytest -m "not slow" | ||
|
|
||
| # Format code | ||
| black src/ tests/ | ||
| isort src/ tests/ | ||
|
|
||
| # Lint | ||
| flake8 src/ tests/ | ||
|
|
||
| # Type check | ||
| mypy src/madengine | ||
|
|
||
| # Run all pre-commit checks | ||
| pre-commit run --all-files | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| madengine is a CLI tool for running AI/ML models in local Docker, Kubernetes, and SLURM environments. The entry point is `madengine.cli.app:cli_main` (registered as the `madengine` console script). | ||
|
|
||
| ### Layer Structure | ||
|
|
||
| **CLI Layer** (`src/madengine/cli/`) | ||
| - `app.py` — Typer app wiring, registers 5 commands: `discover`, `build`, `run`, `report`, `database` | ||
| - `commands/` — One file per command (build, run, discover, report, database) | ||
| - `constants.py` — `ExitCode` enum (`SUCCESS=0`, `FAILURE=1`, `BUILD_FAILURE=2`, `RUN_FAILURE=3`, `INVALID_ARGS=4`) | ||
|
|
||
| **Orchestration Layer** (`src/madengine/orchestration/`) | ||
| - `build_orchestrator.py` — `BuildOrchestrator`: discovers models, builds Docker images, writes `build_manifest.json` | ||
| - `run_orchestrator.py` — `RunOrchestrator`: reads or triggers builds, infers deployment target, delegates to local or distributed execution | ||
|
|
||
| **Core Layer** (`src/madengine/core/`) | ||
| - `context.py` — `Context` class: merges `additional_context` with system detection (GPU vendor, architecture, OS, ROCm path). Uses `ast.literal_eval()` to parse additional_context strings (not `json.loads` — pass Python dict repr, not JSON) | ||
| - `console.py` — `Console`: shell execution wrapper with live output support | ||
| - `docker.py` — Docker command wrapper | ||
|
|
||
| **Execution Layer** (`src/madengine/execution/`) | ||
| - `container_runner.py` — `ContainerRunner`: runs models from manifest via `docker run`, writes results to `perf.csv` | ||
| - `docker_builder.py` — `DockerBuilder`: builds images from Dockerfiles | ||
| - `container_runner_helpers.py` — Log error pattern scanning, timeout resolution | ||
|
|
||
| **Deployment Layer** (`src/madengine/deployment/`) | ||
| - `factory.py` — `DeploymentFactory`: Factory pattern, registers `SlurmDeployment` and `KubernetesDeployment` | ||
| - `base.py` — `BaseDeployment` abstract class, `DeploymentConfig` dataclass | ||
| - `kubernetes.py` / `slurm.py` — Concrete deployments; target is inferred by Convention over Configuration: presence of `"k8s"` or `"kubernetes"` key → K8s; `"slurm"` key → SLURM; neither → local | ||
| - `presets/` — JSON preset files for K8s/SLURM default configurations; auto-merged with minimal user configs | ||
| - `config_loader.py` — Loads and merges preset JSON with user-supplied config | ||
|
|
||
| **Utils** (`src/madengine/utils/`) | ||
| - `discover_models.py` — `DiscoverModels`: three discovery methods: root `models.json`, `scripts/{dir}/models.json`, or `scripts/{dir}/get_models_json.py` (dynamic) | ||
| - `gpu_tool_factory.py` / `gpu_tool_manager.py` — GPU vendor abstraction (AMD/NVIDIA) | ||
| - `gpu_validator.py` — ROCm installation detection, GPU vendor detection | ||
| - `config_parser.py` — `ConfigParser`: parses `--additional-context` and tools config | ||
|
|
||
| **Reporting** (`src/madengine/reporting/`) | ||
| - `update_perf_csv.py` — Writes/appends to `perf.csv` and `perf_entry.csv` | ||
| - `csv_to_html.py` / `csv_to_email.py` — Report generation | ||
|
|
||
| ### Key Data Flows | ||
|
|
||
| 1. **Build flow**: CLI → `BuildOrchestrator` → `DiscoverModels` (finds models by tags) → `DockerBuilder` (builds images) → writes `build_manifest.json` | ||
|
|
||
| 2. **Run flow**: CLI → `RunOrchestrator` → loads/generates `build_manifest.json` → infers target → `ContainerRunner` (local) or `DeploymentFactory` (K8s/SLURM) → writes `perf.csv` | ||
|
|
||
| 3. **`additional_context`**: User JSON/Python-dict string merged into `Context.ctx`. Context is parsed with `ast.literal_eval()`, so values can use Python dict syntax. Keys like `k8s`, `slurm`, `distributed`, `tools`, `pre_scripts`, `post_scripts` drive behavior. | ||
|
|
||
| 4. **Model definition**: Models defined in `models.json` with fields: `name`, `tags`, `dockerfile`, `scripts`, `n_gpus`, `args`, `timeout`, `skip_gpu_arch`, etc. | ||
|
|
||
| 5. **Script isolation**: During run, `scripts/common/` is populated from the madengine package (pre_scripts, post_scripts, tools) and cleaned up afterwards. The MAD project's own `scripts/` and `docker/` directories are preserved. | ||
|
|
||
| ### Deployment Target Inference | ||
|
|
||
| No explicit `"deploy"` field is needed. Target is inferred from config structure: | ||
| - `"k8s"` or `"kubernetes"` key present → Kubernetes deployment | ||
| - `"slurm"` key present → SLURM deployment | ||
| - Neither → local Docker execution | ||
|
|
||
| ### Test Structure | ||
|
|
||
| ``` | ||
| tests/ | ||
| ├── unit/ # Fast isolated tests with mocking | ||
| ├── integration/ # End-to-end with real Docker/system calls | ||
| ├── e2e/ # Full workflow tests | ||
| └── fixtures/ # Dummy models, scripts, and data for testing | ||
| ``` | ||
|
|
||
| Pytest config is in `pyproject.toml` under `[tool.pytest.ini_options]`. Test markers: `slow`, `integration`. | ||
|
|
||
| ### Code Style | ||
|
|
||
| - Black formatting, 88-character line length | ||
| - isort with `profile = "black"` | ||
| - Google-style docstrings | ||
| - Type hints required for public functions | ||
| - Conventional commits: `feat:`, `fix:`, `docs:`, `test:`, `refactor:`, `style:`, `perf:`, `chore:` |
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.