{"id":14967137,"url":"https://github.com/golemfactory/pfaas","last_synced_at":"2025-10-19T09:31:39.029Z","repository":{"id":56101474,"uuid":"300330340","full_name":"golemfactory/pfaas","owner":"golemfactory","description":"Python's very own gfaas implementation - an experiment","archived":false,"fork":false,"pushed_at":"2020-12-19T17:35:16.000Z","size":26,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-28T07:42:39.145Z","etag":null,"topics":["function-as-a-service","golem","python","vm","ya-runtime"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/golemfactory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-01T15:35:05.000Z","updated_at":"2023-09-08T18:13:06.000Z","dependencies_parsed_at":"2022-08-15T13:10:37.378Z","dependency_job_id":null,"html_url":"https://github.com/golemfactory/pfaas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golemfactory%2Fpfaas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golemfactory%2Fpfaas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golemfactory%2Fpfaas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golemfactory%2Fpfaas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/golemfactory","download_url":"https://codeload.github.com/golemfactory/pfaas/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219877489,"owners_count":16554901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["function-as-a-service","golem","python","vm","ya-runtime"],"created_at":"2024-09-24T13:37:30.602Z","updated_at":"2025-10-19T09:31:38.682Z","avatar_url":"https://github.com/golemfactory.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\u003ccode\u003epfaas\u003c/code\u003e\u003c/h1\u003e\n\n  \u003cp\u003e\n    \u003cstrong\u003eFunction-as-a-Service on top of Golem Network in Python\u003c/strong\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\nThis module allows you to distribute heavy-workload functions to the [Golem Network]. This is a\nsister project to [gfaas].\n\n[Golem Network]: https://golem.network\n[gfaas]: https://github.com/golemfactory/gfaas\n\n⚠️ **Disclaimer:** Use with extra care as this package is highly experimental. ⚠️\n\n## Quick start\n\nCurrently, the only supported version of Python is version `3.8`. Additionally, since this package is\nnot yet released on pypi, you will need to manually install its dependencies\n\n```\npip3 install yapapi\n```\n\nThe usage is pretty straightforward. In your main Python module, e.g. `main.py`, import `pfaas` and\nannotate some heavy-workload function to be distributed on the Golem Network like so\n\n```python\nfrom pfaas import remote_fn\nimport asyncio\n\n@remote_fn()\ndef hello(msg: str) -\u003e str:\n    return msg.upper()\n\nasync def main(msg: str):\n    resp = await hello(msg)\n    print(f\"in={msg}, out={resp}\")\n\nif __name__ == '__main__':\n    loop = asyncio.get_event_loop()\n    task = loop.create_task(main(\"hey there, yagna!\"))\n\n    try:\n        asyncio.get_event_loop().run_until_complete(task)\n    except (Exception, KeyboardInterrupt) as e:\n        print(e)\n        task.cancel()\n        asyncio.get_event_loop().run_until_complete(asyncio.sleep(0.3))\n```\n\nNow simply run as usual\n\n```\npython3 main.py\n```\n\n## Notes about `pfaas.remote_fn`\n\nWhen you annotate a function with `pfaas.remote_fn` attribute, it gets expanded into a\nfull-fledged async function. So for instance, the following function\n\n```python\nfrom pfaas import remote_fn\n\n@remote_fn()\ndef hello(input: str) -\u003e str\n```\n\nexpands into\n\n```python\nasync def hello(input: str) -\u003e str\n```\n\nTherefore, it is important to remember that you need to run the function in an async block.\n\n### Specifying Golem's configuration parameters\n\nYou can currently set the following configuration parameters directly via `pfaas.remote_fn`\ndecorator:\n\n* (maximum) budget in NGNT (defaults to 100):\n\n```python\n@remote_fn(budget=100.0)\ndef hello(input: str) -\u003e str\n```\n\n* timeout as `timedelta` (defaults to 10 minutes):\n\n```python\n@remote_fn(timeout=timedelta(minutes=10))\ndef hello(input: str) -\u003e str\n```\n\n* subnet tag (defaults to \"devnet-alpha.2\"):\n\n```python\n@remote_fn(subnet=\"devnet-alpha.2\")\ndef hello(input: str) -\u003e str\n```\n\nOf course, nobody stops you from setting any number of parameters at once\n\n```python\n@remote_fn(budget=10.0, subnet=\"my_subnet\")\ndef hello(input: str) -\u003e str\n```\n\n## Notes on running your app locally (for testing)\n\nIt is well known that prior to launching our app on some distributed network of nodes, it\nis convenient to first test the app locally in search of bugs and errors. This is also\npossible with `pfaas`. In order to force your app to run locally, simply pass `run_local = True`\nas argument to `pfaas.remote_fn` decorator\n\n```python\nfrom pfaas import remote_fn\n\n@remote_fn(run_local=True)\ndef hello(msg: str) -\u003e str\n```\n\n## Examples\n\nA couple illustrative examples of how to use this module can be found in the `examples/`\ndirectory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolemfactory%2Fpfaas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolemfactory%2Fpfaas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolemfactory%2Fpfaas/lists"}