Build event-driven workflows with python functions
Project description
Install
Install from PyPi
pip install drive-events
Install from source
# clone this repo first
cd drive-events
pip install -e .
Quick Start
A hello world example:
import asyncio
from drive_events import EventInput, default_drive
@default_drive.make_event
async def hello(event: EventInput, global_ctx):
print("hello")
@default_drive.listen_groups([hello])
async def world(event: EventInput, global_ctx):
print("world")
asyncio.run(default_drive.invoke_event(hello))
In this example, The return of hello
event will trigger world
event.
To make an event function, there are few elements:
- Input Signature: must be
(event: EventInput, global_ctx)
EventInput
is the returns of the listening groups.global_ctx
is set by you when invoking events, it can be anything and default toNone
- Make sure you decorate the function with
@default_drive.make_event
or@default_drive.listen_groups([EVENT,...])
Then, run your workflow from any event:
await default_drive.invoke_event(EVENT, EVENT_INPUT, GLOBAL_CTX)
Check out examples for more user cases!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for drive_events-0.0.1.dev4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67bd0cf88dbf66c24daec273a44e95fbe93334d8bef5ee376848215f95377d0a |
|
MD5 | 8557e698bbd0dbbcb99a8fece3d99731 |
|
BLAKE2b-256 | 07e97502edf1a49c805e56d8b9c50bf6d139358a0821653b8800e9271648dcc3 |