conductor_celery 0.0.2a0__tar.gz

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.
@@ -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
+ [![Release](https://img.shields.io/github/v/release/tomas_correa/conductor-celery)](https://img.shields.io/github/v/release/tomas_correa/conductor-celery)
25
+ [![Build status](https://img.shields.io/github/actions/workflow/status/tomas_correa/conductor-celery/main.yml?branch=main)](https://github.com/tomas_correa/conductor-celery/actions/workflows/main.yml?query=branch%3Amain)
26
+ [![codecov](https://codecov.io/gh/tomas_correa/conductor-celery/branch/main/graph/badge.svg)](https://codecov.io/gh/tomas_correa/conductor-celery)
27
+ [![Commit activity](https://img.shields.io/github/commit-activity/m/tomas_correa/conductor-celery)](https://img.shields.io/github/commit-activity/m/tomas_correa/conductor-celery)
28
+ [![License](https://img.shields.io/github/license/tomas_correa/conductor-celery)](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,56 @@
1
+ # conductor-celery
2
+
3
+ This project is a test!!! Do not use it
4
+
5
+ [![Release](https://img.shields.io/github/v/release/tomas_correa/conductor-celery)](https://img.shields.io/github/v/release/tomas_correa/conductor-celery)
6
+ [![Build status](https://img.shields.io/github/actions/workflow/status/tomas_correa/conductor-celery/main.yml?branch=main)](https://github.com/tomas_correa/conductor-celery/actions/workflows/main.yml?query=branch%3Amain)
7
+ [![codecov](https://codecov.io/gh/tomas_correa/conductor-celery/branch/main/graph/badge.svg)](https://codecov.io/gh/tomas_correa/conductor-celery)
8
+ [![Commit activity](https://img.shields.io/github/commit-activity/m/tomas_correa/conductor-celery)](https://img.shields.io/github/commit-activity/m/tomas_correa/conductor-celery)
9
+ [![License](https://img.shields.io/github/license/tomas_correa/conductor-celery)](https://img.shields.io/github/license/tomas_correa/conductor-celery)
10
+
11
+ This is a template repository for Python projects that use Poetry for their dependency management.
12
+
13
+ - **Github repository**: <https://github.com/tomas_correa/conductor-celery/>
14
+ - **Documentation** <https://tomas_correa.github.io/conductor-celery/>
15
+
16
+ ## Getting started with your project
17
+
18
+ First, create a repository on GitHub with the same name as this project, and then run the following commands:
19
+
20
+ ``` bash
21
+ git init -b main
22
+ git add .
23
+ git commit -m "init commit"
24
+ git remote add origin git@github.com:tomas_correa/conductor-celery.git
25
+ git push -u origin main
26
+ ```
27
+
28
+ Finally, install the environment and the pre-commit hooks with
29
+
30
+ ```bash
31
+ make install
32
+ ```
33
+
34
+ You are now ready to start development on your project! The CI/CD
35
+ pipeline will be triggered when you open a pull request, merge to main,
36
+ or when you create a new release.
37
+
38
+ To finalize the set-up for publishing to PyPi or Artifactory, see
39
+ [here](https://fpgmaas.github.io/cookiecutter-poetry/features/publishing/#set-up-for-pypi).
40
+ For activating the automatic documentation with MkDocs, see
41
+ [here](https://fpgmaas.github.io/cookiecutter-poetry/features/mkdocs/#enabling-the-documentation-on-github).
42
+ To enable the code coverage reports, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/codecov/).
43
+
44
+ ## Releasing a new version
45
+
46
+ - Create an API Token on [Pypi](https://pypi.org/).
47
+ - Add the API Token to your projects secrets with the name `PYPI_TOKEN` by visiting
48
+ [this page](https://github.com/tomas_correa/conductor-celery/settings/secrets/actions/new).
49
+ - Create a [new release](https://github.com/tomas_correa/conductor-celery/releases/new) on Github.
50
+ Create a new tag in the form ``*.*.*``.
51
+
52
+ For more details, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/cicd/#how-to-trigger-a-release).
53
+
54
+ ---
55
+
56
+ Repository initiated with [fpgmaas/cookiecutter-poetry](https://github.com/fpgmaas/cookiecutter-poetry).
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,110 @@
1
+ [tool.poetry]
2
+ name = "conductor_celery"
3
+ version = "v0.0.2-alpha"
4
+ description = "This is a template repository for Python projects that use Poetry for their dependency management."
5
+ authors = ["Tomas Correa <ftomas.correa@gmail.com>"]
6
+ repository = "https://github.com/tomas_correa/conductor-celery"
7
+ documentation = "https://tomas_correa.github.io/conductor-celery/"
8
+ readme = "README.md"
9
+ packages = [
10
+ {include = "conductor_celery"}
11
+ ]
12
+
13
+ [tool.poetry.dependencies]
14
+ python = ">=3.8,<4.0"
15
+ celery = "^5.3.1"
16
+ conductor-python = "^1.0.71"
17
+
18
+ [tool.poetry.group.dev.dependencies]
19
+ pytest = "^7.2.0"
20
+ pytest-cov = "^4.0.0"
21
+ deptry = "^0.6.4"
22
+ mypy = "^0.981"
23
+ pre-commit = "^2.20.0"
24
+ tox = "^3.25.1"
25
+ redis = "^4.6.0"
26
+ pytest-celery = "^0.0.0"
27
+ httpretty = "^1.1.4"
28
+
29
+
30
+
31
+ [build-system]
32
+ requires = ["poetry-core>=1.0.0"]
33
+ build-backend = "poetry.core.masonry.api"
34
+
35
+ [tool.black]
36
+ line-length = 120
37
+ target-version = ['py311']
38
+ preview = true
39
+
40
+ [tool.mypy]
41
+ ignore_missing_imports = "True"
42
+ files = ["conductor_celery"]
43
+ disallow_untyped_defs = "False"
44
+ disallow_any_unimported = "False"
45
+ no_implicit_optional = "True"
46
+ check_untyped_defs = "True"
47
+ warn_return_any = "True"
48
+ warn_unused_ignores = "True"
49
+ show_error_codes = "True"
50
+
51
+ [tool.ruff]
52
+ target-version = "py311"
53
+ line-length = 120
54
+ fix = true
55
+ select = [
56
+ # flake8-2020
57
+ "YTT",
58
+ # flake8-bandit
59
+ "S",
60
+ # flake8-bugbear
61
+ "B",
62
+ # flake8-builtins
63
+ "A",
64
+ # flake8-comprehensions
65
+ "C4",
66
+ # flake8-debugger
67
+ "T10",
68
+ # flake8-simplify
69
+ "SIM",
70
+ # isort
71
+ "I",
72
+ # mccabe
73
+ "C90",
74
+ # pycodestyle
75
+ "E", "W",
76
+ # pyflakes
77
+ "F",
78
+ # pygrep-hooks
79
+ "PGH",
80
+ # pyupgrade
81
+ "UP",
82
+ # ruff
83
+ "RUF",
84
+ # tryceratops
85
+ "TRY",
86
+ ]
87
+ ignore = [
88
+ # LineTooLong
89
+ "E501",
90
+ # DoNotAssignLambda
91
+ "E731",
92
+ ]
93
+
94
+ [tool.ruff.per-file-ignores]
95
+ "tests/*" = ["S101"]
96
+
97
+ [tool.coverage.report]
98
+ skip_empty = true
99
+
100
+ [tool.coverage.run]
101
+ branch = true
102
+ source = ["conductor_celery"]
103
+
104
+
105
+ [tool.deptry]
106
+
107
+ extend_exclude = [
108
+ ".venv",
109
+ ".tox"
110
+ ]