BLUX-cA Repository Standards
This document summarizes the house style used across ca.py, ca/cli.py, and related modules. New code should align with these conventions.
CLI Conventions
- Use Typer for subcommands. Group related commands via
typer.Typerand attach withadd_typer. - Default output is concise and human-readable. Prefer Rich tables or
console.print_jsonwhen structured output is needed. - Non-zero exit codes signal user-facing errors; raise
typer.Exit(code=1)orSystemExit(1)after printing a clear message. - Provide
--helpfor every command and avoid hidden flags. Respect environment overrides such asDATASET_DIR,BASE_MODEL, andRUN_NAMEwhen present.
Logging and Output
- Rely on lightweight logging: Rich console output for user-facing flows;
printonly for simple scripts. Avoid noisy debug logs unless explicitly requested. - For background helpers, prefer the standard
loggingmodule with INFO defaults and DEBUG gated by env flags.
Configuration
- Store defaults in versioned YAML (e.g.,
train/configs/). - Precedence: environment variables > CLI flags > config file defaults.
- Validate configuration early and fail fast with actionable error text.
Error Handling
- Catch expected user errors (missing paths, invalid config) and present actionable messages before exiting non-zero.
- Let unexpected exceptions propagate to aid debugging during development.
Paths and Filesystem
- Use
pathlib.Pathfor all filesystem interactions and support execution from any working directory. - Resolve repo-relative paths via
Path(__file__).resolve()parents when needed instead of relying on CWD. - Write generated artifacts to
runs/(gitignored) and avoid committing binaries or checkpoints.
Code Style
- Target Python 3.10+ with type hints on public functions and return types.
- Keep functions small and focused. Include brief module and function docstrings describing intent and behavior.
- Follow
blackformatting andrufflint rules defined inpyproject.toml.
Testing and Tooling
- Provide
python -m compileall-clean code for scripts. - Add smoke checks for CLI entrypoints (
blux-ca --help, doctor checks, training--help). - Use pytest for automated tests; keep smoke tests fast and GPU-optional.