Skip to content
Snippets Groups Projects
README.md 1.07 KiB
Newer Older
Tim Schoof's avatar
Tim Schoof committed
# AsapoWorker

Tim Schoof's avatar
Tim Schoof committed
A toolkit to simplify the creation of ASAP::O workers.
Tim Schoof's avatar
Tim Schoof committed

> This project is in an early stage of development and should be used with caution


## Installation

AsapoWorker requires

Tim Schoof's avatar
Tim Schoof committed
* python >= 3.5
Tim Schoof's avatar
Tim Schoof committed
* ASAP::O consumer
* ASAP::O producer
Tim Schoof's avatar
Tim Schoof committed

Download the latest release and extract it. Optionally run

```
$ cd AsapoWorker
$ pip install .
```

## Usage example

* Create a AsapoWorker application
```
Tim Schoof's avatar
Tim Schoof committed
from AsapoWorker import Configurable, Config, Worker, Application, AsapoSender
Tim Schoof's avatar
Tim Schoof committed
from MyAnalyis import analyse

@Configurable
class MyWorker(Worker):
    myparameter = Config(
        "A configurable parameter", type=float)

    def process(self, data):
Tim Schoof's avatar
Tim Schoof committed
        data, metadata = analyse(data, self.myparameter)
        self.send(data, metadata)
Tim Schoof's avatar
Tim Schoof committed

if __name__ == "__main__":
Tim Schoof's avatar
Tim Schoof committed
    app = Application(worker_class=MyWorker, producer_class=AsapoSender)
Tim Schoof's avatar
Tim Schoof committed
    app.run()
```
* Start the worker
```
python path/to/worker.py \
Tim Schoof's avatar
Tim Schoof committed
    --receiver.stream in_stream_name \
    --sender.stream out_stream_name \
Tim Schoof's avatar
Tim Schoof committed
    --worker.myparameter 1.23
```

## Contribution

Please feel free to open issues or pull requests.