conductor_celery 0.0.2a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- conductor_celery/__init__.py +0 -0
- conductor_celery/tasks.py +60 -0
- conductor_celery/utils.py +26 -0
- conductor_celery/wrapper.py +24 -0
- conductor_celery-0.0.2a0.dist-info/LICENSE +21 -0
- conductor_celery-0.0.2a0.dist-info/METADATA +75 -0
- conductor_celery-0.0.2a0.dist-info/RECORD +8 -0
- conductor_celery-0.0.2a0.dist-info/WHEEL +4 -0
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from celery import Task, shared_task
|
|
4
|
+
|
|
5
|
+
from conductor_celery.utils import configure_runner
|
|
6
|
+
from conductor_celery.utils import update_task as real_update_task
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ConductorPollTask(Task):
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ConductorTask(Task):
|
|
14
|
+
"""
|
|
15
|
+
This handle a canductor task
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def apply(
|
|
19
|
+
self,
|
|
20
|
+
args=None,
|
|
21
|
+
kwargs=None,
|
|
22
|
+
link=None,
|
|
23
|
+
link_error=None,
|
|
24
|
+
task_id=None,
|
|
25
|
+
retries=None,
|
|
26
|
+
throw=None,
|
|
27
|
+
logfile=None,
|
|
28
|
+
loglevel=None,
|
|
29
|
+
headers=None,
|
|
30
|
+
**options,
|
|
31
|
+
) -> Any:
|
|
32
|
+
runner = configure_runner(server_api_url=self.app.conf["conductor_server_api_url"], name=self.name, debug=True)
|
|
33
|
+
conductor_task = runner.poll_task()
|
|
34
|
+
|
|
35
|
+
ret = super().apply(
|
|
36
|
+
None,
|
|
37
|
+
conductor_task.input_data,
|
|
38
|
+
link,
|
|
39
|
+
link_error,
|
|
40
|
+
task_id,
|
|
41
|
+
retries,
|
|
42
|
+
throw,
|
|
43
|
+
logfile,
|
|
44
|
+
loglevel,
|
|
45
|
+
headers,
|
|
46
|
+
**options,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
runner.update_task(
|
|
50
|
+
real_update_task(
|
|
51
|
+
conductor_task.task_id, conductor_task.workflow_instance_id, conductor_task.worker_id, ret.result
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
return ret
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@shared_task(bind=True)
|
|
58
|
+
def update_task(self, name, task_id, workflow_instance_id, worker_id, values):
|
|
59
|
+
runner = configure_runner(server_api_url=self.app.conf["conductor_server_api_url"], name=name, debug=True)
|
|
60
|
+
runner.update_task(real_update_task(task_id, workflow_instance_id, worker_id, values))
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from conductor.client.configuration.configuration import Configuration
|
|
2
|
+
from conductor.client.configuration.settings.metrics_settings import MetricsSettings
|
|
3
|
+
from conductor.client.http.models.task_result import TaskResult
|
|
4
|
+
|
|
5
|
+
from conductor_celery.wrapper import TaskRunner, Worker
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def configure_runner(server_api_url: str, name: str, debug=False):
|
|
9
|
+
configuration = Configuration(server_api_url=server_api_url, debug=True)
|
|
10
|
+
|
|
11
|
+
worker = Worker(name)
|
|
12
|
+
metrics_settings = MetricsSettings()
|
|
13
|
+
return TaskRunner(worker, configuration, metrics_settings)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def update_task(task_id, workflow_instance_id, worker_id, values) -> TaskResult:
|
|
17
|
+
task_result = TaskResult(
|
|
18
|
+
task_id=task_id,
|
|
19
|
+
workflow_instance_id=workflow_instance_id,
|
|
20
|
+
worker_id=worker_id,
|
|
21
|
+
)
|
|
22
|
+
for key, value in values.items():
|
|
23
|
+
task_result.add_output_data(key, value)
|
|
24
|
+
|
|
25
|
+
task_result.status = "COMPLETED"
|
|
26
|
+
return task_result
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from conductor.client.automator import task_runner
|
|
4
|
+
from conductor.client.http.models.task import Task
|
|
5
|
+
from conductor.client.worker.worker_interface import WorkerInterface
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Worker(WorkerInterface):
|
|
9
|
+
def __init__(self, task_definition_name) -> None:
|
|
10
|
+
self.task_definition_name = task_definition_name
|
|
11
|
+
|
|
12
|
+
def execute(self) -> None:
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
def paused(self) -> bool:
|
|
16
|
+
return False
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class TaskRunner(task_runner.TaskRunner):
|
|
20
|
+
def poll_task(self) -> Task:
|
|
21
|
+
return self.__poll_task()
|
|
22
|
+
|
|
23
|
+
def update_task(self, retval: Any) -> Any:
|
|
24
|
+
return self.__update_task(retval)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Tomas Correa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: conductor-celery
|
|
3
|
+
Version: 0.0.2a0
|
|
4
|
+
Summary: This is a template repository for Python projects that use Poetry for their dependency management.
|
|
5
|
+
Home-page: https://github.com/tomas_correa/conductor-celery
|
|
6
|
+
Author: Tomas Correa
|
|
7
|
+
Author-email: ftomas.correa@gmail.com
|
|
8
|
+
Requires-Python: >=3.8,<4.0
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Requires-Dist: celery (>=5.3.1,<6.0.0)
|
|
15
|
+
Requires-Dist: conductor-python (>=1.0.71,<2.0.0)
|
|
16
|
+
Project-URL: Documentation, https://tomas_correa.github.io/conductor-celery/
|
|
17
|
+
Project-URL: Repository, https://github.com/tomas_correa/conductor-celery
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# conductor-celery
|
|
21
|
+
|
|
22
|
+
This project is a test!!! Do not use it
|
|
23
|
+
|
|
24
|
+
[](https://img.shields.io/github/v/release/tomas_correa/conductor-celery)
|
|
25
|
+
[](https://github.com/tomas_correa/conductor-celery/actions/workflows/main.yml?query=branch%3Amain)
|
|
26
|
+
[](https://codecov.io/gh/tomas_correa/conductor-celery)
|
|
27
|
+
[](https://img.shields.io/github/commit-activity/m/tomas_correa/conductor-celery)
|
|
28
|
+
[](https://img.shields.io/github/license/tomas_correa/conductor-celery)
|
|
29
|
+
|
|
30
|
+
This is a template repository for Python projects that use Poetry for their dependency management.
|
|
31
|
+
|
|
32
|
+
- **Github repository**: <https://github.com/tomas_correa/conductor-celery/>
|
|
33
|
+
- **Documentation** <https://tomas_correa.github.io/conductor-celery/>
|
|
34
|
+
|
|
35
|
+
## Getting started with your project
|
|
36
|
+
|
|
37
|
+
First, create a repository on GitHub with the same name as this project, and then run the following commands:
|
|
38
|
+
|
|
39
|
+
``` bash
|
|
40
|
+
git init -b main
|
|
41
|
+
git add .
|
|
42
|
+
git commit -m "init commit"
|
|
43
|
+
git remote add origin git@github.com:tomas_correa/conductor-celery.git
|
|
44
|
+
git push -u origin main
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Finally, install the environment and the pre-commit hooks with
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
make install
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You are now ready to start development on your project! The CI/CD
|
|
54
|
+
pipeline will be triggered when you open a pull request, merge to main,
|
|
55
|
+
or when you create a new release.
|
|
56
|
+
|
|
57
|
+
To finalize the set-up for publishing to PyPi or Artifactory, see
|
|
58
|
+
[here](https://fpgmaas.github.io/cookiecutter-poetry/features/publishing/#set-up-for-pypi).
|
|
59
|
+
For activating the automatic documentation with MkDocs, see
|
|
60
|
+
[here](https://fpgmaas.github.io/cookiecutter-poetry/features/mkdocs/#enabling-the-documentation-on-github).
|
|
61
|
+
To enable the code coverage reports, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/codecov/).
|
|
62
|
+
|
|
63
|
+
## Releasing a new version
|
|
64
|
+
|
|
65
|
+
- Create an API Token on [Pypi](https://pypi.org/).
|
|
66
|
+
- Add the API Token to your projects secrets with the name `PYPI_TOKEN` by visiting
|
|
67
|
+
[this page](https://github.com/tomas_correa/conductor-celery/settings/secrets/actions/new).
|
|
68
|
+
- Create a [new release](https://github.com/tomas_correa/conductor-celery/releases/new) on Github.
|
|
69
|
+
Create a new tag in the form ``*.*.*``.
|
|
70
|
+
|
|
71
|
+
For more details, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/cicd/#how-to-trigger-a-release).
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
Repository initiated with [fpgmaas/cookiecutter-poetry](https://github.com/fpgmaas/cookiecutter-poetry).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
conductor_celery/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
conductor_celery/tasks.py,sha256=N8PV7E0sveHiDKZsl70-VFIvqmPhRbBkXwiLkfJLvFE,1553
|
|
3
|
+
conductor_celery/utils.py,sha256=-pq_mB4nvVu0kkteH7lFcCuBslaDWEX-i2xQ-RhuAzs,925
|
|
4
|
+
conductor_celery/wrapper.py,sha256=DYYJK4fNZXZ0Lc62xVPaCkzOLtOmu7l-_22-zoUsPYA,637
|
|
5
|
+
conductor_celery-0.0.2a0.dist-info/LICENSE,sha256=XbUKTZPsplV7Qeco49wjShvW2zXh0MWeA-f_BqTepwU,1070
|
|
6
|
+
conductor_celery-0.0.2a0.dist-info/METADATA,sha256=4ADGdev_DnZ19wAJtPIQmygz-P0rs74e_aTDyAie1xw,3657
|
|
7
|
+
conductor_celery-0.0.2a0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
8
|
+
conductor_celery-0.0.2a0.dist-info/RECORD,,
|