semvec/pypi-packages huggingface dataset:
pyhermes 0.7.1
The Python interface to the Hermes message broker.
Requires Python: >=3.9
Keywords: pyhermes

## pyhermes

[![Version Badge](https://badge.fury.io/py/pyhermes.png)](https://badge.fury.io/py/pyhermes.png)
[![Build Status](https://travis-ci.org/allegro/pyhermes.png?branch=master)](https://travis-ci.org/allegro/pyhermes)

The Python interface to the [Hermes](http://hermes.allegro.tech) message broker.

## Documentation

The full documentation is at https://pyhermes.readthedocs.org.

## Installation

To install pyhermes, simply:

```python
pip install pyhermes
```

Then use it in a project:

```python
import pyhermes
```

## Features

* TODO

## Quickstart

### Subscriber

To create handler for particular subscription topic decorate your function using `subscribe` decorator:

```python
import pyhermes

@pyhermes.subscriber(topic='pl.allegro.pyhermes.sample-topic')
def handler(data):
    # process data
```

This function will be called every time there is new message published to the selected topic.

### Publisher
Use `publish` function to publish data to some topic in hermes:

```python
import pyhermes

@pyhermes.publisher(topic='pl.allegro.pyhermes.sample-topic')
def my_complex_function(a, b, c):
    result = a + b + c
    publish(my_complex_function._topic, {'complex_result': result})
```

You could publish directly result of the function as well:

```python
import pyhermes

@pyhermes.publisher(topic='pl.allegro.pyhermes.sample-topic', auto_publish_result=True)
def my_complex_function(a, b, c):
    return {'complex_result': a + b + c}
```

Result of decorated function is automatically published to selected topic in hermes.

## Running Tests

Does the code actually work?

```python
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements/test.txt
(myenv) $ python runtests.py
```

## Credits

Tools used in rendering this package:

*  [Cookiecutter](https://github.com/audreyr/cookiecutter)
*  [cookiecutter-djangopackage](https://github.com/pydanny/cookiecutter-djangopackage)
golem-cloud 0.2.0
A library that helps with writing Golem components in Python 
Requires Python: >=3.12

# 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.