https://github.com/golemcloud/golem-py
A library that helps with writing Golem components in Python
https://github.com/golemcloud/golem-py
Last synced: 5 months ago
JSON representation
A library that helps with writing Golem components in Python
- Host: GitHub
- URL: https://github.com/golemcloud/golem-py
- Owner: golemcloud
- License: apache-2.0
- Created: 2025-04-28T10:02:11.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-27T10:36:37.000Z (about 1 year ago)
- Last Synced: 2025-06-04T01:16:25.424Z (about 1 year ago)
- Language: Python
- Size: 322 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# golem-cloud
A library that helps with writing [Golem](https://www.golem.cloud/) components in Python
## Usage
golem-cloud is built on top of [componentize-py](https://github.com/bytecodealliance/componentize-py) and relies on bindings generated by it to work.
To set up a project begin by creating a wit directory and defining a world that your component will implement:
```wit
package demo-namespace:demo-package;
interface demo-api {
run: func();
}
world demo-world {
import wasi:http/types@0.2.0;
import wasi:http/outgoing-handler@0.2.0;
import golem:api/host@1.1.6;
export demo-api;
}
```
To enable usage of golem-cloud with your project you need to tell it about your world and where the bindings will be generated by componentize-py. To do this include
the following code snippet at the top of your python code. Make sure to place it before any other uses of the golem-cloud library.
```python
import golem_py_bindings
golem_py_bindings.register_bindings("demo_world") # Put the name of your world here
```
You can now use golem-cloud in your project:
```python
from golem_py.durability import Durability, DurableFunctionType
from demo_world.imports.oplog import WrappedFunctionType_ReadLocal
durability = Durability("custom", "random-number-generator", WrappedFunctionType_ReadLocal)
```
Note:
golem-cloud is using bindings that are generated by componentize-py for your world. You can only use the modules in golem-cloud for which you have all necessary bindings (by having the appropriate imports and exports in your world). Trying
to use a module for which your don't have all required bindings will fail with an import error (even if the initial register_bindings was successful). Every module in golem-cloud documents which bindings are required for it to work, so please consult the module documentation.