ergon-framework-python 0.1.3__py3-none-any.whl → 0.1.4__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.
- ergon/__init__.py +13 -13
- ergon/bootstrap/src/__project__/main.py +9 -9
- ergon/bootstrap/src/__project__/tasks/constants.py +13 -13
- ergon/bootstrap/src/__project__/tasks/example_task/config.py +4 -4
- ergon/bootstrap/src/__project__/tasks/example_task/exceptions.py +4 -4
- ergon/bootstrap/src/__project__/tasks/example_task/helpers.py +4 -4
- ergon/bootstrap/src/__project__/tasks/example_task/schemas.py +5 -5
- ergon/bootstrap/src/__project__/tasks/example_task/task.py +1 -1
- ergon/bootstrap/src/__project__/tasks/settings.py +5 -5
- ergon/cli.py +174 -174
- ergon/connector/__init__.py +112 -98
- ergon/connector/connector.py +97 -97
- ergon/connector/ergon_platform/__init__.py +17 -0
- ergon/connector/ergon_platform/_client.py +23 -0
- ergon/connector/ergon_platform/_operations.py +264 -0
- ergon/connector/ergon_platform/async_connector.py +223 -0
- ergon/connector/ergon_platform/connector.py +200 -0
- ergon/connector/ergon_platform/models.py +107 -0
- ergon/connector/ergon_platform/utils.py +250 -0
- ergon/connector/excel/__init__.py +18 -18
- ergon/connector/excel/connector.py +175 -175
- ergon/connector/excel/models.py +24 -24
- ergon/connector/excel/service.py +98 -98
- ergon/connector/nylas/__init__.py +45 -45
- ergon/connector/nylas/async_auth_service.py +15 -15
- ergon/connector/nylas/auth_service.py +43 -43
- ergon/connector/pipefy/__init__.py +21 -21
- ergon/connector/pipefy/async_connector.py +48 -48
- ergon/connector/pipefy/async_service.py +907 -907
- ergon/connector/pipefy/connector.py +36 -36
- ergon/connector/pipefy/models.py +48 -48
- ergon/connector/pipefy/service.py +1016 -1016
- ergon/connector/pipefy/version.py +1 -1
- ergon/connector/postgres/__init__.py +11 -11
- ergon/connector/postgres/async_connector.py +119 -119
- ergon/connector/postgres/async_service.py +116 -116
- ergon/connector/postgres/models.py +34 -34
- ergon/connector/rabbitmq/__init__.py +25 -25
- ergon/connector/rabbitmq/async_connector.py +129 -129
- ergon/connector/rabbitmq/async_service.py +525 -525
- ergon/connector/rabbitmq/connector.py +54 -54
- ergon/connector/rabbitmq/helper.py +14 -14
- ergon/connector/rabbitmq/models.py +115 -115
- ergon/connector/rabbitmq/service.py +199 -199
- ergon/connector/sqs/__init__.py +15 -15
- ergon/connector/sqs/async_connector.py +120 -120
- ergon/connector/sqs/async_service.py +246 -246
- ergon/connector/sqs/connector.py +120 -120
- ergon/connector/sqs/models.py +36 -36
- ergon/connector/sqs/service.py +219 -219
- ergon/connector/transaction.py +14 -14
- ergon/service/__init__.py +5 -5
- ergon/service/service.py +17 -17
- ergon/task/__init__.py +13 -13
- ergon/task/base.py +222 -222
- ergon/task/exceptions.py +217 -217
- ergon/task/helpers.py +691 -691
- ergon/task/manager.py +85 -85
- ergon/task/mixins/__init__.py +13 -13
- ergon/task/mixins/consumer.py +887 -887
- ergon/task/mixins/metrics.py +457 -457
- ergon/task/mixins/producer.py +486 -486
- ergon/task/policies.py +229 -229
- ergon/task/runner.py +386 -386
- ergon/task/utils.py +64 -64
- ergon/telemetry/__init__.py +7 -7
- ergon/telemetry/_resource.py +13 -13
- ergon/telemetry/logging.py +370 -370
- ergon/telemetry/metrics.py +101 -101
- ergon/telemetry/tracing.py +152 -152
- ergon/utils/__init__.py +5 -5
- ergon/utils/env.py +26 -26
- {ergon_framework_python-0.1.3.dist-info → ergon_framework_python-0.1.4.dist-info}/METADATA +3 -1
- ergon_framework_python-0.1.4.dist-info/RECORD +98 -0
- ergon_framework_python-0.1.3.dist-info/RECORD +0 -91
- {ergon_framework_python-0.1.3.dist-info → ergon_framework_python-0.1.4.dist-info}/WHEEL +0 -0
- {ergon_framework_python-0.1.3.dist-info → ergon_framework_python-0.1.4.dist-info}/entry_points.txt +0 -0
- {ergon_framework_python-0.1.3.dist-info → ergon_framework_python-0.1.4.dist-info}/licenses/LICENSE +0 -0
- {ergon_framework_python-0.1.3.dist-info → ergon_framework_python-0.1.4.dist-info}/top_level.txt +0 -0
ergon/__init__.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
from . import connector, service, task, telemetry, utils
|
|
2
|
-
from .task.manager import manager
|
|
3
|
-
|
|
4
|
-
__all__ = [
|
|
5
|
-
"service",
|
|
6
|
-
"connector",
|
|
7
|
-
"task",
|
|
8
|
-
"telemetry",
|
|
9
|
-
"utils",
|
|
10
|
-
"manager",
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
__version__ = "0.1.3"
|
|
1
|
+
from . import connector, service, task, telemetry, utils
|
|
2
|
+
from .task.manager import manager
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"service",
|
|
6
|
+
"connector",
|
|
7
|
+
"task",
|
|
8
|
+
"telemetry",
|
|
9
|
+
"utils",
|
|
10
|
+
"manager",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
__version__ = "0.1.3"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
from ergon.cli import ergon
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def main():
|
|
5
|
-
ergon()
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if __name__ == "__main__":
|
|
9
|
-
main()
|
|
1
|
+
from ergon.cli import ergon
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def main():
|
|
5
|
+
ergon()
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
main()
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
from ergon.task.policies import RetryPolicy
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# ----------------------------------------
|
|
5
|
-
# --- RETRY POLICY CONFIGURATION ---
|
|
6
|
-
# ----------------------------------------
|
|
7
|
-
def default_retry_policy():
|
|
8
|
-
return RetryPolicy(
|
|
9
|
-
max_attempts=3,
|
|
10
|
-
backoff=1,
|
|
11
|
-
backoff_multiplier=2,
|
|
12
|
-
backoff_cap=10,
|
|
13
|
-
)
|
|
1
|
+
from ergon.task.policies import RetryPolicy
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# ----------------------------------------
|
|
5
|
+
# --- RETRY POLICY CONFIGURATION ---
|
|
6
|
+
# ----------------------------------------
|
|
7
|
+
def default_retry_policy():
|
|
8
|
+
return RetryPolicy(
|
|
9
|
+
max_attempts=3,
|
|
10
|
+
backoff=1,
|
|
11
|
+
backoff_multiplier=2,
|
|
12
|
+
backoff_cap=10,
|
|
13
|
+
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Uncomment below to use framework imports
|
|
2
|
-
# ----------------------------------------
|
|
3
|
-
|
|
4
|
-
# from ergon import task
|
|
1
|
+
# Uncomment below to use framework imports
|
|
2
|
+
# ----------------------------------------
|
|
3
|
+
|
|
4
|
+
# from ergon import task
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Uncomment below to use framework imports
|
|
2
|
-
# ----------------------------------------
|
|
3
|
-
|
|
4
|
-
# from ergon.task.exceptions import TransactionException
|
|
1
|
+
# Uncomment below to use framework imports
|
|
2
|
+
# ----------------------------------------
|
|
3
|
+
|
|
4
|
+
# from ergon.task.exceptions import TransactionException
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Uncomment below to use framework imports
|
|
2
|
-
# ----------------------------------------
|
|
3
|
-
|
|
4
|
-
# from .. import helpers as shared
|
|
1
|
+
# Uncomment below to use framework imports
|
|
2
|
+
# ----------------------------------------
|
|
3
|
+
|
|
4
|
+
# from .. import helpers as shared
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Uncomment below to use framework imports
|
|
2
|
-
# ----------------------------------------
|
|
3
|
-
|
|
4
|
-
# from pydantic import BaseModel
|
|
5
|
-
# from .. import schemas as shared
|
|
1
|
+
# Uncomment below to use framework imports
|
|
2
|
+
# ----------------------------------------
|
|
3
|
+
|
|
4
|
+
# from pydantic import BaseModel
|
|
5
|
+
# from .. import schemas as shared
|
|
@@ -1 +1 @@
|
|
|
1
|
-
# from ergon import task, connector
|
|
1
|
+
# from ergon import task, connector
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Uncomment below to use framework imports
|
|
2
|
-
# ----------------------------------------
|
|
3
|
-
|
|
4
|
-
# from ergon import service, connector, telemetry
|
|
5
|
-
# from ergon.utils import load_env
|
|
1
|
+
# Uncomment below to use framework imports
|
|
2
|
+
# ----------------------------------------
|
|
3
|
+
|
|
4
|
+
# from ergon import service, connector, telemetry
|
|
5
|
+
# from ergon.utils import load_env
|
ergon/cli.py
CHANGED
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import json
|
|
3
|
-
import shutil
|
|
4
|
-
import sys
|
|
5
|
-
import uuid
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
from typing import List, Optional
|
|
8
|
-
|
|
9
|
-
from .connector import Transaction
|
|
10
|
-
from .task.base import TaskConfig
|
|
11
|
-
from .task.manager import manager
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# ---------------------------------------------------------------------
|
|
15
|
-
# Utility: bootstrap project
|
|
16
|
-
# ---------------------------------------------------------------------
|
|
17
|
-
def bootstrap_project(project_name: str, target_dir: str):
|
|
18
|
-
root = Path(__file__).resolve().parent
|
|
19
|
-
template_src = root / "bootstrap" / "src" / "__project__"
|
|
20
|
-
|
|
21
|
-
if not template_src.exists():
|
|
22
|
-
raise RuntimeError(f"Template missing: {template_src}")
|
|
23
|
-
|
|
24
|
-
target = Path(target_dir).resolve()
|
|
25
|
-
target_src = target / "src" / project_name
|
|
26
|
-
target_src.mkdir(parents=True, exist_ok=True)
|
|
27
|
-
|
|
28
|
-
for item in template_src.rglob("*"):
|
|
29
|
-
rel = item.relative_to(template_src)
|
|
30
|
-
dest = target_src / rel
|
|
31
|
-
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
32
|
-
if item.is_file():
|
|
33
|
-
shutil.copy2(item, dest)
|
|
34
|
-
|
|
35
|
-
print(f"✔ Bootstrapped successfully at src/{project_name}")
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# ---------------------------------------------------------------------
|
|
39
|
-
# CLI parser
|
|
40
|
-
# ---------------------------------------------------------------------
|
|
41
|
-
def create_parser():
|
|
42
|
-
parser = argparse.ArgumentParser(
|
|
43
|
-
prog="ergon",
|
|
44
|
-
description="Ergon Task Framework CLI",
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
48
|
-
|
|
49
|
-
# -------------------------------------------------------------
|
|
50
|
-
# ergon list
|
|
51
|
-
# -------------------------------------------------------------
|
|
52
|
-
subparsers.add_parser("list", help="List all registered tasks")
|
|
53
|
-
|
|
54
|
-
# -------------------------------------------------------------
|
|
55
|
-
# ergon run <task>
|
|
56
|
-
# -------------------------------------------------------------
|
|
57
|
-
run_parser = subparsers.add_parser("run", help="Run a registered task")
|
|
58
|
-
run_parser.add_argument("task_name", type=str)
|
|
59
|
-
|
|
60
|
-
# -------------------------------------------------------------
|
|
61
|
-
# ergon process-transaction
|
|
62
|
-
# -------------------------------------------------------------
|
|
63
|
-
tx_parser = subparsers.add_parser(
|
|
64
|
-
"process-transaction",
|
|
65
|
-
help="Process a single transaction (inline payload)",
|
|
66
|
-
)
|
|
67
|
-
tx_parser.add_argument("task", type=str)
|
|
68
|
-
tx_parser.add_argument("policy", type=str)
|
|
69
|
-
tx_parser.add_argument(
|
|
70
|
-
"--payload-json",
|
|
71
|
-
required=True,
|
|
72
|
-
help="Transaction payload as JSON string",
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
# -------------------------------------------------------------
|
|
76
|
-
# ergon process-transaction-by-id
|
|
77
|
-
# -------------------------------------------------------------
|
|
78
|
-
tx_id_parser = subparsers.add_parser(
|
|
79
|
-
"process-transaction-by-id",
|
|
80
|
-
help="Process a transaction by ID via connector fetch",
|
|
81
|
-
)
|
|
82
|
-
tx_id_parser.add_argument("task", type=str)
|
|
83
|
-
tx_id_parser.add_argument("policy", type=str)
|
|
84
|
-
tx_id_parser.add_argument("transaction_id", type=str)
|
|
85
|
-
|
|
86
|
-
# -------------------------------------------------------------
|
|
87
|
-
# ergon bootstrap
|
|
88
|
-
# -------------------------------------------------------------
|
|
89
|
-
bootstrap_parser = subparsers.add_parser(
|
|
90
|
-
"bootstrap",
|
|
91
|
-
help="Create a new project using the Ergon template",
|
|
92
|
-
)
|
|
93
|
-
bootstrap_parser.add_argument("project_name", type=str)
|
|
94
|
-
bootstrap_parser.add_argument(
|
|
95
|
-
"target_dir",
|
|
96
|
-
nargs="?",
|
|
97
|
-
default=".",
|
|
98
|
-
help="Target directory (default: current directory)",
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
return parser
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
# ---------------------------------------------------------------------
|
|
105
|
-
# CLI entry point
|
|
106
|
-
# ---------------------------------------------------------------------
|
|
107
|
-
def ergon(tasks: Optional[List[TaskConfig]] = None):
|
|
108
|
-
if tasks:
|
|
109
|
-
for cfg in tasks:
|
|
110
|
-
if not manager.get(cfg.name):
|
|
111
|
-
manager.register(cfg)
|
|
112
|
-
|
|
113
|
-
parser = create_parser()
|
|
114
|
-
args = parser.parse_args()
|
|
115
|
-
|
|
116
|
-
if not args.command:
|
|
117
|
-
parser.print_help()
|
|
118
|
-
sys.exit(1)
|
|
119
|
-
|
|
120
|
-
# -------------------------------------------------------------
|
|
121
|
-
# LIST TASKS
|
|
122
|
-
# -------------------------------------------------------------
|
|
123
|
-
if args.command == "list":
|
|
124
|
-
task_names = manager.list_tasks()
|
|
125
|
-
if not task_names:
|
|
126
|
-
print("No tasks registered. Did you import your config files?")
|
|
127
|
-
else:
|
|
128
|
-
print("Registered tasks:")
|
|
129
|
-
for t in task_names:
|
|
130
|
-
print(f" - {t}")
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
# -------------------------------------------------------------
|
|
134
|
-
# RUN TASK
|
|
135
|
-
# -------------------------------------------------------------
|
|
136
|
-
if args.command == "run":
|
|
137
|
-
manager.run(args.task_name)
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
# -------------------------------------------------------------
|
|
141
|
-
# PROCESS TRANSACTION (INLINE)
|
|
142
|
-
# -------------------------------------------------------------
|
|
143
|
-
if args.command == "process-transaction":
|
|
144
|
-
try:
|
|
145
|
-
payload = json.loads(args.payload_json)
|
|
146
|
-
except json.JSONDecodeError as exc:
|
|
147
|
-
print(f"[ERROR] Invalid JSON payload: {exc}")
|
|
148
|
-
sys.exit(2)
|
|
149
|
-
|
|
150
|
-
transaction = Transaction(id=str(uuid.uuid4()), payload=payload)
|
|
151
|
-
manager.process_transaction(
|
|
152
|
-
task=args.task,
|
|
153
|
-
policy=args.policy,
|
|
154
|
-
transaction=transaction,
|
|
155
|
-
)
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
# -------------------------------------------------------------
|
|
159
|
-
# PROCESS TRANSACTION BY ID
|
|
160
|
-
# -------------------------------------------------------------
|
|
161
|
-
if args.command == "process-transaction-by-id":
|
|
162
|
-
manager.process_transaction_by_id(
|
|
163
|
-
task=args.task,
|
|
164
|
-
policy=args.policy,
|
|
165
|
-
transaction_id=args.transaction_id,
|
|
166
|
-
)
|
|
167
|
-
return
|
|
168
|
-
|
|
169
|
-
# -------------------------------------------------------------
|
|
170
|
-
# BOOTSTRAP
|
|
171
|
-
# -------------------------------------------------------------
|
|
172
|
-
if args.command == "bootstrap":
|
|
173
|
-
bootstrap_project(args.project_name, args.target_dir)
|
|
174
|
-
return
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
import shutil
|
|
4
|
+
import sys
|
|
5
|
+
import uuid
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import List, Optional
|
|
8
|
+
|
|
9
|
+
from .connector import Transaction
|
|
10
|
+
from .task.base import TaskConfig
|
|
11
|
+
from .task.manager import manager
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# ---------------------------------------------------------------------
|
|
15
|
+
# Utility: bootstrap project
|
|
16
|
+
# ---------------------------------------------------------------------
|
|
17
|
+
def bootstrap_project(project_name: str, target_dir: str):
|
|
18
|
+
root = Path(__file__).resolve().parent
|
|
19
|
+
template_src = root / "bootstrap" / "src" / "__project__"
|
|
20
|
+
|
|
21
|
+
if not template_src.exists():
|
|
22
|
+
raise RuntimeError(f"Template missing: {template_src}")
|
|
23
|
+
|
|
24
|
+
target = Path(target_dir).resolve()
|
|
25
|
+
target_src = target / "src" / project_name
|
|
26
|
+
target_src.mkdir(parents=True, exist_ok=True)
|
|
27
|
+
|
|
28
|
+
for item in template_src.rglob("*"):
|
|
29
|
+
rel = item.relative_to(template_src)
|
|
30
|
+
dest = target_src / rel
|
|
31
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
32
|
+
if item.is_file():
|
|
33
|
+
shutil.copy2(item, dest)
|
|
34
|
+
|
|
35
|
+
print(f"✔ Bootstrapped successfully at src/{project_name}")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# ---------------------------------------------------------------------
|
|
39
|
+
# CLI parser
|
|
40
|
+
# ---------------------------------------------------------------------
|
|
41
|
+
def create_parser():
|
|
42
|
+
parser = argparse.ArgumentParser(
|
|
43
|
+
prog="ergon",
|
|
44
|
+
description="Ergon Task Framework CLI",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
48
|
+
|
|
49
|
+
# -------------------------------------------------------------
|
|
50
|
+
# ergon list
|
|
51
|
+
# -------------------------------------------------------------
|
|
52
|
+
subparsers.add_parser("list", help="List all registered tasks")
|
|
53
|
+
|
|
54
|
+
# -------------------------------------------------------------
|
|
55
|
+
# ergon run <task>
|
|
56
|
+
# -------------------------------------------------------------
|
|
57
|
+
run_parser = subparsers.add_parser("run", help="Run a registered task")
|
|
58
|
+
run_parser.add_argument("task_name", type=str)
|
|
59
|
+
|
|
60
|
+
# -------------------------------------------------------------
|
|
61
|
+
# ergon process-transaction
|
|
62
|
+
# -------------------------------------------------------------
|
|
63
|
+
tx_parser = subparsers.add_parser(
|
|
64
|
+
"process-transaction",
|
|
65
|
+
help="Process a single transaction (inline payload)",
|
|
66
|
+
)
|
|
67
|
+
tx_parser.add_argument("task", type=str)
|
|
68
|
+
tx_parser.add_argument("policy", type=str)
|
|
69
|
+
tx_parser.add_argument(
|
|
70
|
+
"--payload-json",
|
|
71
|
+
required=True,
|
|
72
|
+
help="Transaction payload as JSON string",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# -------------------------------------------------------------
|
|
76
|
+
# ergon process-transaction-by-id
|
|
77
|
+
# -------------------------------------------------------------
|
|
78
|
+
tx_id_parser = subparsers.add_parser(
|
|
79
|
+
"process-transaction-by-id",
|
|
80
|
+
help="Process a transaction by ID via connector fetch",
|
|
81
|
+
)
|
|
82
|
+
tx_id_parser.add_argument("task", type=str)
|
|
83
|
+
tx_id_parser.add_argument("policy", type=str)
|
|
84
|
+
tx_id_parser.add_argument("transaction_id", type=str)
|
|
85
|
+
|
|
86
|
+
# -------------------------------------------------------------
|
|
87
|
+
# ergon bootstrap
|
|
88
|
+
# -------------------------------------------------------------
|
|
89
|
+
bootstrap_parser = subparsers.add_parser(
|
|
90
|
+
"bootstrap",
|
|
91
|
+
help="Create a new project using the Ergon template",
|
|
92
|
+
)
|
|
93
|
+
bootstrap_parser.add_argument("project_name", type=str)
|
|
94
|
+
bootstrap_parser.add_argument(
|
|
95
|
+
"target_dir",
|
|
96
|
+
nargs="?",
|
|
97
|
+
default=".",
|
|
98
|
+
help="Target directory (default: current directory)",
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
return parser
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# ---------------------------------------------------------------------
|
|
105
|
+
# CLI entry point
|
|
106
|
+
# ---------------------------------------------------------------------
|
|
107
|
+
def ergon(tasks: Optional[List[TaskConfig]] = None):
|
|
108
|
+
if tasks:
|
|
109
|
+
for cfg in tasks:
|
|
110
|
+
if not manager.get(cfg.name):
|
|
111
|
+
manager.register(cfg)
|
|
112
|
+
|
|
113
|
+
parser = create_parser()
|
|
114
|
+
args = parser.parse_args()
|
|
115
|
+
|
|
116
|
+
if not args.command:
|
|
117
|
+
parser.print_help()
|
|
118
|
+
sys.exit(1)
|
|
119
|
+
|
|
120
|
+
# -------------------------------------------------------------
|
|
121
|
+
# LIST TASKS
|
|
122
|
+
# -------------------------------------------------------------
|
|
123
|
+
if args.command == "list":
|
|
124
|
+
task_names = manager.list_tasks()
|
|
125
|
+
if not task_names:
|
|
126
|
+
print("No tasks registered. Did you import your config files?")
|
|
127
|
+
else:
|
|
128
|
+
print("Registered tasks:")
|
|
129
|
+
for t in task_names:
|
|
130
|
+
print(f" - {t}")
|
|
131
|
+
return
|
|
132
|
+
|
|
133
|
+
# -------------------------------------------------------------
|
|
134
|
+
# RUN TASK
|
|
135
|
+
# -------------------------------------------------------------
|
|
136
|
+
if args.command == "run":
|
|
137
|
+
manager.run(args.task_name)
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
# -------------------------------------------------------------
|
|
141
|
+
# PROCESS TRANSACTION (INLINE)
|
|
142
|
+
# -------------------------------------------------------------
|
|
143
|
+
if args.command == "process-transaction":
|
|
144
|
+
try:
|
|
145
|
+
payload = json.loads(args.payload_json)
|
|
146
|
+
except json.JSONDecodeError as exc:
|
|
147
|
+
print(f"[ERROR] Invalid JSON payload: {exc}")
|
|
148
|
+
sys.exit(2)
|
|
149
|
+
|
|
150
|
+
transaction = Transaction(id=str(uuid.uuid4()), payload=payload)
|
|
151
|
+
manager.process_transaction(
|
|
152
|
+
task=args.task,
|
|
153
|
+
policy=args.policy,
|
|
154
|
+
transaction=transaction,
|
|
155
|
+
)
|
|
156
|
+
return
|
|
157
|
+
|
|
158
|
+
# -------------------------------------------------------------
|
|
159
|
+
# PROCESS TRANSACTION BY ID
|
|
160
|
+
# -------------------------------------------------------------
|
|
161
|
+
if args.command == "process-transaction-by-id":
|
|
162
|
+
manager.process_transaction_by_id(
|
|
163
|
+
task=args.task,
|
|
164
|
+
policy=args.policy,
|
|
165
|
+
transaction_id=args.transaction_id,
|
|
166
|
+
)
|
|
167
|
+
return
|
|
168
|
+
|
|
169
|
+
# -------------------------------------------------------------
|
|
170
|
+
# BOOTSTRAP
|
|
171
|
+
# -------------------------------------------------------------
|
|
172
|
+
if args.command == "bootstrap":
|
|
173
|
+
bootstrap_project(args.project_name, args.target_dir)
|
|
174
|
+
return
|