workflow.core 1.9.11__tar.gz → 1.11.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.
Files changed (59) hide show
  1. {workflow_core-1.9.11 → workflow_core-1.11.0}/PKG-INFO +1 -1
  2. {workflow_core-1.9.11 → workflow_core-1.11.0}/pyproject.toml +1 -1
  3. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/cli/buckets.py +7 -1
  4. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/cli/configs.py +36 -8
  5. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/cli/pipelines.py +10 -2
  6. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/http/buckets.py +3 -1
  7. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/http/configs.py +27 -0
  8. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/renderers.py +24 -3
  9. {workflow_core-1.9.11 → workflow_core-1.11.0}/README.md +0 -0
  10. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/__init__.py +0 -0
  11. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/cli/__init__.py +0 -0
  12. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/cli/main.py +0 -0
  13. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/cli/results.py +0 -0
  14. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/cli/run.py +0 -0
  15. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/cli/schedules.py +0 -0
  16. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/cli/workspace.py +0 -0
  17. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/daemons/__init__.py +0 -0
  18. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/daemons/audit.py +0 -0
  19. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/daemons/transfer.py +0 -0
  20. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/definitions/__init__.py +0 -0
  21. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/definitions/config.py +0 -0
  22. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/definitions/jsonschema.md +0 -0
  23. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/definitions/notify.py +0 -0
  24. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/definitions/work.py +0 -0
  25. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/definitions/workspace.py +0 -0
  26. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/examples/autocomplete.py +0 -0
  27. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/examples/function.py +0 -0
  28. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/examples/sample.svg +0 -0
  29. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/examples/sample.workflow.yml +0 -0
  30. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/exceptions.py +0 -0
  31. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/helpers/__init__.py +0 -0
  32. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/helpers/date.py +0 -0
  33. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/http/__init__.py +0 -0
  34. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/http/client.py +0 -0
  35. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/http/context.py +0 -0
  36. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/http/pipelines.py +0 -0
  37. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/http/results.py +0 -0
  38. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/http/schedules.py +0 -0
  39. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/lifecycle/__init__.py +0 -0
  40. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/lifecycle/archive/__init__.py +0 -0
  41. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/lifecycle/archive/http.py +0 -0
  42. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/lifecycle/archive/posix.py +0 -0
  43. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/lifecycle/archive/s3.py +0 -0
  44. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/lifecycle/attempt.py +0 -0
  45. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/lifecycle/configure.py +0 -0
  46. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/lifecycle/execute.py +0 -0
  47. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/__init__.py +0 -0
  48. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/decorators.py +0 -0
  49. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/logger.py +0 -0
  50. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/prompt.py +0 -0
  51. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/read.py +0 -0
  52. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/tmate.sh +0 -0
  53. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/validate.py +0 -0
  54. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/variables.py +0 -0
  55. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/utils/write.py +0 -0
  56. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/workspaces/__init__.py +0 -0
  57. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/workspaces/chimefrb.yml +0 -0
  58. {workflow_core-1.9.11 → workflow_core-1.11.0}/workflow/workspaces/development.yml +0 -0
  59. {workflow_core-1.9.11 → workflow_core-1.11.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.9.11
3
+ Version: 1.11.0
4
4
  Summary: Workflow Core
5
5
  Home-page: https://github.com/chimefrb/workflow
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "workflow.core"
3
- version = "1.9.11"
3
+ version = "1.11.0"
4
4
  description = "Workflow Core"
5
5
  authors = ["Shiny Brar <charanjotbrar@gmail.com>"]
6
6
  license = "MIT"
@@ -38,6 +38,9 @@ def buckets():
38
38
  )
39
39
  @click.option("-p", "--parent", type=str, required=False, help="Filter by parent.")
40
40
  @click.option("-f", "--force", is_flag=True, help="Do not prompt for confirmation")
