Part of Catalyst Ecosystem. Project manifest.
Installation
Common installation:
pip install -U reaction
Getting started
consumer.py:
import asyncio
from typing import List, Any
from reaction.rpc import RabbitRPC
class rpc(RabbitRPC):
URL = 'amqp://user:password@host'
@rpc()
def sync_square(*values) -> List[float]:
return [v ** 2 for v in values]
@rpc()
async def async_square(*values) -> List[float]:
await asyncio.sleep(1)
return [v ** 2 for v in values]
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.create_task(sync_square.consume())
loop.create_task(async_square.consume())
loop.run_forever()
client.py:
import asyncio
from consumer import sync_square, async_square
if __name__ == '__main__':
loop = asyncio.get_event_loop()
x = loop.run_until_complete(sync_square.call(2, 3))
y = loop.run_until_complete(async_square.call(4, 5, 6))
print(x) # 4, 9
print(y) # 16, 25, 36
loop.close()
Example
- Register telegram bot, achieve token
cd example && TG_TOKEN="telegram bot token goes here" docker-compose up --force-recreate --build- RabbitMQ web ui: http://127.0.0.1:15672/#/
- user: admin
- password: j8XfG9ZDT5ZZrWTzw62q
- Docs (you can submit requests from web ui): http://127.0.0.1:8000/docs#/
- Redoc: http://127.0.0.1:8000/redoc
- Telegram bot is ready to classify ants & bees, but you have to send files "as a photo"
Telegram bot quick howto
Install async telegram client first:
$ pip install aiotg
Then create your bot:
tgbot.py
from consumer import async_square
from aiotg import Bot, Chat
bot = Bot(api_token='telegram bot token goes here')
@bot.command('/start')
async def start(chat: Chat, match):
return chat.reply('Send me /square command with one float argument')
@bot.command(r"/square (.+)")
async def square_command(chat: Chat, match):
val = match.group(1)
try:
val = float(val)
square = await async_square.call(val)
resp = f'Square for {val} is {square}'
except:
resp = 'Invalid number'
return chat.reply(resp)
bot.run()
Metadata
Release files for reaction 20.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reaction-20.2.tar.gz | 6.6 kB | Without provenance | Details for reaction-20.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reaction-20.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for reaction-20.2-py2.py3-none-any.whl |
Total release size: 17.5 kB
Release files / reaction-20.2.tar.gz
| Download URL | reaction-20.2.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8eeeba74e35e76cdcd781c777a4629a5c9f512f61c6d91400e736574075a7deb
|
|
BLAKE2b-256 checksum How to use checksums |
3e71ed0b7b89b2e8b311d619718dd6c49de211d992b910f913576cfc3afad36a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Release files / reaction-20.2-py2.py3-none-any.whl
| Download URL | reaction-20.2-py2.py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
3c36fbe4a0d7d91a3bdcb339ed2775e18bc8e49edd077c03d20d257d4dcd100b
|
|
BLAKE2b-256 checksum How to use checksums |
759bc549eb02e2b5caf8e2dcfb6386fa82645ffaaf2e7fc3c6d682f0591d8187
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Security for reaction 20.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.