Hydra for Python
Project description
HydraPy
Hydra for Python
- NOTE THIS PROJECT IS IN VERY EARLY DEVELOPMENT
- HydraPy is changing quickly and not recommended for use at this time
* HydraPy requires Python 3.7+ and aioredis==1.3.1 or greater
Hydra is an approach to building light-weight microservices by leveraging the awesome power of the Redis database platform.
HydraPy is a nextgen port of the NodeJS implementation of Hydra with a goal of offering the same level of ease of use to the Python community. We hope this will empower data scientists to build containerized microservices for their AI/ML applications.
The Hydra approach was first presented at the 2006 EmpireNode conference in New York City where Hydra for NodeJS was open sourced.
The following describes the approach:
Usage
Installation
https://pypi.org/project/hydra-py/
Import
from hydrapy import HydraPy, hydra_route, UMF_Message
Route registration
Routes which do not require HydraPy functions can be defined as:
hydra_route('/', ['GET'])
@app.route('/', methods=['GET'])
async def home():
return 'Sample Service'
Note we still call the hydra_route function so that HydraPy will know about this function even if the function itself does not call HydraPy functions. This is required for routing.
Routes that do depend on HydraPy must be declared after HydraPy has been initialized.
hydra = HydraPy(config_path='./config.json', version=service_version, message_handler=hydra_message_handler)
si = await hydra.init()
hydra_route('/v1/sample/health', ['GET'])
@app.route('/v1/sample/health', methods=['GET'])
async def health():
return {
'result': hydra.get_health()
}
await hydra.register_routes()
Example services
There are two example services available:
sample-service
message-sample-service
Development
Build the sample-service
The service can be built as a debug and non-debug container.
Debug
$ cd sample-service
$ ./build-debug.sh
Non-debug
$ cd sample-service
$ ./build.sh
Start the support cluster
$ cd docker
$ ./startup.sh
Web interfaces
HydraRouter: http://localhost:5353 RedisInsight: http://localhost:8001
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.