Skip to main content

Hi-Level API for Golem The Next Milestone

Project description

Golem Python API

Tests - Status PyPI - Status PyPI version GitHub license GitHub issues

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


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.4.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yapapi-0.1.4-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file yapapi-0.1.4.tar.gz.

File metadata

  • Download URL: yapapi-0.1.4.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.3 Darwin/19.6.0

File hashes

Hashes for yapapi-0.1.4.tar.gz
Algorithm Hash digest
SHA256 78101e476d3b29f9e3d34fa5a8a04aef6a5a603baf7cefce11dfb001677e38bf
MD5 3624aab59a02cb5f00220ef32970feb6
BLAKE2b-256 878f8938fe956b1c1f0b978485c1ca09eb74a46c5f36f6d2c34758e5cf80c816

See more details on using hashes here.

File details

Details for the file yapapi-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: yapapi-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 32.5 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

Hashes for yapapi-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e6ba05619f27545051a83094571b4a1eabddf5fc97442d2a0b35216326bdb36b
MD5 0a18a939c58f70daf4957c078174336a
BLAKE2b-256 19de0987a5d21fd7fdb475ddc562a28728175afb9d04d6cc2de515d8846b4ce4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page