mirror of
https://github.com/vladmandic/automatic
synced 2026-08-31 09:31:00 +02:00
a2ca7fe944
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2.3 KiB
2.3 KiB
description, name, applyTo
| description | name | applyTo |
|---|---|---|
| Use when editing Python core runtime code, startup flow, model loading, API internals, backend/device logic, or shared state in modules and pipelines. | Core Runtime Guidelines | launch.py, webui.py, installer.py, modules/**/*.py, pipelines/**/*.py, scripts/**/*.py, extensions-builtin/**/*.py |
Core Runtime Guidelines
- Preserve startup ordering and import timing in
launch.pyandwebui.py; avoid moving initialization steps unless required to fix a critical startup bug or implement a new startup feature. - Treat
modules/shared.pyas the source of truth for global runtime state (shared.opts, model references, backend/device flags). - Prefer narrow changes (changes scoped to a single function or module when feasible) with explicit side effects; avoid introducing new cross-module mutable globals.
- Keep platform paths neutral: do not assume CUDA-only behavior and preserve ROCm/IPEX/DirectML/OpenVINO compatibility branches.
- Keep extension and script loading resilient: when adding startup scans/hooks, preserve partial-failure tolerance and logging.
- Follow existing API/server patterns under
modules/api/and reuse shared queue/state helpers rather than ad-hoc request handling. - Reuse established model-loading and pipeline patterns (
modules/sd_*,pipelines/) instead of creating parallel abstractions. - For substantial Python changes, run at least relevant checks:
npm run ruffandnpm run pylint(or narrower equivalents when appropriate).
Build And Test
- Activate environment:
source venv/bin/activate(always ensure this is active when working with Python code). - Test startup:
python launch.py --test - Full startup:
python launch.py - Full lint sequence:
pnpm lint - Python checks individually:
pnpm ruff,pnpm pylint - JS checks:
pnpm eslintandpnpm eslint-ui
Pitfalls
- Initialization order matters: startup paths in
launch.pyandwebui.pyare sensitive to import/load timing. - Shared mutable global state can create subtle regressions; prefer narrow, explicit changes.
- Device/backend-specific code paths (CUDA/ROCm/IPEX/DirectML/OpenVINO) should not assume one platform.
- Scripts and extension loading is dynamic; failures may appear only when specific extensions or models are present.