Skip to content

Commit

Permalink
move external-worker to sub-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
vzickner committed Sep 20, 2024
1 parent 5627c30 commit 28a917c
Show file tree
Hide file tree
Showing 45 changed files with 73 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- run: pip install virtualenv
- run: virtualenv venv
- run: source venv/bin/activate
- run: cd external-worker/
- run: pip install setuptools
- run: pip install -e ".[testing]"
- run: python -m unittest discover
Expand All @@ -40,7 +41,7 @@ jobs:
- run: pip install virtualenv
- run: virtualenv venv
- run: source venv/bin/activate
- run: python setup.py install
- run: python external-worker/setup.py install
- run: cd robocorp/
- run: pip install setuptools
- run: pip install -e ".[testing]"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ jobs:
- run: virtualenv venv
- run: source venv/bin/activate
- run: pip install setuptools
- run: cd external-worker/
- run: python setup.py sdist
- run: pip wheel --no-deps . -w dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
packages-dir: external-worker/dist/
verbose: true
3 changes: 2 additions & 1 deletion .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ jobs:
- run: virtualenv venv
- run: source venv/bin/activate
- run: pip install setuptools
- run: cd external-worker/
- run: python setup.py sdist
- run: pip wheel --no-deps . -w dist
- name: Publish package distributions to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/
packages-dir: external-worker/dist/
verbose: true
57 changes: 5 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,12 @@
# Flowable External Worker Library for Python
# Flowable External Client Python