41
+ @click.option(
42
+ "-l", "--limit", type=int, required=False, help="Limit of Work objects to remove."
43
+ )
41
44
  def remove(
42
45
  bucket: str,
43
46
  status: Optional[str] = None,
@@ -45,6 +48,7 @@ def remove(
45
48
  tag: Optional[Tuple[str]] = None,
46
49
  parent: Optional[str] = None,
47
50
  force: bool = False,
51
+ limit: Optional[int] = 100,
48
52
  ):
49
53
  """Remove work[s] from the buckets.
50
54
 
@@ -55,8 +59,9 @@ def remove(
55
59
  tag (Optional[Tuple[str]], optional): Filter by tag. Defaults to None.
56
60
  parent (Optional[str], optional): Filter by parent. Defaults to None.
57
61
  force (bool, optional): Do not prompt for confirmation. Defaults to False.
62
+ limit (int, optional): Limit of Work objects to remove. Defaults to False.
58
63
  """
59
- http = HTTPContext()
64
+ http = HTTPContext(backends=["buckets"])
60
65
  events: Optional[List[int]] = None
61
66
  tags: Optional[List[str]] = None
62
67
  if event:
@@ -70,6 +75,7 @@ def remove(
70
75
  tags=tags,
71
76
  parent=parent,
72
77
  force=force,
78
+ limit=limit,
73
79
  )
74
80
 
75
81
 
@@ -48,7 +48,7 @@ def version():
48
48
  @configs.command("count", help="Count objects per collection.")
49
49
  def count():
50
50
  """Count objects in a database."""
51
- http = HTTPContext()
51
+ http = HTTPContext(backends=["configs"])
52
52
  counts = http.configs.count()
53
53
  table.add_column("Name", max_width=50, justify="left", style="blue")
54
54
  table.add_column("Count", max_width=50, justify="left")
@@ -75,7 +75,7 @@ def deploy(filename: click.Path):
75
75
  filename : click.Path
76
76
  File path.
77
77
  """
78
- http = HTTPContext()
78
+ http = HTTPContext(backends=["configs"])
79
79
  filepath: str = str(filename)
80
80
  data: Dict[str, Any] = {}
81
81
  with open(filepath) as reader:
@@ -148,7 +148,7 @@ def ls(name: Optional[str] = None, quiet: bool = False):
148
148
  projection = {"yaml": 0, "deployments": 0}
149
149
  if quiet:
150
150
  projection = {"id": 1}
151
- http = HTTPContext()
151
+ http = HTTPContext(backends=["configs"])
152
152
  objects = http.configs.get_configs(name=name, projection=json.dumps(projection))
153
153
 
154
154
  # ? Add columns for each key
@@ -188,7 +188,7 @@ def ls(name: Optional[str] = None, quiet: bool = False):
188
188
  )
189
189
  def ps(name: str, id: str, details: bool):
190
190
  """Show details for an object."""
191
- http = HTTPContext()
191
+ http = HTTPContext(backends=["configs", "pipelines"])
192
192
  query: str = json.dumps({"id": id})
193
193
  projection: str = json.dumps({})
194
194
  console_content = None
@@ -233,12 +233,12 @@ def ps(name: str, id: str, details: bool):
233
233
  console.print(console_content)
234
234
 
235
235
 
236
- @configs.command("stop", help="Stop managers for a Config.")
236
+ @configs.command("stop", help="Stop Pipelines related to a Config.")
237
237
  @click.argument("config", type=str, required=True)
238
238
  @click.argument("id", type=str, required=True)
239
239
  def stop(config: str, id: str):
240
240
  """Stop managers for a Config."""
241
- http = HTTPContext()
241
+ http = HTTPContext(backends=["configs"])
242
242
  stop_result = http.configs.stop(config, id)
243
243
  if not any(stop_result):
244
244
  text = Text("No configurations were stopped.", style="red")
@@ -258,12 +258,12 @@ def stop(config: str, id: str):
258
258
  console.print(table)
259
259
 
260
260
 
261
- @configs.command("rm", help="Remove a config.")
261
+ @configs.command("rm", help="Removes a config.")
262
262
  @click.argument("config", type=str, required=True)
263
263
  @click.argument("id", type=str, required=True)
264
264
  def rm(config: str, id: str):
265
265
  """Remove a config."""
266
- http = HTTPContext()
266
+ http = HTTPContext(backends=["configs"])
267
267
  content = None
268
268
  try:
269
269
  delete_result = http.configs.remove(config, id)
@@ -278,3 +278,31 @@ def rm(config: str, id: str):
278
278
  table.add_row(id)
279
279
  content = table
280
280
  console.print(content)
281
+
282
+
283
+ @configs.command("retry", help="Retry all Pipeline related to a Config.")
284
+ @click.argument("name", type=str, required=True)
285
+ @click.argument("id", type=str, required=True)
286
+ def retry(name: str, id: str):
287
+ """Retry all Pipeline related to a Config.
288
+
289
+ Parameters
290
+ ----------
291
+ name : str
292
+ Config name.
293
+ id : str
294
+ Config ID.
295
+ """
296
+ http = HTTPContext(backends=["configs"])
297
+ content = None
298
+ try:
299
+ retry_result = http.configs._retry(name, id)
300
+ except Exception as e:
301
+ text = Text(f"No configurations were retried.\nError: {e}", style="red")
302
+ content = text
303
+ else:
304
+ table.add_column(
305
+ retry_result["message"], max_width=50, justify="left", style="red"
306
+ )
307
+ content = table
308
+ console.print(content)
@@ -94,7 +94,15 @@ def count():
94
94
  @pipelines.command("ps", help="Get pipeline details.")
95
95
  # @click.argument("pipeline", type=str, required=True)
96
96
  @click.argument("id", type=str, required=True)
97
- def ps(id: str):
97
+ @click.option(
98
+ "-h",
99
+ "--history",
100
+ is_flag=True,
101
+ default=False,
102
+ show_default=True,
103
+ help="Show the execution history for the Pipeline.",
104
+ )
105
+ def ps(id: str, history: bool = False):
98
106
  """List a pipeline configuration in detail."""
99
107
  http = HTTPContext()
100
108
  query: str = json.dumps({"id": id})
@@ -131,7 +139,7 @@ def ps(id: str):
131
139
  max_width=column_max_width,
132
140
  justify="left",
133
141
  )
134
- text.append(render_pipeline(payload))
142
+ text.append(render_pipeline(payload, history=history))
135
143
  table.add_row(text)
136
144
  console_content = table
137
145
  finally:
@@ -148,6 +148,7 @@ class Buckets(Client):
148
148
  tags: Optional[List[str]] = None,
149
149
  parent: Optional[str] = None,
150
150
  force: bool = False,
151
+ limit: Optional[int] = 100
151
152
  ) -> bool:
152
153
  """Delete works belonging to a pipeline from the buckets backend.
153
154
 
@@ -161,6 +162,7 @@ class Buckets(Client):
161
162
  event (Optional[List[int]]): The event to delete works with.
162
163
  force (bool, optional): Whether to force the deletion without requiring
163
164
  user confirmation. Defaults to False.
165
+ limit (int, optional): Limit of Work objects to remove. Defaults to False.
164
166
 
165
167
  Returns:
166
168
  bool: Whether any works were deleted.
@@ -171,7 +173,7 @@ class Buckets(Client):
171
173
  query.update({"tags": {"$in": tags}} if tags else {})
172
174
  query.update({"config.parent": parent} if parent else {})
173
175
  projection = {"id": True}
174
- result = self.view(query, projection)
176
+ result = self.view(query, projection, limit=limit)
175
177
  ids: List[str] = []
176
178
  if result:
177
179
  ids = [work["id"] for work in result]
@@ -163,3 +163,30 @@ class Configs(Client):
163
163
  response.raise_for_status()
164
164
  server_info = response.json()
165
165
  return {"client": client_info, "server": server_info}
166
+
167
+
168
+ @retry(
169
+ reraise=True, wait=wait_random(min=0.3, max=1.8), stop=(stop_after_delay(15))
170
+ )
171
+ def _retry(self, name: str, id: str) -> Dict[str, Any]:
172
+ """Makes POST request to /retry endpoint.
173
+
174
+ Parameters
175
+ ----------
176
+ name : str
177
+ Config name.
178
+ id : str
179
+ Config ID.
180
+
181
+ Returns
182
+ -------
183
+ Dict[str, Any]
184
+ Response payload.
185
+ """
186
+ with self.session as session:
187
+ body = {"id": id, "name": name}
188
+ response: Response = session.post(
189
+ url=f"{self.baseurl}/configs/retry", json=body
190
+ )
191
+ response.raise_for_status()
192
+ return response.json()
@@ -11,7 +11,13 @@ from workflow.http.context import HTTPContext
11
11
  from workflow.utils.variables import status_colors, status_symbols
12
12
 
13
13
 
14
- def render_pipeline(payload: Dict[str, Any]) -> Text:
14
+ def render_timestamp(timestamp: float):
15
+ timestamp = dt.datetime.fromtimestamp(timestamp)
16
+ timestamp = dt.datetime.strftime(timestamp, "%m-%d-%Y, %H:%M:%S")
17
+ return timestamp
18
+
19
+
20
+ def render_pipeline(payload: Dict[str, Any], history: bool = False) -> Text:
15
21
  """Renders a pipeline to rich.Text().
16
22
 
17
23
  Parameters
@@ -25,19 +31,31 @@ def render_pipeline(payload: Dict[str, Any]) -> Text:
25
31
  Rendered text.
26
32
  """
27
33
  steps_field = "steps"
34
+ history_field = "history"
28
35
  time_fields = ["creation", "start", "stop"]
29
36
  text = Text()
30
37
  for k, v in payload.items():
31
- key_value_text = Text()
38
+ if k == "history" and not history:
39
+ continue
32
40
  if not v:
33
41
  continue
42
+ key_value_text = Text()
34
43
  if k in time_fields and v:
35
- v = dt.datetime.fromtimestamp(v)
44
+ v = render_timestamp(v)
36
45
  if k == steps_field:
37
46
  key_value_text = Text(f"{k}: \n", style="bright_blue")
38
47
  for step in v:
39
48
  key_value_text.append(f" {step['name']}:")
40
49
  key_value_text.append(f"{status_symbols[step['status']]}\n")
50
+ elif k == history_field:
51
+ key_value_text = Text(f"{k}: \n", style="bright_blue")
52
+ for timestamp in v.keys():
53
+ rendered = render_timestamp(int(timestamp))
54
+ key_value_text.append(f" {rendered}:\n", style="bright_green")
55
+ for execution in v[timestamp].keys():
56
+ key_value_text.append(f"{' ' * 4}{execution}:\n")
57
+ for work in v[timestamp][execution]:
58
+ key_value_text.append(f"{' ' * 6}{work}\n", style="white")
41
59
  else:
42
60
  key_value_text = Text(f"{k}: ", style="bright_blue")
43
61
  key_value_text.append(
@@ -64,6 +82,7 @@ def render_config(http: HTTPContext, payload: Dict[str, Any]) -> Text:
64
82
  """
65
83
  text = Text()
66
84
  hidden_keys = ["yaml", "services", "name"]
85
+ time_fields = ["creation", "start", "stop"]
67
86
  query = json_dumps({"id": {"$in": payload["pipelines"]}})
68
87
  projection = json_dumps({"id": 1, "status": 1})
69
88
  pipelines_statuses = http.pipelines.get_pipelines(
@@ -76,6 +95,8 @@ def render_config(http: HTTPContext, payload: Dict[str, Any]) -> Text:
76
95
  if k in hidden_keys:
77
96
  continue
78
97
  key_value_text = Text()
98
+ if k in time_fields and v:
99
+ v = render_timestamp(v)
79
100
  if k == "pipelines":
80
101
  key_value_text.append(f"{k}: \n", style="bright_blue")
81
102
  for status in pipelines_statuses:
File without changes