data_pipeline_api 0.8.0__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.
- data_pipeline_api/__init__.py +27 -0
- data_pipeline_api/ext/SEIRSModelRun.py +43 -0
- data_pipeline_api/ext/SEIRSconfig.yaml +31 -0
- data_pipeline_api/ext/SEIRSconfigWindows.yaml +31 -0
- data_pipeline_api/ext/__init__.py +0 -0
- data_pipeline_api/ext/static_params_SEIRS.csv +8 -0
- data_pipeline_api/fdp_utils.py +517 -0
- data_pipeline_api/link.py +218 -0
- data_pipeline_api/pipeline.py +611 -0
- data_pipeline_api/raise_issue.py +255 -0
- data_pipeline_api-0.8.0.dist-info/LICENSE +674 -0
- data_pipeline_api-0.8.0.dist-info/METADATA +75 -0
- data_pipeline_api-0.8.0.dist-info/RECORD +14 -0
- data_pipeline_api-0.8.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def raise_issue_by_index(
|
|
6
|
+
handle: dict,
|
|
7
|
+
index: Optional[bool],
|
|
8
|
+
issue: str,
|
|
9
|
+
severity: int,
|
|
10
|
+
group: bool = True,
|
|
11
|
+
) -> None:
|
|
12
|
+
"""
|
|
13
|
+
Raises an issue for a given input or output index and writes it to the handle
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
| handle: the handle containing the index
|
|
17
|
+
| index: a unique reference to an input or output in
|
|
18
|
+
| the handle see get_handle_index_from_path()
|
|
19
|
+
| issue: what the issue is as a string
|
|
20
|
+
| severity: How severe the issue is as an interger from 1-10
|
|
21
|
+
"""
|
|
22
|
+
return raise_issue(
|
|
23
|
+
handle, "index", issue, severity, index=index, group=group
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def raise_issue_by_existing_data_product(
|
|
28
|
+
handle: dict,
|
|
29
|
+
data_product: str,
|
|
30
|
+
version: str,
|
|
31
|
+
namespace: str,
|
|
32
|
+
issue: str,
|
|
33
|
+
severity: int,
|
|
34
|
+
group: bool = True,
|
|
35
|
+
) -> None:
|
|
36
|
+
"""
|
|
37
|
+
Raises an issue for a given data_product and writes it to the handle
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
| data_product: the data_product name as a string
|
|
41
|
+
| version: version of the data_product as a string
|
|
42
|
+
| namespace: namespace of the date_product as a string
|
|
43
|
+
| issue: what the issue is as a string
|
|
44
|
+
| severity: How severe the issue is as an interger from 1-10
|
|
45
|
+
"""
|
|
46
|
+
return raise_issue(
|
|
47
|
+
handle,
|
|
48
|
+
"existing_data_product",
|
|
49
|
+
issue,
|
|
50
|
+
severity,
|
|
51
|
+
data_product=data_product,
|
|
52
|
+
namespace=namespace,
|
|
53
|
+
version=version,
|
|
54
|
+
group=group,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def raise_issue_by_data_product(
|
|
59
|
+
handle: dict,
|
|
60
|
+
data_product: str,
|
|
61
|
+
version: str,
|
|
62
|
+
namespace: str,
|
|
63
|
+
issue: str,
|
|
64
|
+
severity: int,
|
|
65
|
+
group: bool = True,
|
|
66
|
+
) -> None:
|
|
67
|
+
"""
|
|
68
|
+
Raises an issue for a given data_product in the run_metadata and writes it to the handle
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
| data_product: the data_product name as a string
|
|
72
|
+
| version: version of the data_product as a string
|
|
73
|
+
| namespace: namespace of the date_product as a string
|
|
74
|
+
| issue: what the issue is as a string
|
|
75
|
+
| severity: How severe the issue is as an interger from 1-10
|
|
76
|
+
"""
|
|
77
|
+
return raise_issue(
|
|
78
|
+
handle,
|
|
79
|
+
"data_product",
|
|
80
|
+
issue,
|
|
81
|
+
severity,
|
|
82
|
+
data_product=data_product,
|
|
83
|
+
namespace=namespace,
|
|
84
|
+
version=version,
|
|
85
|
+
group=group,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def raise_issue_with_config(
|
|
90
|
+
handle: dict, issue: str, severity: int, group: bool = True
|
|
91
|
+
) -> None:
|
|
92
|
+
"""
|
|
93
|
+
Raise an issue with config: add an issue for the config to the handle.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
| handle
|
|
97
|
+
| issue: what the issue is as a string
|
|
98
|
+
| severity: How severe the issue is as an interger from 1-10
|
|
99
|
+
"""
|
|
100
|
+
return raise_issue_by_type(handle, "config", issue, severity, group)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def raise_issue_with_submission_script(
|
|
104
|
+
handle: dict, issue: str, severity: int, group: bool = True
|
|
105
|
+
) -> None:
|
|
106
|
+
"""
|
|
107
|
+
Raise an issue with submission script: add an issue for the submission_script to the handle.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
| handle
|
|
111
|
+
| issue: what the issue is as a string
|
|
112
|
+
| severity: How severe the issue is as an interger from 1-10
|
|
113
|
+
"""
|
|
114
|
+
return raise_issue_by_type(
|
|
115
|
+
handle, "submission_script", issue, severity, group
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def raise_issue_with_github_repo(
|
|
120
|
+
handle: dict, issue: str, severity: int, group: bool = True
|
|
121
|
+
) -> None:
|
|
122
|
+
"""
|
|
123
|
+
Raise an issue with config add an issue for the github_repo to the handle.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
| handle
|
|
127
|
+
| issue: what the issue is as a string
|
|
128
|
+
| severity: How severe the issue is as an interger from 1-10
|
|
129
|
+
"""
|
|
130
|
+
return raise_issue_by_type(handle, "github_repo", issue, severity, group)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def raise_issue_by_type(
|
|
134
|
+
handle: dict, type: str, issue: str, severity: int, group: bool = True
|
|
135
|
+
) -> None:
|
|
136
|
+
"""
|
|
137
|
+
Raise an issue by type of issue (with config, with submission_script, with github_repo)
|
|
138
|
+
"""
|
|
139
|
+
accepted_types = ["config", "submission_script", "github_repo"]
|
|
140
|
+
if type not in accepted_types:
|
|
141
|
+
raise ValueError(
|
|
142
|
+
"Please supply a valid type. \
|
|
143
|
+
valid types: config, submission_script, github_repo"
|
|
144
|
+
)
|
|
145
|
+
return raise_issue(handle, type, issue, severity, index=False, group=group)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
# flake8: noqa C901
|
|
149
|
+
def raise_issue(
|
|
150
|
+
handle: dict,
|
|
151
|
+
issue_type: str,
|
|
152
|
+
issue: str,
|
|
153
|
+
severity: int,
|
|
154
|
+
index: bool = None,
|
|
155
|
+
data_product: str = None,
|
|
156
|
+
component: str = None,
|
|
157
|
+
version: str = None,
|
|
158
|
+
namespace: str = None,
|
|
159
|
+
group: bool = True,
|
|
160
|
+
) -> None:
|
|
161
|
+
current_group = issue + ":" + str(severity)
|
|
162
|
+
if issue_type in {
|
|
163
|
+
"config",
|
|
164
|
+
"submission_script",
|
|
165
|
+
"github_repo",
|
|
166
|
+
"existing_data_product",
|
|
167
|
+
}:
|
|
168
|
+
logging.info("Adding issue {} for {} to handle".format(issue, type))
|
|
169
|
+
elif index is None:
|
|
170
|
+
reads = (
|
|
171
|
+
handle["yaml"]["read"] if "read" in handle["yaml"].keys() else None
|
|
172
|
+
)
|
|
173
|
+
writes = (
|
|
174
|
+
handle["yaml"]["write"]
|
|
175
|
+
if "write" in handle["yaml"].keys()
|
|
176
|
+
else None
|
|
177
|
+
)
|
|
178
|
+
data_product_in_config = False
|
|
179
|
+
if reads:
|
|
180
|
+
for i in reads:
|
|
181
|
+
if i["data_product"] == data_product:
|
|
182
|
+
data_product_in_config = True
|
|
183
|
+
if (
|
|
184
|
+
"use" in i.keys()
|
|
185
|
+
and "use_version" in i["use"].keys()
|
|
186
|
+
and i["use"]["version"] != version
|
|
187
|
+
):
|
|
188
|
+
data_product_in_config = False
|
|
189
|
+
data_product = i["data_product"]
|
|
190
|
+
if not group:
|
|
191
|
+
current_group = i["data_product"]
|
|
192
|
+
if writes:
|
|
193
|
+
for i in writes:
|
|
194
|
+
if i["data_product"] == data_product:
|
|
195
|
+
data_product_in_config = (
|
|
196
|
+
"use" not in i.keys()
|
|
197
|
+
or "use_version" not in i["use"].keys()
|
|
198
|
+
or i["use"]["version"] == version
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
data_product = i["data_product"]
|
|
202
|
+
if not group:
|
|
203
|
+
current_group = i["data_product"]
|
|
204
|
+
|
|
205
|
+
if not data_product_in_config:
|
|
206
|
+
raise ValueError("Data product not in config file")
|
|
207
|
+
|
|
208
|
+
logging.info(
|
|
209
|
+
"Raising issue {} for {}@{} to handle".format(
|
|
210
|
+
issue, data_product, version
|
|
211
|
+
)
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
else:
|
|
215
|
+
tmp = None
|
|
216
|
+
if "output" in handle:
|
|
217
|
+
for output in handle["output"]:
|
|
218
|
+
if output == index:
|
|
219
|
+
tmp = handle["output"][output]
|
|
220
|
+
if not group:
|
|
221
|
+
current_group = handle["output"][output]
|
|
222
|
+
if "input" in handle:
|
|
223
|
+
for input in handle["input"]:
|
|
224
|
+
if input == index:
|
|
225
|
+
tmp = handle["input"][input]
|
|
226
|
+
if not group:
|
|
227
|
+
current_group = handle["input"][input]
|
|
228
|
+
if tmp is None:
|
|
229
|
+
raise ValueError("Error: index not found in handle")
|
|
230
|
+
|
|
231
|
+
data_product = tmp["data_product"]
|
|
232
|
+
component = tmp["use_component"]
|
|
233
|
+
version = tmp["use_version"]
|
|
234
|
+
namespace = tmp["use_namespace"]
|
|
235
|
+
|
|
236
|
+
logging.info("Adding issue {} for {} to handle".format(issue, index))
|
|
237
|
+
# Write to handle and return path
|
|
238
|
+
issues_dict = {
|
|
239
|
+
"index": index,
|
|
240
|
+
"type": issue_type,
|
|
241
|
+
"use_data_product": data_product,
|
|
242
|
+
"use_component": component,
|
|
243
|
+
"version": version,
|
|
244
|
+
"use_namespace": namespace,
|
|
245
|
+
"issue": issue,
|
|
246
|
+
"severity": severity,
|
|
247
|
+
"group": current_group,
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if "issues" in handle:
|
|
251
|
+
this_issue = "issue_" + str(len(handle["issues"]))
|
|
252
|
+
handle["issues"][this_issue] = issues_dict
|
|
253
|
+
else:
|
|
254
|
+
handle["issues"] = {}
|
|
255
|
+
handle["issues"]["issue_0"] = issues_dict
|