Hi-Level API for Golem The Next Milestone
Project description
Golem Python API
How to use
Rendering
from yapapi.runner import Engine, Task, vm
from datetime import timedelta
async def main():
package = await vm.repo(
image_hash="ef007138617985ebb871e4305bc86fc97073f1ea9ab0ade9ad492ea995c4bc8b",
min_mem_gib=0.5,
min_storage_gib=2.0,
)
async def worker(ctx, tasks):
ctx.send_file("./scene.blend", "/golem/resource/scene.blend")
async for task in tasks:
frame = task.data
ctx.begin()
crops = [
{
"outfilebasename": "out",
"borders_x": [0.0, 1.0],
"borders_y": [0.0, 1.0],
}
]
ctx.send_json(
"/golem/work/params.json",
{
"scene_file": "/golem/resource/scene.blend",
"resolution": (800, 600),
"use_compositing": False,
"crops": crops,
"samples": 100,
"frames": [frame],
"output_format": "PNG",
"RESOURCES_DIR": "/golem/resources",
"WORK_DIR": "/golem/work",
"OUTPUT_DIR": "/golem/output",
},
)
ctx.run("/golem/entrypoints/render_entrypoint.py")
ctx.download_file("/golem/output/out.png", f"output_{frame}.png")
yield ctx.commit()
# TODO: Check if job is valid
# and reject by: task.reject_task(msg = 'invalid file')
task.accept_task()
ctx.log("no more frame to render")
async with Engine(
package=package,
max_worker=10,
budget=10.0,
timeout=timedelta(minutes=5),
) as engine:
async for progress in engine.map(
worker, [Task(data=frame) for frame in range(1, 101)]
):
print("progress=", progress)
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
yapapi-0.1.3.tar.gz
(27.0 kB
view details)
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
yapapi-0.1.3-py3-none-any.whl
(32.2 kB
view details)
File details
Details for the file yapapi-0.1.3.tar.gz.
File metadata
- Download URL: yapapi-0.1.3.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.8.3 Darwin/19.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c32a61a2cdce035c7f1798a3e5bb9eb7099f608b65e0f3e42e95729ea201b5ed
|
|
| MD5 |
ea01c55cf01a02fdecde09839e1b6503
|
|
| BLAKE2b-256 |
bc870c180938ad765e95f3b064991523eb4ca016b3856a70f546761b01edb033
|
File details
Details for the file yapapi-0.1.3-py3-none-any.whl.
File metadata
- Download URL: yapapi-0.1.3-py3-none-any.whl
- Upload date:
- Size: 32.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.10 CPython/3.8.3 Darwin/19.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14145078935d2d837d8fc109e7d133425836fd5a9e1ba387961bce45dc0827f5
|
|
| MD5 |
95937c93031f172048d2b071020c9def
|
|
| BLAKE2b-256 |
2e1f72d46c7e876ad43328aab0a439d4a653f9659047e8cd8597ea9430bf6e89
|