workflow.core 1.4.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.4.0 → workflow_core-1.6.0}/PKG-INFO +11 -5
- {workflow_core-1.4.0 → workflow_core-1.6.0}/README.md +10 -4
- {workflow_core-1.4.0 → workflow_core-1.6.0}/pyproject.toml +1 -1
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/cli/run.py +23 -11
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/daemons/transfer.py +44 -89
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/examples/function.py +24 -1
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/lifecycle/archive/s3.py +6 -6
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/lifecycle/attempt.py +7 -1
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/lifecycle/execute.py +3 -2
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/cli/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/cli/buckets.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/cli/configs.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/cli/main.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/cli/pipelines.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/cli/results.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/cli/schedules.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/cli/workspace.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/daemons/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/daemons/audit.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/definitions/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/definitions/config.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/definitions/jsonschema.md +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/definitions/notify.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/definitions/work.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/definitions/workspace.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/examples/sample.svg +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/examples/sample.workflow.yml +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/helpers/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/helpers/date.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/http/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/http/buckets.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/http/client.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/http/configs.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/http/context.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/http/pipelines.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/http/results.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/http/schedules.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/lifecycle/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/lifecycle/archive/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/lifecycle/archive/http.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/lifecycle/archive/posix.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/lifecycle/configure.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/decorators.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/logger.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/prompt.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/read.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/renderers.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/tmate.sh +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/validate.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/variables.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/utils/write.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/workspaces/__init__.py +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/workspaces/chimefrb.yml +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/workspaces/development.yml +0 -0
- {workflow_core-1.4.0 → workflow_core-1.6.0}/workflow/workspaces/site-dev.yml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: workflow.core
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Summary: Workflow Core
|
|
5
5
|
Home-page: https://github.com/chimefrb/workflow
|
|
6
6
|
License: MIT
|
|
@@ -39,12 +39,18 @@ For more information, please refer to the [Workflow documentation](https://chime
|
|
|
39
39
|
|
|
40
40
|
## Getting Started
|
|
41
41
|
|
|
42
|
-
To get started with the Workflow
|
|
42
|
+
To get started with the Workflow, you need to have Python 3.8.1 or later installed. You can then install the project's dependencies using Poetry:
|
|
43
|
+
|
|
44
|
+
### Install from PyPI
|
|
43
45
|
|
|
44
46
|
```bash
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
pip install workflow.core
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Install from Source
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install git+https://github.com/chimefrb/workflow.git
|
|
48
54
|
```
|
|
49
55
|
|
|
50
56
|
Alternatively, you can add the Workflow project as a dependency to your own project using Poetry:
|
|
@@ -8,12 +8,18 @@ For more information, please refer to the [Workflow documentation](https://chime
|
|
|
8
8
|
|
|
9
9
|
## Getting Started
|
|
10
10
|
|
|
11
|
-
To get started with the Workflow
|
|
11
|
+
To get started with the Workflow, you need to have Python 3.8.1 or later installed. You can then install the project's dependencies using Poetry:
|
|
12
|
+
|
|
13
|
+
### Install from PyPI
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
pip install workflow.core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Install from Source
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install git+https://github.com/chimefrb/workflow.git
|
|
17
23
|
```
|
|
18
24
|
|
|
19
25
|
Alternatively, you can add the Workflow project as a dependency to your own project using Poetry:
|
|
@@ -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,19 +1,16 @@
|
|
|
1
1
|
"""Workflow Transfer Daemon."""
|
|
2
2
|
|
|
3
3
|
import time
|
|
4
|
-
from typing import Any, Dict, List
|
|
4
|
+
from typing import Any, Dict, List
|
|
5
5
|
|
|
6
6
|
import click
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
from workflow import DEFAULT_WORKSPACE_PATH
|
|
9
9
|
from workflow.http.buckets import Buckets
|
|
10
10
|
from workflow.http.results import Results
|
|
11
|
-
from workflow.utils
|
|
12
|
-
from workflow.utils import read
|
|
13
|
-
from workflow.lifecycle import configure
|
|
14
|
-
from workflow.http.context import HTTPContext
|
|
11
|
+
from workflow.utils import logger, read
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
log = logger.get_logger("workflow.daemons.transfer")
|
|
17
14
|
|
|
18
15
|
|
|
19
16
|
def deposit_work_to_results(
|
|
@@ -66,94 +63,48 @@ def is_work_already_deposited(results: Results, work: Dict[str, Any]) -> bool:
|
|
|
66
63
|
|
|
67
64
|
|
|
68
65
|
@click.command()
|
|
69
|
-
@click.option("--sleep", "-s", default=5, help="
|
|
66
|
+
@click.option("--sleep", "-s", default=5, help="Time to sleep between transfers")
|
|
70
67
|
@click.option(
|
|
71
|
-
"-
|
|
72
|
-
"
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
URL,
|
|
76
|
-
JSON,
|
|
77
|
-
),
|
|
78
|
-
default=(DEFAULT_WORKSPACE_PATH.as_posix()),
|
|
79
|
-
show_default=True,
|
|
80
|
-
help="workspace config.",
|
|
68
|
+
"--buckets-base-url",
|
|
69
|
+
"-b",
|
|
70
|
+
default="http://frb-vsop.chime:8004",
|
|
71
|
+
help="Location of the Buckets backend.",
|
|
81
72
|
)
|
|
82
|
-
@click.option("--limit", default=50, help="works to transfer per run.")
|
|
83
73
|
@click.option(
|
|
84
|
-
"--
|
|
74
|
+
"--results-base-url",
|
|
75
|
+
"-r",
|
|
76
|
+
default="http://frb-vsop.chime:8005",
|
|
77
|
+
help="Location of the Results backend.",
|
|
85
78
|
)
|
|
86
79
|
@click.option(
|
|
87
80
|
"--test-mode", default=False, help="Enable test mode to avoid while True loop"
|
|
88
81
|
)
|
|
89
|
-
def
|
|
82
|
+
def transfer_work(
|
|
90
83
|
sleep: int,
|
|
91
|
-
|
|
84
|
+
buckets_base_url: str,
|
|
85
|
+
results_base_url: str,
|
|
92
86
|
test_mode: bool,
|
|
93
|
-
|
|
94
|
-
cutoff: int,
|
|
87
|
+
limit_per_run: int = 50,
|
|
95
88
|
) -> Dict[str, Any]:
|
|
96
|
-
"""Transfer
|
|
97
|
-
Args:
|
|
98
|
-
sleep (int): seconds to sleep between transfers.
|
|
99
|
-
workspace (Union[str, Dict[Any, Any]]): workspace config.
|
|
100
|
-
test_mode (bool): Enable test mode to avoid while True loop.
|
|
101
|
-
limit (int): works to transfer per run.
|
|
102
|
-
cutoff (int): cutoff time in seconds for stale work.
|
|
89
|
+
"""Transfer successful Work from Buckets DB to Results DB.
|
|
103
90
|
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
Args:
|
|
92
|
+
sleep (int): number of seconds to sleep between transfers
|
|
93
|
+
buckets_base_url (str): location of the Buckets backend
|
|
94
|
+
results_base_url (str): location of the Results backend
|
|
95
|
+
test_mode (bool): Enable test mode to avoid while True loop
|
|
96
|
+
limit_per_run (int): Max number of failed Work entires to transfer per
|
|
97
|
+
run of daemon.
|
|
106
98
|
"""
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
.get("config", {})
|
|
117
|
-
.get("archive", {})
|
|
118
|
-
.get("results", True)
|
|
119
|
-
)
|
|
120
|
-
logger.info(f"Archive : {'Enabled' if archive else 'Disabled'}")
|
|
121
|
-
http: HTTPContext = HTTPContext(backends=["buckets", "results"])
|
|
122
|
-
logger.info("HTTP Context Initialized")
|
|
123
|
-
logger.info(f"HTTP Context: Buckets Backend @ {http.buckets.baseurl}")
|
|
124
|
-
logger.info(f"HTTP Context: Results Backend @ {http.results.baseurl}")
|
|
125
|
-
|
|
126
|
-
delete: List[str] = []
|
|
127
|
-
successful: List[Dict[str, Any]] = []
|
|
128
|
-
failed: List[Dict[str, Any]] = []
|
|
129
|
-
|
|
130
|
-
for work in http.buckets.view(
|
|
131
|
-
query={"status": "success"}, projection={}, skip=0, limit=limit
|
|
132
|
-
):
|
|
133
|
-
if work["config"]["archive"]["results"] is False:
|
|
134
|
-
delete.append(work["id"])
|
|
135
|
-
elif work["config"]["archive"]["results"] is True and archive:
|
|
136
|
-
successful.append(work)
|
|
137
|
-
else:
|
|
138
|
-
delete.append(work["id"])
|
|
139
|
-
|
|
140
|
-
# Transfer successful work to results
|
|
141
|
-
response: Dict[str, Any] = {}
|
|
142
|
-
response = http.results.deposit(successful)
|
|
143
|
-
for key, value in response.items():
|
|
144
|
-
if value:
|
|
145
|
-
delete.append(key)
|
|
146
|
-
|
|
147
|
-
try:
|
|
148
|
-
logger.info(f"Transferring {len(successful)} successful works to results")
|
|
149
|
-
response = http.results.deposit(successful)
|
|
150
|
-
for key, value in response.items():
|
|
151
|
-
if value:
|
|
152
|
-
delete.append(key)
|
|
153
|
-
except Exception as error:
|
|
154
|
-
logger.error("Failed to deposit successful works to results")
|
|
155
|
-
logger.error(f"Exception: {error}")
|
|
156
|
-
|
|
99
|
+
buckets = Buckets(base_url=buckets_base_url, debug=test_mode)
|
|
100
|
+
results = Results(base_url=results_base_url, debug=test_mode)
|
|
101
|
+
|
|
102
|
+
log.info("Starting Transfer Daemon")
|
|
103
|
+
log.info(f"Sleeptime: {sleep}")
|
|
104
|
+
log.info(f"Buckets@ : {buckets_base_url}")
|
|
105
|
+
log.info(f"Results@ : {results_base_url}")
|
|
106
|
+
log.info(f"Test Mode: {test_mode}")
|
|
107
|
+
log.info(f"Limit/Tx : {limit_per_run}")
|
|
157
108
|
|
|
158
109
|
def transfer(test_flag: bool, buckets: Buckets, results: Results) -> Dict[str, Any]:
|
|
159
110
|
"""Transfer Work from Buckets to Results.
|
|
@@ -166,7 +117,12 @@ def transfer(
|
|
|
166
117
|
Returns:
|
|
167
118
|
Dict[str, Any]: Transfer status.
|
|
168
119
|
"""
|
|
169
|
-
|
|
120
|
+
results_workspace_config = (
|
|
121
|
+
read.workspace(DEFAULT_WORKSPACE_PATH.as_posix())
|
|
122
|
+
.get("config", {})
|
|
123
|
+
.get("archive", {})
|
|
124
|
+
.get("results", None)
|
|
125
|
+
)
|
|
170
126
|
transfer_status: Dict[str, Any] = {}
|
|
171
127
|
# 1. Transfer successful Work
|
|
172
128
|
# TODO: decide projection fields
|
|
@@ -174,7 +130,7 @@ def transfer(
|
|
|
174
130
|
query={"status": "success"},
|
|
175
131
|
projection={},
|
|
176
132
|
skip=0,
|
|
177
|
-
limit=
|
|
133
|
+
limit=limit_per_run,
|
|
178
134
|
)
|
|
179
135
|
successful_work_to_delete = [
|
|
180
136
|
work
|
|
@@ -187,7 +143,6 @@ def transfer(
|
|
|
187
143
|
for work in successful_work
|
|
188
144
|
if work["config"]["archive"]["results"] is True and results_workspace_config
|
|
189
145
|
]
|
|
190
|
-
|
|
191
146
|
if successful_work_to_transfer:
|
|
192
147
|
transfer_status["successful_work_transferred"] = deposit_work_to_results(
|
|
193
148
|
buckets, results, successful_work_to_transfer
|
|
@@ -206,7 +161,7 @@ def transfer(
|
|
|
206
161
|
},
|
|
207
162
|
projection={},
|
|
208
163
|
skip=0,
|
|
209
|
-
limit=
|
|
164
|
+
limit=limit_per_run,
|
|
210
165
|
)
|
|
211
166
|
failed_work_to_delete = [
|
|
212
167
|
work
|
|
@@ -236,7 +191,7 @@ def transfer(
|
|
|
236
191
|
},
|
|
237
192
|
projection={},
|
|
238
193
|
skip=0,
|
|
239
|
-
limit=
|
|
194
|
+
limit=limit_per_run,
|
|
240
195
|
)
|
|
241
196
|
if stale_work:
|
|
242
197
|
buckets.delete_ids([work["id"] for work in stale_work])
|
|
@@ -252,4 +207,4 @@ def transfer(
|
|
|
252
207
|
|
|
253
208
|
|
|
254
209
|
if __name__ == "__main__":
|
|
255
|
-
|
|
210
|
+
transfer_work()
|
|
@@ -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",
|
|
@@ -68,9 +68,9 @@ def copy(path: Path, payload: Optional[List[str]]) -> bool:
|
|
|
68
68
|
file_path=item,
|
|
69
69
|
)
|
|
70
70
|
# Update payload with new path
|
|
71
|
-
payload[
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
payload[index] = (
|
|
72
|
+
f"s3://{os.getenv('WORKFLOW_S3_ENDPOINT')}/workflow/{'/'.join([object_paths, item.split('/')[-1]])}" # noqa: E501
|
|
73
|
+
)
|
|
74
74
|
log.info("Move complete ✅")
|
|
75
75
|
return True
|
|
76
76
|
except Exception as error:
|
|
@@ -120,9 +120,9 @@ def move(path: Path, payload: Optional[List[str]]) -> bool:
|
|
|
120
120
|
file_path=item,
|
|
121
121
|
)
|
|
122
122
|
# Update payload with new path
|
|
123
|
-
payload[
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
payload[index] = (
|
|
124
|
+
f"s3://{os.getenv('WORKFLOW_S3_ENDPOINT')}/workflow/{'/'.join([object_paths, item.split('/')[-1]])}" # noqa: E501 # noqa: E501
|
|
125
|
+
)
|
|
126
126
|
# Delete file
|
|
127
127
|
os.remove(item)
|
|
128
128
|
log.info("Move complete ✅")
|
|
@@ -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
|