workflow.core 1.5.0__tar.gz → 1.6.0__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.
- {workflow_core-1.5.0 → workflow_core-1.6.0}/PKG-INFO +1 -1
- {workflow_core-1.5.0 → workflow_core-1.6.0}/pyproject.toml +1 -1
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/cli/run.py +23 -11
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/daemons/audit.py +1 -10
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/examples/function.py +24 -1
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/lifecycle/attempt.py +7 -1
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/lifecycle/execute.py +3 -2
- {workflow_core-1.5.0 → workflow_core-1.6.0}/README.md +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/cli/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/cli/buckets.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/cli/configs.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/cli/main.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/cli/pipelines.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/cli/results.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/cli/schedules.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/cli/workspace.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/daemons/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/daemons/transfer.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/definitions/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/definitions/config.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/definitions/jsonschema.md +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/definitions/notify.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/definitions/work.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/definitions/workspace.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/examples/sample.svg +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/examples/sample.workflow.yml +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/helpers/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/helpers/date.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/http/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/http/buckets.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/http/client.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/http/configs.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/http/context.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/http/pipelines.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/http/results.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/http/schedules.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/lifecycle/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/lifecycle/archive/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/lifecycle/archive/http.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/lifecycle/archive/posix.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/lifecycle/archive/s3.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/lifecycle/configure.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/decorators.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/logger.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/prompt.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/read.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/renderers.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/tmate.sh +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/validate.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/variables.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/utils/write.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/workspaces/__init__.py +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/workspaces/chimefrb.yml +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/workspaces/development.yml +0 -0
- {workflow_core-1.5.0 → workflow_core-1.6.0}/workflow/workspaces/site-dev.yml +0 -0
|
@@ -107,6 +107,13 @@ localspaces = Path(DEFAULT_WORKSPACE_PATH).parent
|
|
|
107
107
|
show_default=True,
|
|
108
108
|
help="workspace config.",
|
|
109
109
|
)
|
|
110
|
+
@click.option(
|
|
111
|
+
"--argsource",
|
|
112
|
+
type=click.Choice(["parameters", "work"]),
|
|
113
|
+
default="parameters",
|
|
114
|
+
show_default=True,
|
|
115
|
+
help="run function with parameters or work object.",
|
|
116
|
+
)
|
|
110
117
|
@click.option(
|
|
111
118
|
"--log-level",
|
|
112
119
|
type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]),
|
|
@@ -125,6 +132,7 @@ def run(
|
|
|
125
132
|
lives: int,
|
|
126
133
|
sleep: int,
|
|
127
134
|
workspace: Union[str, Dict[Any, Any]],
|
|
135
|
+
argsource: str,
|
|
128
136
|
log_level: str,
|
|
129
137
|
):
|
|
130
138
|
"""Fetch and perform work."""
|
|
@@ -153,6 +161,7 @@ def run(
|
|
|
153
161
|
)
|
|
154
162
|
logger.info(f"Buckets : {buckets}")
|
|
155
163
|
logger.info(f"Function : {function}")
|
|
164
|
+
logger.info(f"Argsource: {argsource}")
|
|
156
165
|
logger.info(f"Command : {command}")
|
|
157
166
|
logger.info(f"Mode : {'Static' if (function or command) else 'Dynamic'}")
|
|
158
167
|
logger.info(f"Lives : {'infinite' if lives == -1 else lives}")
|
|
@@ -212,17 +221,18 @@ def run(
|
|
|
212
221
|
refresh_per_second=10 if tty else 1,
|
|
213
222
|
):
|
|
214
223
|
lifecycle(
|
|
215
|
-
buckets,
|
|
216
|
-
function,
|
|
217
|
-
command,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
buckets=buckets,
|
|
225
|
+
function=function,
|
|
226
|
+
command=command,
|
|
227
|
+
argsource=argsource,
|
|
228
|
+
lives=lives,
|
|
229
|
+
sleep=sleep,
|
|
230
|
+
site=site,
|
|
231
|
+
tags=tags,
|
|
232
|
+
parents=parents,
|
|
233
|
+
events=events,
|
|
234
|
+
config=config,
|
|
235
|
+
http=http,
|
|
226
236
|
)
|
|
227
237
|
except Exception as error:
|
|
228
238
|
logger.exception(error)
|
|
@@ -237,6 +247,7 @@ def lifecycle(
|
|
|
237
247
|
buckets: List[str],
|
|
238
248
|
function: Optional[str],
|
|
239
249
|
command: Optional[str],
|
|
250
|
+
argsource: str,
|
|
240
251
|
lives: int,
|
|
241
252
|
sleep: int,
|
|
242
253
|
site: str,
|
|
@@ -266,6 +277,7 @@ def lifecycle(
|
|
|
266
277
|
buckets=buckets,
|
|
267
278
|
function=function,
|
|
268
279
|
command=command,
|
|
280
|
+
argsource=argsource,
|
|
269
281
|
site=site,
|
|
270
282
|
tags=tags,
|
|
271
283
|
parents=parents,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Audit Daemon."""
|
|
2
2
|
|
|
3
3
|
import time
|
|
4
|
-
from typing import Any, Dict,
|
|
4
|
+
from typing import Any, Dict, Union
|
|
5
5
|
|
|
6
6
|
import click
|
|
7
7
|
from click_params import JSON, URL, FirstOf
|
|
@@ -34,13 +34,6 @@ logger = get_logger("workflow.daemons.audit")
|
|
|
34
34
|
show_default=True,
|
|
35
35
|
help="workspace config.",
|
|
36
36
|
)
|
|
37
|
-
@click.option(
|
|
38
|
-
"--token",
|
|
39
|
-
"-t",
|
|
40
|
-
default=None,
|
|
41
|
-
type=click.STRING,
|
|
42
|
-
help="Authentication Token.",
|
|
43
|
-
)
|
|
44
37
|
@click.option(
|
|
45
38
|
"--test-mode",
|
|
46
39
|
default=False,
|
|
@@ -51,7 +44,6 @@ logger = get_logger("workflow.daemons.audit")
|
|
|
51
44
|
def audit(
|
|
52
45
|
sleep: int,
|
|
53
46
|
workspace: Union[str, Dict[Any, Any]],
|
|
54
|
-
token: Optional[str],
|
|
55
47
|
test_mode: bool,
|
|
56
48
|
) -> Dict[str, Any]:
|
|
57
49
|
"""Audit Buckets Backend.
|
|
@@ -68,7 +60,6 @@ def audit(
|
|
|
68
60
|
logger.info("Starting Audit Daemon")
|
|
69
61
|
logger.info(f"Sleep Time: {sleep}")
|
|
70
62
|
logger.info(f"Workspace : {workspace}")
|
|
71
|
-
logger.info(f"Token : {token}")
|
|
72
63
|
logger.info(f"Test Mode : {test_mode}")
|
|
73
64
|
configure.workspace(workspace=workspace)
|
|
74
65
|
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"""Sample CHIME/FRB Workflow Compatible Function."""
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Dict, List, Tuple, Union
|
|
4
|
+
from typing import Any, Dict, List, Tuple, Union
|
|
5
5
|
|
|
6
6
|
import click
|
|
7
7
|
from click_params import FirstOf
|
|
8
8
|
|
|
9
|
+
from workflow.definitions.work import Work
|
|
10
|
+
from workflow.utils.logger import get_logger
|
|
11
|
+
|
|
12
|
+
logger = get_logger("workflow.examples.function")
|
|
13
|
+
|
|
9
14
|
|
|
10
15
|
def math(
|
|
11
16
|
alpha: Union[float, int], beta: Union[float, int] = 1.0
|
|
@@ -24,6 +29,7 @@ def math(
|
|
|
24
29
|
The results, products, and plots
|
|
25
30
|
"""
|
|
26
31
|
try:
|
|
32
|
+
logger.info(f"Running math with alpha:{alpha}, beta:{beta}")
|
|
27
33
|
assert isinstance(alpha, (float, int)), "alpha must be a number"
|
|
28
34
|
assert isinstance(beta, (float, int)), "beta must be a number"
|
|
29
35
|
results: Dict[str, float] = {
|
|
@@ -52,6 +58,23 @@ def math(
|
|
|
52
58
|
raise error
|
|
53
59
|
|
|
54
60
|
|
|
61
|
+
def worker(work: Work) -> Work:
|
|
62
|
+
"""Sample CHIME/FRB Workflow Compatible Function.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
work (Work): A work object
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
Work: The work object
|
|
69
|
+
"""
|
|
70
|
+
logger.info("Processing math with work object...")
|
|
71
|
+
parameters: Dict[str, Any] = work.parameters or {}
|
|
72
|
+
alpha: float = float(parameters.get("alpha", 1.14))
|
|
73
|
+
beta: float = float(parameters.get("beta", 3.14))
|
|
74
|
+
work.results, work.products, work.plots = math(alpha, beta)
|
|
75
|
+
return work
|
|
76
|
+
|
|
77
|
+
|
|
55
78
|
@click.command("math", help="Sample CHIME/FRB Workflow Compatible Function.")
|
|
56
79
|
@click.option(
|
|
57
80
|
"--alpha",
|
|
@@ -16,6 +16,7 @@ def work(
|
|
|
16
16
|
buckets: List[str],
|
|
17
17
|
function: Optional[str],
|
|
18
18
|
command: Optional[str],
|
|
19
|
+
argsource: str,
|
|
19
20
|
site: str,
|
|
20
21
|
tags: List[str],
|
|
21
22
|
parents: List[str],
|
|
@@ -28,6 +29,8 @@ def work(
|
|
|
28
29
|
Args:
|
|
29
30
|
buckets (List[str]): Name of the buckets to perform work from.
|
|
30
31
|
function (Optional[str]): Static function to perform work.
|
|
32
|
+
command (Optional[str]): Static command to perform work.
|
|
33
|
+
argsource (str): Source of arguments for the function.
|
|
31
34
|
site (str): Site to filter work by.
|
|
32
35
|
tags (List[str]): Tags to filter work by.
|
|
33
36
|
parents (List[str]): Parent pipeline to filter work by.
|
|
@@ -82,9 +85,12 @@ def work(
|
|
|
82
85
|
assert work.command or work.function, "neither function or command provided"
|
|
83
86
|
|
|
84
87
|
# Get the user function from the work object dynamically
|
|
85
|
-
if work.function:
|
|
88
|
+
if work.function and argsource == "parameters":
|
|
86
89
|
logger.debug(f"executing function: {work.function}")
|
|
87
90
|
work = execute.function(work)
|
|
91
|
+
elif work.function and argsource == "work":
|
|
92
|
+
logger.debug(f"executing function with work object: {work.function}")
|
|
93
|
+
work = execute.function_with_work(work)
|
|
88
94
|
|
|
89
95
|
# If we have a valid command, execute it
|
|
90
96
|
if work.command:
|
|
@@ -127,7 +127,7 @@ def command(work: Work) -> Work:
|
|
|
127
127
|
return work
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
def
|
|
130
|
+
def function_with_work(work: Work) -> Work:
|
|
131
131
|
"""Execute a work function with work object.
|
|
132
132
|
|
|
133
133
|
Args:
|
|
@@ -144,10 +144,11 @@ def with_work(work: Work) -> Work:
|
|
|
144
144
|
# Check the type hints of the function,
|
|
145
145
|
# check if the input/output is a Work object
|
|
146
146
|
hints = get_type_hints(func)
|
|
147
|
-
logger.info(f"function
|
|
147
|
+
logger.info(f"executing function with work object: {func.__name__}({work})")
|
|
148
148
|
assert hints.get("work") == Work, "function must have a Work object as input"
|
|
149
149
|
assert hints.get("return") == Work, "function must return a Work object"
|
|
150
150
|
work = func(work)
|
|
151
|
+
validate.size(work)
|
|
151
152
|
work.status = "success"
|
|
152
153
|
except Exception as error:
|
|
153
154
|
work.status = "failure"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|