Commit 2924ba3
feat(cli): add --process-type option to override process execution mode (#183)
# Summary
Adds `--process-type` CLI option to `plugboard process run` for
switching between `LocalProcess` and `RayProcess` execution modes,
overriding YAML configuration. Uses `Literal` type for type-safe
validation.
# Changes
- **CLI Enhancement**
- Added `--process-type {local|ray}` option to `run` command with
`Literal["local", "ray"]` type
- Typer automatically validates input and shows helpful error messages
for invalid values
- **Schema Enhancement**
- Added `RAY_CONNECTOR_CLS_PATH` constant to connector schema for
consistency
- Implemented `ProcessSpec.override_process_type()` method with
mapping-based logic
- Method handles process type, connector builder, and state backend
updates atomically
- When switching to `ray`: `LocalProcess` → `RayProcess`,
`AsyncioConnector` → `RayConnector`, `DictStateBackend` →
`RayStateBackend`
- When switching to `local`: reverses the above transformations
- Preserves connector builder args during override
- Only modifies incompatible components (e.g., won't change
`RayConnector` when already on Ray)
- **Tests**
- Unit tests for local override and ray override
- Validation testing handled by typer's built-in Literal type support
**Example usage:**
```bash
# Override any YAML config to run locally
plugboard process run ray-config.yaml --process-type local
# Force Ray execution regardless of YAML
plugboard process run local-config.yaml --process-type ray
```
**Implementation Note:** The override logic is implemented in the schema
layer (`ProcessSpec.override_process_type()`) using a mapping-based
approach rather than hard-coded if/else branches in the CLI, keeping
business logic close to the data model and improving maintainability.
Type safety is enforced using `Literal` types, allowing typer to handle
validation automatically.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>CLI option to switch between local and Ray
process</issue_title>
> <issue_description>See
#49 (comment)
>
> We would like to be able to switch between Local and Ray processes
from the CLI.</issue_description>
>
> <agent_instructions>We need an option on the CLI to switch between
`RayProcess` and `LocalProcess` by overriding whatever is specified in
the input YAML. Note that when changing from local to ray, it is not
enough just to change the `Process` type: you will also need to make
sure the `connector_builder` and `State` type are changed if they are
specified in the YAML and not compatible with Ray.</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #60
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/plugboard-dev/plugboard/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: toby-coleman <13170610+toby-coleman@users.noreply.github.com>
Co-authored-by: Toby Coleman <toby@tobycoleman.com>
Co-authored-by: Toby Coleman <toby-coleman@users.noreply.github.com>1 parent bd69137 commit 2924ba3
5 files changed
Lines changed: 117 additions & 1 deletion
File tree
- plugboard-schemas/plugboard_schemas
- plugboard/cli/process
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
| |||
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
95 | 105 | | |
96 | 106 | | |
97 | 107 | | |
| |||
100 | 110 | | |
101 | 111 | | |
102 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
103 | 119 | | |
104 | 120 | | |
105 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
91 | 134 | | |
92 | 135 | | |
93 | 136 | | |
| |||
0 commit comments