Anything World API wrapper library and CLI
Project description
Anything World Python Client
Python library and CLI for Anything World API.
:warning: Please make sure to follow our guidelines
on preparing your 3D model for success before sending them to be animated,
by using our /animate
endpoint.
For more information of what changed between versions, please check the CHANGELOG file.
Installing
pip install anything-world
Using
First of all, create a new .env
file with the right API key and URLs:
AW_API_KEY=<YOUR API KEY>
AW_API_URL=https://api.anything.world
AW_POLLING_URL=https://api.anything.world/user-processed-model
From Python
This library provides both synchronous and asynchronous implementations.
The sync implementation is based on requests
and tries to keep dependencies
at minimum (i.e. no need to install asyncio
nor aiohttp
). However,
if you use-case requires async calls, please follow the next section for its
implementation.
Sync
from anything_world.sync_api import AWClient
# Create a client to be able to query Anything World's API
client = AWClient()
# Search for 3D models of `cats`:
response = client.find('cats')
# Upload files from ./examples/cat folder to be animated
response = client.animate('./examples/cat', 'some_cat', 'cat', is_symmetric=True)
# Response has the model_id of the 3D model that our AI pipeline is currently animating
model_id = response["model_id"]
# Runs a long-polling loop, starting it only after 2 minutes and after that,
# checking every 5 secs if the API is done animating the model
animated_response = client.get_animated_model(model_id, waiting_time=5, warmup_time=120)
# Check if our AI pipeline is done animating the model
is_finished = client.is_animation_done(model_id)
assert is_finished == True
Async
import asyncio
from anything_world.async_api import AWClient
# Create a client to be able to query Anything World's API
client = AWClient()
# Search for 3D models of `cats`:
response = asyncio.run(
client.find('cats'))
# Upload files from ./examples/cat folder to be animated
response = asyncio.run(
client.animate('./examples/cat', 'some_cat', 'cat', is_symmetric=True))
# Response has the model_id of the 3D model that our AI pipeline is currently animating
model_id = response["model_id"]
# Runs a long-polling loop, starting it only after 2 minutes and after that,
# checking every 5 secs if the API is done animating the model
animated_response = asyncio.run(
client.get_animated_model(model_id, waiting_time=5, warmup_time=120))
# Check if our AI pipeline is done animating the model
is_finished = asyncio.run(
client.is_animation_done(model_id))
assert is_finished == True
From CLI
All AWClient
methods are exposed as commands of the anything
CLI tool.
Just call the anything
tool and it will display a manual page of the
available commands:
anything
You can do exactly the same we did in Python before through the CLI:
anything find <QUERY STRING>
anything animate ./examples/cat "some cat" "cat" --is_symmetric
anything get_animated_model <MODEL_ID>
...
Developing
Installing from source
git clone git@github.com:anythingworld/anything-world-python.git
cd anything-world-python
python3 -m venv venv
source venv/bin/activate
pip install -e .
Testing
pytest -v -s
Releasing a new pip package
Bump the version in pyproject.toml
and then:
rm -rf dist/*
python3 -m build
python3 -m twine upload dist/*
License
This Python module has a MIT-style license, as found in the LICENSE file.
The cat model in examples/cat
folder is from Google Poly (CC-BY 4.0) license.
The ASCII logo was generated by https://patorjk.com/software/taag/ using the original font fuzzy.flf by Juan Car (jc@juguete.quim.ucm.es).
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 anything_world-0.1.1.tar.gz
.
File metadata
- Download URL: anything_world-0.1.1.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 095be6849cd54c5e34fd8a0198a901c6e7b6fd9468ddaaabec135fb2ff8ce239 |
|
MD5 | a3e72beed1e680cd7e1f3ecae667d961 |
|
BLAKE2b-256 | c63b00be69c688690402af085255887bbf047ea7e1cc09cefe34e88dd115b2eb |
File details
Details for the file anything_world-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: anything_world-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c126878efa03f979f791a9e0c4d10f7cb918451c930b362bfadd11ba154bf348 |
|
MD5 | ccec3d6c8140f65f937fd4e88f41203e |
|
BLAKE2b-256 | 675bbb18401774208487eba578f93087cbdae43f955cd70dec1a1463e0aa25a3 |