Skip to content

Commit e923c34

Browse files
committed
add class signature
1 parent c13d012 commit e923c34

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

src/advanced_concepts/custom_runners.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,35 @@ Custom runners need to implement two main protocols: `Runner` and `Execution`. T
1111
Your runner class needs to implement just one method:
1212

1313
```python
14-
def start_execution(self, metadata: Metadata) -> Execution:
15-
"""Start an execution for a specific tool.
16-
17-
Args:
18-
metadata: Information about the tool being executed (name, package, etc.)
14+
class MyRunner:
15+
def start_execution(self, metadata: Metadata) -> Execution:
16+
"""Start an execution for a specific tool.
1917
20-
Returns:
21-
An Execution object that will handle the actual command execution
22-
"""
18+
Args:
19+
metadata: Information about the tool being executed (name, package, etc.)
20+
21+
Returns:
22+
An Execution object that will handle the actual command execution
23+
"""
2324
```
2425

2526
### The Execution Protocol
2627

2728
The `Execution` object does the heavy lifting with four key methods:
2829

2930
```python
30-
def input_file(self, host_file: InputPathType, resolve_parent: bool = False, mutable: bool = False) -> str:
31-
"""Handle input files - return where the command should find them"""
31+
class MyExecution:
32+
def input_file(self, host_file: InputPathType, resolve_parent: bool = False, mutable: bool = False) -> str:
33+
"""Handle input files - return where the command should find them"""
3234

33-
def output_file(self, local_file: str, optional: bool = False) -> OutputPathType:
34-
"""Handle output files - return where they'll be stored on the host"""
35+
def output_file(self, local_file: str, optional: bool = False) -> OutputPathType:
36+
"""Handle output files - return where they'll be stored on the host"""
3537

36-
def params(self, params: dict) -> dict:
37-
"""Process or modify command parameters if needed"""
38+
def params(self, params: dict) -> dict:
39+
"""Process or modify command parameters if needed"""
3840

39-
def run(self, cargs: list[str], handle_stdout=None, handle_stderr=None) -> None:
40-
"""Actually execute the command"""
41+
def run(self, cargs: list[str], handle_stdout=None, handle_stderr=None) -> None:
42+
"""Actually execute the command"""
4143
```
4244

4345
## Example: Simple Custom Runner

0 commit comments

Comments
 (0)