[License:
![license](https://img.shields.io/hexpm/l/plug.svg)](https://github.com/flowable/flowable-external-client-python/blob/main/LICENSE)

![Flowable Actions CI](https://github.com/flowable/flowable-external-client-python/actions/workflows/main.yml/badge.svg?branch=main)

An _External Worker Task_ in BPMN or CMMN is a task where the custom logic of that task is executed externally to Flowable, i.e. on another server.
When the process or case engine arrives at such a task, it will create an **external job**, which is exposed over the REST API.
Through this REST API, the job can be acquired and locked.
Once locked, the custom logic is responsible for signalling over REST that the work is done and the process or case can continue.

This project makes implementing such custom logic in Python easy by not having the worry about the low-level details of the REST API and focus on the actual custom business logic.
Integrations for other languages are available, too.

## Authentication

The different ways to authenticate are explained in the [documentation of the underlying requests HTTP library which is used to connect to Flowable](https://requests.readthedocs.io/en/latest/user/authentication/).
The `ExternalWorkerClient` accepts as a parameter `auth` an implementation of `requests.auth.AuthBase`.
There are default implementations for example for basic authentication e.g. `HTTPBasicAuth("admin", "test")`.
Flowable offers a bearer token implementation `FlowableCloudToken` which allows to specify an access token to the Flowable Cloud offering.

## Sample

### Cloud

The usage with Flowable Cloud is simpler, since everything is pre-configured.
However, it's required to either use the user credentials or to pre-configure a personal access token.

```python
from flowable.external_worker_client import ExternalWorkerClient
from flowable.external_worker_client.cloud_token import FlowableCloudToken

client = ExternalWorkerClient(auth=FlowableCloudToken("<personal-access-token>"))

def my_callback(job, worker_result_builder):
print('Executed job: ' + job.id)
return worker_result_builder.success()

subscription = client.subscribe('myTopic', my_callback)
```

### Local

The following is an example how you can connect to a Flowable instance running at `http://host.docker.internal:8090` and process all messages retrieved on the topic `myTopic`:

```python
from flowable.external_worker_client import ExternalWorkerClient
from requests.auth import HTTPBasicAuth

client = ExternalWorkerClient('http://localhost:8090/flowable-work', auth=HTTPBasicAuth("admin", "test"))

def my_callback(job, worker_result_builder):
print('Executed job: ' + job.id)
return worker_result_builder.success()

subscription = client.subscribe('myTopic', my_callback)
```
This is a collection of multiple Flowable Python clients.
Currently, the project consists out of:

* [External Worker Client](./external-worker): A library to connect custom application code to Flowable with the external worker functionality
* [Robocorp Client](./robocorp-client): A python module to execute Robocorp actions and tasks with the Flowable Robocorp task (based on the external worker).
59 changes: 59 additions & 0 deletions external-worker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Flowable External Worker Library for Python

[License:
![license](https://img.shields.io/hexpm/l/plug.svg)](https://github.com/flowable/flowable-external-client-python/blob/main/LICENSE)

![Flowable Actions CI](https://github.com/flowable/flowable-external-client-python/actions/workflows/main.yml/badge.svg?branch=main)

An _External Worker Task_ in BPMN or CMMN is a task where the custom logic of that task is executed externally to Flowable, i.e. on another server.
When the process or case engine arrives at such a task, it will create an **external job**, which is exposed over the REST API.
Through this REST API, the job can be acquired and locked.
Once locked, the custom logic is responsible for signalling over REST that the work is done and the process or case can continue.

This project makes implementing such custom logic in Python easy by not having the worry about the low-level details of the REST API and focus on the actual custom business logic.
Integrations for other languages are available, too.

## Authentication

The different ways to authenticate are explained in the [documentation of the underlying requests HTTP library which is used to connect to Flowable](https://requests.readthedocs.io/en/latest/user/authentication/).
The `ExternalWorkerClient` accepts as a parameter `auth` an implementation of `requests.auth.AuthBase`.
There are default implementations for example for basic authentication e.g. `HTTPBasicAuth("admin", "test")`.
Flowable offers a bearer token implementation `FlowableCloudToken` which allows to specify an access token to the Flowable Cloud offering.

## Sample

### Cloud

The usage with Flowable Cloud is simpler, since everything is pre-configured.
However, it's required to either use the user credentials or to pre-configure a personal access token.

```python
from flowable.external_worker_client import ExternalWorkerClient
from flowable.external_worker_client.cloud_token import FlowableCloudToken

client = ExternalWorkerClient(auth=FlowableCloudToken("<personal-access-token>"))

def my_callback(job, worker_result_builder):
print('Executed job: ' + job.id)
return worker_result_builder.success()

subscription = client.subscribe('myTopic', my_callback)
```

### Local

The following is an example how you can connect to a Flowable instance running at `http://host.docker.internal:8090` and process all messages retrieved on the topic `myTopic`:

```python
from flowable.external_worker_client import ExternalWorkerClient
from requests.auth import HTTPBasicAuth

client = ExternalWorkerClient('http://localhost:8090/flowable-work', auth=HTTPBasicAuth("admin", "test"))

def my_callback(job, worker_result_builder):
print('Executed job: ' + job.id)
return worker_result_builder.success()

subscription = client.subscribe('myTopic', my_callback)
```

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.py → external-worker/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
setup(
name='flowable.external-worker-client',
packages=['flowable', 'flowable.external_worker_client'],
version='1.1.0rc1',
version='1.0.1rc1',
description='Flowable External Worker Library to connect Python code to Flowable using an external worker.',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions robocorp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
setup(
name='flowable.robocorp-client',
packages=['flowable', 'flowable.robocorp_client'],
version='1.1.0rc1',
version='1.0.0rc1',
description='Flowable client to be used with Robocorp. This client connects to a Flowable instance via external worker and executes robocorp tasks or actions.',
long_description=long_description,
long_description_content_type='text/markdown',
author='Flowable',
license='Apache License, Version 2.0',
install_requires=['flowable.external-worker-client>=1.1.0rc1', 'robocorp-actions>=0.2.1', 'robocorp-tasks>=3.1.1', 'robocorp-truststore>=0.9.1'],
install_requires=['flowable.external-worker-client>=1.0.1rc1', 'robocorp-actions>=0.2.1', 'robocorp-tasks>=3.1.1', 'robocorp-truststore>=0.9.1'],
extras_require={
'testing': ['pytest', 'vcrpy']
},
Expand Down

0 comments on commit 28a917c

Please sign in to comment.