Metadata-Version: 2.4
Name: runner-pjpawel
Version: 0.1.4
Summary: Universal runner with builder objects to run async, threaded or group commands
Project-URL: Homepage, https://github.com/pjpawel/runner
Project-URL: Issues, https://github.com/pjpawel/runner/issues
Author-email: pjpawel <pjpawel@proton.me>
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# runner (runner-pjpawel)
Universal runner with builder objects to run async, threaded or group commands

*Build for my research projects to run multiple scenarios with retry with one command*

#### *Remember! This project is on early stage of development* 

### Install
```shell
pip install runner-pjpawel
```

### Build runner
1. Create Runner class.
```python
from runner_pjpawel import Runner
runner = Runner()
```
2. Add commands. Use prepared `Command` classes in `runner.commands` module or classes that extends `runnner.command.BaseCommand`
```python
from runner_pjpawel.command.common import ShellCommand
shell = ShellCommand("uname -a")
runner.add_command(shell)
```
3. Invoke `run` or `run_sync` method.
```python
runner.run_sync()
```

### Existing commands
 - **ShellCommand** - executes shell command with subprocess.Popen
 - **GroupCommand** - treats all commands as one, allow to execute reset callback before retry
 - **ParallelCommand** - run commands in separate threads in parallel

### Commands to be implemented
 - **CyclicCommand** - Handles job than should be run more than once
 - **ThreadCommand** - Run callable in separate thread

### Build new commands
You can build you own command. To do so, create class that extend class `BaseCommand`.
You have to override `_do_work` method.
```python
class YourCommand(BaseCommand):
    def _do_work(self) -> CommandResult | None:
        ...
```



### Full examples

1. Simplest example
```python
from runner_pjpawel import Runner
from runner_pjpawel.command import ShellCommand

r = Runner(show_progress_bar=False)
r.add_command(ShellCommand("uname"))
r.run_sync()
    
```




