Convert your python function into a hosted endpoint with minimal changes to your existing code
Project description
Eden
You were in Eden, the garden of God. Every kind of precious stone adorned you: ruby, topaz, and diamond, beryl, onyx, and jasper, sapphire, turquoise, and emerald. Your mountings and settings were crafted in gold, prepared on the day of your creation.
Ezekiel 28:13
Eden helps you to deploy your AI art pipelines (or sometimes other stuff) as a hosted endpoint with support for multiple GPUs and scaling over multiple machines. If you're new here, check out the examples
pip install eden-python
Setting up a block
Hosting with eden requires minimal changes to your existing code. Each unit within eden is called a Block, they're the units which take certain inputs and generate art accordingly.
The first step is to configure run().
from eden.block import Block
from eden.datatypes import Image
eden_block = Block()
run() is supposed to be the function that runs every time someone wants to use this pipeline to generate art. For now it supports text, images, and numbers as inputs.
my_args = {
'prompt': 'let there be light', ## text
'number': 12345, ## numbers
'input_image': Image() ## images require eden.datatypes.Image()
}
@eden_block.run(args = my_args)
def do_something(config):
pil_image = config['input_image']
some_number = config['number']
return {
'text': 'hello world', ## returning text
'number': some_number, ## returning numbers
'image': Image(pil_image) ## Image() works on PIL.Image, numpy.array and on jpg an png files (str)
}
Hosting a block
from eden.hosting import host_block
host_block(
block = eden_block,
port= 5656,
logfile= 'logs.log',
log_level= 'info',
max_num_workers = 5
)
block(eden.block.Block): The eden block you'd want to host.port(int, optional): Localhost port where the block would be hosted. Defaults to8080.host(str): specifies where the endpoint would be hosted. Defaults to'0.0.0.0'.max_num_workers(int, optional): Maximum number of tasks to run in parallel. Defaults to4.redis_port(int, optional): Port number for celery's redis server. Defaults to6379.redis_host(str, optional): Place to host redis foreden.queue.QueueData. Defaults to"localhost".requires_gpu(bool, optional): Set this toFalseif your tasks dont necessarily need GPUs.log_level(str, optional): Can be 'debug', 'info', or 'warning'. Defaults to'warning'exclude_gpu_ids(list, optional): List of gpu ids to not use for hosting. Example:[2,3]. Defaults to[]logfile(str, optional): Name of the file where the logs would be stored. If set toNone, it will show all logs on stdout. Defaults to'logs.log'queue_name(str, optional): Name of the celery queue used for the block. Useful when hosting multiple blocks with the same redis. (defaults oncelery)
Client
A Client is the unit that sends requests to a hosted block.
from eden.client import Client
from eden.datatypes import Image
c = Client(url = 'http://127.0.0.1:5656', username= 'abraham')
After you start a task with run() as shown below, it returns a token as run_response['token']. This token should be used later on to check the task status or to obtain your results.
Note:
Image()is compatible with following types:PIL.Image,numpy.arrayand filenames (str) ending with.jpgor.png
config = {
'prompt': 'let there be light',
'number': 2233,
'input_image': Image('your_image.png') ## Image() supports jpg, png filenames, np.array or PIL.Image
}
run_response = c.run(config)
Fetching results/checking task status using the token can be done using fetch().
results = c.fetch(token = run_response['token'])
print(results)
Examples
- Hosting a Resnet18 inference endpoint with eden: server + client
- A very (very) minimal example which is good for starting out on eden: server + client
- Working with intermediate results: server + client
Prometheus metrics out of the box
Eden supports the following internal metrics (/metrics) which have been exposed via prometheus:
num_queued_jobs: Specifies the number of queued jobsnum_running_jobs: Specifies the number of running jobsnum_failed_jobs: Specifies the number of failed jobsnum_succeeded_jobs: Specifies the number of succeeded jobs
Development
Setup
git clone git@github.com:abraham-ai/eden.git
cd eden
python3 setup.py develop
Compile dependencies with pip-compile (this generates a requirements.txt file). You will need pip-tools installed for this to work (pip install pip-tools)
pip-compile requirements.in
You also have to install redis on your machine
sudo apt-get install redis-server
sudo service redis-server start
Optionally, if you want to stop redis after you're done then you can run:
sudo service redis-server stop
Runnning tests on your local machine can be done with:
sh test_local.sh
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eden-python-0.2.0.tar.gz.
File metadata
- Download URL: eden-python-0.2.0.tar.gz
- Upload date:
- Size: 35.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
493dcd41ebd0d193d7b3ea02d4aa9ccfcafa8f2df83d8f56e1734350d6318976
|
|
| MD5 |
29b370efd99c035cefbe75d7688ca901
|
|
| BLAKE2b-256 |
26b4d3bbc7bea01e6b1a4a6c72c9048366cd66d2288aec8121eba81631cfab84
|
File details
Details for the file eden_python-0.2.0-py3-none-any.whl.
File metadata
- Download URL: eden_python-0.2.0-py3-none-any.whl
- Upload date:
- Size: 42.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94bfae8db480c37f66420925b76c5961d0af059434b783b63f0cc71cb3b218ae
|
|
| MD5 |
3a4006e9581cb75459eaab1b5beefbe3
|
|
| BLAKE2b-256 |
6a4d8463d4b36e296d8161d58ab065ef3e1fcfa6427673681b2cda77701bd9b7
|