Skip to content

A library that helps with writing Golem components in Python

License

Notifications You must be signed in to change notification settings

golemcloud/golem-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golem-cloud

A library that helps with writing Golem components in Python

Usage

golem-cloud is built on top of 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:

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.

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:

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.

About

A library that helps with writing Golem components in Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published