Skip to content

Commit a29324a

Browse files
authored
Merge pull request #569 from dkackman/develop
Release 0.6.0
2 parents f026a76 + e6c94c2 commit a29324a

354 files changed

Lines changed: 44555 additions & 21453 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/copilot-instructions.md‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
This is a declarative workflow engine for the HuggingFace Diffusers library that executes AI model pipelines via JSON configuration files.
44

5-
## REPL Worker Architecture (NEW)
5+
## Worker Architecture
66

7-
The REPL uses a **persistent worker subprocess** for workflow execution to maintain GPU model cache:
7+
`dw.serve` uses a **persistent worker subprocess** for workflow execution to maintain GPU model cache:
88
- Worker keeps models loaded in GPU across multiple runs
99
- Automatic workflow file change detection (SHA256 hash)
1010
- Aggressive memory cleanup between runs (gc.collect + torch.cuda.empty_cache)
@@ -14,17 +14,17 @@ The REPL uses a **persistent worker subprocess** for workflow execution to maint
1414

1515
**Key modules:**
1616
- `dw/worker.py` - Worker process with command loop and memory management
17-
- `dw/repl.py` - REPL with worker lifecycle (start/stop/restart)
17+
- `dw/worker_manager.py` - Worker lifecycle (start/stop/restart) for `JobManager`
1818
- Communication via `multiprocessing.Queue` (command_queue, result_queue)
1919

20-
**Worker commands:** execute, shutdown, ping, clear_memory, memory_status
20+
**Worker commands:** execute, cancel, shutdown, clear_memory, memory_status, probe_cache (typed messages in `dw/worker_protocol.py`; request/reply commands carry a `request_id`)
2121

2222
## Architecture Overview
2323

2424
**Core Components:**
25-
- `dw/workflow.py`: Main orchestrator - loads JSON workflows, handles variable substitution, manages step execution
25+
- `dw/workflow.py`: Main orchestrator - loads JSON workflows, handles variable substitution, manages step execution (the run's phases live in `dw/workflow_run.py`, validation in `dw/validation.py`)
2626
- `dw/step.py`: Individual workflow step executor - runs pipelines/tasks/sub-workflows
27-
- `dw/pipeline_processors/pipeline.py`: Manages HuggingFace pipeline loading, configuration, and shared components
27+
- `dw/pipeline_processors/pipeline.py`: The `Pipeline` class - HuggingFace pipeline loading and shared components (placement, component loading, adapters and progress reporting are beside it in `placement.py`, `components.py`, `adapters.py`, `progress.py`)
2828
- `dw/tasks/task.py`: Executes utility tasks (image processing, QR codes, data gathering)
2929
- `dw/previous_results.py`: Handles cross-step data flow using cartesian products of previous results
3030

@@ -72,7 +72,7 @@ The REPL uses a **persistent worker subprocess** for workflow execution to maint
7272
**Execution:** `python -m dw.run workflow.json variable1=value1`
7373

7474
**Adding New Tasks:** Register a handler function in `dw/tasks/task.py` with the `@register_command("name")` decorator; `Task.run()` dispatches to the registry (falling back to image/video processor lookups for unregistered names)
75-
**Adding Pipeline Types:** Update `workflow_schema.json` and ensure proper component loading in `pipeline.py`
75+
**Adding Pipeline Types:** Update `workflow_schema.json` and ensure proper component loading in `pipeline_processors/components.py`
7676

7777
## Project-Specific Conventions
7878

@@ -91,13 +91,14 @@ The REPL uses a **persistent worker subprocess** for workflow execution to maint
9191

9292
## Security
9393

94-
**Critical security module** (`dw/security.py`) provides comprehensive input validation and protection:
94+
**Critical security modules**: `dw/security.py` provides comprehensive input validation and protection, and `dw/trust.py` gates the trust model for untrusted workflows:
9595
- **Path validation**: Prevents traversal attacks, validates file extensions, enforces directory restrictions
9696
- **Input sanitization**: Validates variable names (alphanumeric + underscore/hyphen only), string lengths, control characters
9797
- **Command safety**: Sanitizes subprocess arguments, blocks shell metacharacters, enforces `shell=False`
9898
- **URL validation**: Restricts to http/https schemes only
99+
- **Workflow trust**: Controls what untrusted workflows may import (`dw/trust.py`)
99100

100-
All entry points (run.py, validate.py, repl.py) use security validation. When adding features:
101+
All entry points (run.py, validate.py, serve.py) use security validation. When adding features:
101102
- Always validate paths with `validate_path()` or `validate_workflow_path()`
102103
- Use `validate_variable_name()` for user-provided variable names
103104
- Sanitize URLs with `validate_url()` before remote loading

‎.github/workflows/ci.yml‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,57 @@ jobs:
7575
- name: Build
7676
run: npm run build
7777

78+
e2e:
79+
# Playwright against a real dw.serve, on PRs into master only - the
80+
# release PR is where a stale spec has to be caught, and the job carries
81+
# the backend install as well as the browser
82+
if: github.event_name == 'pull_request' && github.base_ref == 'master'
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v7
86+
- uses: actions/setup-python@v7
87+
with:
88+
python-version: '3.12'
89+
cache: pip
90+
cache-dependency-path: |
91+
pyproject.toml
92+
requirements.txt
93+
requirements-test.txt
94+
- run: sudo apt-get update && sudo apt-get install -y libgl1 libglib2.0-0
95+
- name: Install torch (CPU)
96+
run: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
97+
- name: Install dependencies
98+
run: |
99+
pip install -r requirements.txt -r requirements-test.txt
100+
pip install git+https://github.com/huggingface/diffusers
101+
- uses: actions/setup-node@v7
102+
with:
103+
node-version-file: ui/.nvmrc
104+
cache: npm
105+
cache-dependency-path: ui/package-lock.json
106+
- name: Build the UI the fixture server serves
107+
working-directory: ui
108+
run: |
109+
npm ci
110+
npm run build
111+
- name: Install Chromium
112+
working-directory: ui
113+
run: npx playwright install --with-deps chromium
114+
- name: E2E tests
115+
working-directory: ui
116+
env:
117+
DW_E2E_PYTHON: python
118+
run: npx playwright test
119+
- name: Upload the Playwright report
120+
if: failure()
121+
uses: actions/upload-artifact@v7
122+
with:
123+
name: playwright-report
124+
path: |
125+
ui/playwright-report/
126+
ui/test-results/
127+
retention-days: 7
128+
78129
wheel:
79130
# The packaged artifact: SPA built into the wheel. Tags and manual runs
80131
# only - the jobs above already prove the build on every push.

‎.vscode/launch.json‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@
5454
"PYTHONPATH": "${workspaceFolder}"
5555
}
5656
},
57-
{
58-
"name": "REPL",
59-
"type": "debugpy",
60-
"request": "launch",
61-
"module": "dw.repl",
62-
"cwd": "${workspaceFolder}/",
63-
"justMyCode": true,
64-
"args": []
65-
},
6657
{
6758
"name": "validate file",
6859
"type": "debugpy",

0 commit comments

Comments
 (0)