{"id":13757224,"url":"https://github.com/catalyst-team/reaction","last_synced_at":"2025-05-05T21:33:19.788Z","repository":{"id":57460361,"uuid":"208425663","full_name":"catalyst-team/reaction","owner":"catalyst-team","description":"Convenient DL serving","archived":false,"fork":false,"pushed_at":"2021-09-13T05:57:58.000Z","size":161,"stargazers_count":72,"open_issues_count":1,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-29T12:56:15.653Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catalyst-team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"catalyst_team","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-09-14T10:40:40.000Z","updated_at":"2024-01-04T16:37:46.000Z","dependencies_parsed_at":"2022-08-28T13:53:16.726Z","dependency_job_id":null,"html_url":"https://github.com/catalyst-team/reaction","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst-team%2Freaction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst-team%2Freaction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst-team%2Freaction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catalyst-team%2Freaction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catalyst-team","download_url":"https://codeload.github.com/catalyst-team/reaction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223768617,"owners_count":17199394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T12:00:29.916Z","updated_at":"2024-11-13T15:01:13.591Z","avatar_url":"https://github.com/catalyst-team.png","language":"Python","funding_links":["https://patreon.com/catalyst_team"],"categories":["Python","2.For Experiment"],"sub_categories":["Experiments management"],"readme":"\u003cdiv align=\"center\"\u003e\n\n![Reaction logo](https://raw.githubusercontent.com/catalyst-team/catalyst-pics/master/pics/Reaction_Logo.png)\n\n**Convenient DL serving**\n\n![Build Status](https://github.com/catalyst-team/reaction/workflows/CI/badge.svg)\n[![CodeFactor](https://www.codefactor.io/repository/github/catalyst-team/reaction/badge)](https://www.codefactor.io/repository/github/catalyst-team/reaction)\n[![Pipi version](https://img.shields.io/pypi/v/reaction.svg)](https://pypi.org/project/reaction/)\n[![Docs](https://img.shields.io/badge/dynamic/json.svg?label=docs\u0026url=https%3A%2F%2Fpypi.org%2Fpypi%2Freaction%2Fjson\u0026query=%24.info.version\u0026colorB=brightgreen\u0026prefix=v)](https://catalyst-team.github.io/reaction/index.html)\n[![PyPI Status](https://pepy.tech/badge/reaction)](https://pepy.tech/project/reaction)\n\n[![Twitter](https://img.shields.io/badge/news-twitter-499feb)](https://twitter.com/CatalystTeam)\n[![Telegram](https://img.shields.io/badge/channel-telegram-blue)](https://t.me/catalyst_team)\n[![Slack](https://img.shields.io/badge/Catalyst-slack-success)](https://join.slack.com/t/catalyst-team-devs/shared_invite/zt-d9miirnn-z86oKDzFMKlMG4fgFdZafw)\n[![Github contributors](https://img.shields.io/github/contributors/catalyst-team/reaction.svg?logo=github\u0026logoColor=white)](https://github.com/catalyst-team/reaction/graphs/contributors)\n\n\u003c/div\u003e\n\nProject [manifest](https://github.com/catalyst-team/catalyst/blob/master/MANIFEST.md). Part of [Catalyst Ecosystem](https://docs.google.com/presentation/d/1D-yhVOg6OXzjo9K_-IS5vSHLPIUxp1PEkFGnpRcNCNU/edit?usp=sharing):\n- [Alchemy](https://github.com/catalyst-team/alchemy) - Experiments logging \u0026 visualization\n- [Catalyst](https://github.com/catalyst-team/catalyst) - Accelerated Deep Learning Research and Development\n- [Reaction](https://github.com/catalyst-team/reaction) - Convenient Deep Learning models serving\n\n---\n\n## Installation\n\nCommon installation:\n```bash\npip install -U reaction\n```\n\n## Getting started\n\n**consumer.py**:\n```python\nimport asyncio\nfrom typing import List, Any\nfrom reaction.rpc import RabbitRPC\n\n\nclass rpc(RabbitRPC):\n    URL = \"amqp://user:password@host\"\n\n\n@rpc()\ndef sync_square(*values) -\u003e List[float]:\n    return [v ** 2 for v in values]\n\n\n@rpc()\nasync def async_square(*values) -\u003e List[float]:\n    await asyncio.sleep(1)\n    return [v ** 2 for v in values]\n\n\nif __name__ == \"__main__\":\n    loop = asyncio.get_event_loop()\n    loop.create_task(sync_square.consume())\n    loop.create_task(async_square.consume())\n    loop.run_forever()\n```\n\n**client.py**:\n```python\nimport asyncio\nfrom consumer import sync_square, async_square\n\nif __name__ == \"__main__\":\n    loop = asyncio.get_event_loop()\n    x = loop.run_until_complete(sync_square.call(2, 3))\n    y = loop.run_until_complete(async_square.call(4, 5, 6))\n    print(x)  # 4, 9\n    print(y)  # 16, 25, 36\n    loop.close()\n```\n\n## Example\n* Register telegram bot, achieve token\n* `cd example \u0026\u0026 TG_TOKEN=\"telegram bot token goes here\" docker-compose up --force-recreate --build`\n* RabbitMQ web ui: http://127.0.0.1:15672/#/\n  * user: admin\n  * password: j8XfG9ZDT5ZZrWTzw62q\n* Docs (you can submit requests from web ui): http://127.0.0.1:8000/docs#/\n* Redoc: http://127.0.0.1:8000/redoc\n* Telegram bot is ready to classify ants \u0026 bees, you have to send files \"as a photo\" or \"as a file\"\n\n## Telegram bot quick howto\n\nInstall async telegram client first:\n```bash\n$ pip install aiotg\n```\n\nThen create your bot:\n\n**tgbot.py**\n```python\nfrom consumer import async_square\nfrom aiotg import Bot, Chat\n\nbot = Bot(api_token=\"telegram bot token goes here\")\n\n\n@bot.command(\"/start\")\nasync def start(chat: Chat, match):\n    return chat.reply(\"Send me /square command with one float argument\")\n\n\n@bot.command(r\"/square (.+)\")\nasync def square_command(chat: Chat, match):\n    val = match.group(1)\n    try:\n        val = float(val)\n        square = await async_square.call(val)\n        resp = f\"Square for {val} is {square}\"\n    except:\n        resp = \"Invalid number\"\n    return chat.reply(resp)\n\n\nbot.run()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatalyst-team%2Freaction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatalyst-team%2Freaction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatalyst-team%2Freaction/lists"}