Hydra for Python
Project description
HydraPy
Hydra for Python
- NOTE THIS PROJECT IS IN VERY EARLY DEVELOPMENT
* HydraPy requires Python 3.7+ and aioredis==1.3.1 or greater
- If using this version with HydraRouter it's important to refresh hydra router after your test container is loaded.
- $ curl localhost:5353/v1/router/refresh
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
Import
from hydra import HydraPy
from hydra import hydra_route
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(redis, hydra_config)
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()
Development
Build the sample-service
The service can be built as a debug and non-debug container.
Debug
$ cd sample-service
$ ./build-debug.sh 1.0.0
Non-debug
$ cd sample-service
$ ./build.sh 1.0.0
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.
Source Distribution
Built Distribution
File details
Details for the file hydra-py-0.1.2.tar.gz
.
File metadata
- Download URL: hydra-py-0.1.2.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ebc157a0c71c102e50545480d621410629a7349dd34b3b50e14eb254be84151 |
|
MD5 | 0c9fd0786466146df821c339de9e0fa9 |
|
BLAKE2b-256 | 3acd61ee4b5d91c72369f8f1ed7834bf6a233c96425c77a6338569a88103be6a |
Provenance
File details
Details for the file hydra_py-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: hydra_py-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1107e138c8038ab9cb4ef1fa41f4466737c52b92640b7106e822fbdc476b9fdc |
|
MD5 | 1e61a3f478581fe95922aef2de898623 |
|
BLAKE2b-256 | ddff163a50e915dd37038eb9f762643f4984812f17313e850b454dde07ccf262 |