Metadata-Version: 2.1
Name: yapapi
Version: 0.1.0
Summary: Hi-Level API for Golem The Next Milestone
License: LGPL-3.0-or-later
Author: Przemysław K. Rekucki
Author-email: przemyslaw.rekucki@golem.network
Requires-Python: >=3.6.1,<4.0.0
Classifier: Development Status :: 1 - Planning
Classifier: Framework :: AsyncIO
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: System :: Distributed Computing
Requires-Dist: aiohttp (>=3.6.2,<4.0.0)
Requires-Dist: dataclasses (>=0.7,<0.8); python_version >= "3.6" and python_version < "3.7"
Requires-Dist: urllib3 (>=1.25.9,<2.0.0)
Requires-Dist: ya-market (>=0.1.0,<0.2.0)
Description-Content-Type: text/markdown

# Golem Python API

![Continuous integration](https://github.com/prekucki/yapapi/workflows/Continuous%20integration/badge.svg)

## How to use

Rendering

```python
from yapapi.runner import Engine, Task, vm
from datetime import timedelta

async def main():
    package = await vm.repo(image_hash = 'ef007138617985ebb871e4305bc86fc97073f1ea9ab0ade9ad492ea995c4bc8b')

    async def worker(ctx, tasks):
        ctx.send_file('./scene.blend', '/golem/resource/scene.blend')
        async for task in tasks:
            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': [task.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_{task.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(frame=frame) for frame in range(1,101) ]):
            print("progress=", progress)
```

