workflow.core 1.12.2__tar.gz → 1.12.4__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 (60) hide show
  1. {workflow_core-1.12.2 → workflow_core-1.12.4}/PKG-INFO +3 -2
  2. {workflow_core-1.12.2 → workflow_core-1.12.4}/pyproject.toml +2 -2
  3. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/cli/run.py +14 -7
  4. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/lifecycle/configure.py +14 -3
  5. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/lifecycle/execute.py +55 -13
  6. {workflow_core-1.12.2 → workflow_core-1.12.4}/README.md +0 -0
  7. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/__init__.py +0 -0
  8. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/cli/__init__.py +0 -0
  9. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/cli/buckets.py +0 -0
  10. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/cli/configs.py +0 -0
  11. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/cli/main.py +0 -0
  12. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/cli/pipelines.py +0 -0
  13. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/cli/results.py +0 -0
  14. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/cli/schedules.py +0 -0
  15. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/cli/workspace.py +0 -0
  16. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/daemons/__init__.py +0 -0
  17. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/daemons/audit.py +0 -0
  18. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/daemons/transfer.py +0 -0
  19. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/definitions/__init__.py +0 -0
  20. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/definitions/config.py +0 -0
  21. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/definitions/jsonschema.md +0 -0
  22. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/definitions/notify.py +0 -0
  23. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/definitions/work.py +0 -0
  24. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/definitions/workspace.py +0 -0
  25. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/examples/autocomplete.py +0 -0
  26. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/examples/function.py +0 -0
  27. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/examples/sample.svg +0 -0
  28. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/examples/sample.workflow.yml +0 -0
  29. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/exceptions.py +0 -0
  30. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/helpers/__init__.py +0 -0
  31. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/helpers/date.py +0 -0
  32. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/http/__init__.py +0 -0
  33. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/http/buckets.py +0 -0
  34. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/http/client.py +0 -0
  35. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/http/configs.py +0 -0
  36. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/http/context.py +0 -0
  37. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/http/pipelines.py +0 -0
  38. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/http/results.py +0 -0
  39. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/http/schedules.py +0 -0
  40. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/lifecycle/__init__.py +0 -0
  41. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/lifecycle/archive/__init__.py +0 -0
  42. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/lifecycle/archive/http.py +0 -0
  43. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/lifecycle/archive/posix.py +0 -0
  44. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/lifecycle/archive/s3.py +0 -0
  45. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/lifecycle/attempt.py +0 -0
  46. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/__init__.py +0 -0
  47. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/decorators.py +0 -0
  48. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/format.py +0 -0
  49. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/logger.py +0 -0
  50. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/prompt.py +0 -0
  51. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/read.py +0 -0
  52. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/renderers.py +0 -0
  53. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/tmate.sh +0 -0
  54. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/validate.py +0 -0
  55. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/variables.py +0 -0
  56. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/utils/write.py +0 -0
  57. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/workspaces/__init__.py +0 -0
  58. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/workspaces/chimefrb.yml +0 -0
  59. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/workspaces/development.yml +0 -0
  60. {workflow_core-1.12.2 → workflow_core-1.12.4}/workflow/workspaces/site-dev.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workflow.core
3
- Version: 1.12.2
3
+ Version: 1.12.4
4
4
  Summary: Workflow Core
5
5
  License: MIT
6
6
  Author: Shiny Brar
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
17
18
  Requires-Dist: click (>=8.1,<9.0)
18
19
  Requires-Dist: click-params (>=0.5,<0.6)
19
20
  Requires-Dist: docker (>=6.1)
@@ -24,7 +25,7 @@ Requires-Dist: pyyaml (>=6.0,<7.0)
24
25
  Requires-Dist: requests (>=2.31,<3.0)
25
26
  Requires-Dist: rich (>=13.4,<14.0)
26
27
  Requires-Dist: tenacity (>=8.2,<9.0)
27
- Requires-Dist: tjzegmott-python-logging-loki (>=0.0.1,<0.0.2)
28
+ Requires-Dist: tjzegmott-python-logging-loki (>=0,<1)
28
29
  Requires-Dist: toml (>=0.10,<0.11)
29
30
  Project-URL: Documentation, https://chimefrb.github.io/workflow-docs/
30
31
  Project-URL: Repository, https://github.com/chimefrb/workflow
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "workflow.core"
3
- version = "1.12.2"
3
+ version = "1.12.4"
4
4
  description = "Workflow Core"
5
5
  authors = ["Shiny Brar <charanjotbrar@gmail.com>"]
6
6
  license = "MIT"
@@ -22,7 +22,7 @@ minio = "^7.2"
22
22
  pydantic-settings = "^2.0"
23
23
  click-params = "^0.5"
24
24
  docker = ">=6.1"
25
- tjzegmott-python-logging-loki = "^0.0.1"
25
+ tjzegmott-python-logging-loki = "^0"
26
26
 
27
27
  [tool.poetry.group.dev.dependencies]
28
28
  mypy = "*"
@@ -2,6 +2,7 @@
2
2
 
3
3
  import platform
4
4
  import signal
5
+ from contextlib import nullcontext
5
6
  from pathlib import Path
6
7
  from sys import stderr, stdout
7
8
  from threading import Event
@@ -228,13 +229,19 @@ def run(
228
229
  "[bold]Starting Workflow Lifecycle[/bold]",
229
230
  extra=dict(markup=True, color="green"),
230
231
  )
231
- console = Console(force_terminal=True, tab_size=4)
232
- with console.status(
233
- status="",
234
- spinner="aesthetic" if tty else "dots",
235
- spinner_style="bold green",
236
- refresh_per_second=10 if tty else 1,
237
- ):
232
+ # Without a terminal (e.g. a container's logs) every spinner frame would be
233
+ # written to the logs, so it's only shown in a terminal
234
+ spinner = (
235
+ Console(force_terminal=True, tab_size=4).status(
236
+ status="",
237
+ spinner="aesthetic",
238
+ spinner_style="bold green",
239
+ refresh_per_second=10,
240
+ )
241
+ if tty
242
+ else nullcontext()
243
+ )
244
+ with spinner:
238
245
  lifecycle(
239
246
  buckets=buckets,
240
247
  function=function,
@@ -82,7 +82,11 @@ def loki(logger: Logger, config: Dict[str, Any]) -> bool:
82
82
  ).status_code
83
83
  if status_code == 200:
84
84
  loki_handler = LokiHandler(
85
- url=url, tags=loki_tags, headers=loki_headers, version="1"
85
+ url=url,
86
+ tags=loki_tags,
87
+ headers=loki_headers,
88
+ version="1",
89
+ suppress_errors=True,
86
90
  )
87
91
  loki_handler.setFormatter(
88
92
  Formatter("%(levelname)s %(tag)s %(name)s %(message)s")
@@ -115,7 +119,9 @@ def arguments(func: Callable[..., Any], work: Work) -> List[str]:
115
119
  paraneter_name_in_function, None
116
120
  )
117
121
 
118
- if parameter_value_in_work:
122
+ # Only missing parameters are left to their defaults: False, 0 and ""
123
+ # are values too
124
+ if parameter_value_in_work is not None:
119
125
  if isinstance(parameter, click.Argument):
120
126
  # If argument, then the parameter is purely positional without a key
121
127
  if isinstance(parameter_value_in_work, list):
@@ -127,7 +133,12 @@ def arguments(func: Callable[..., Any], work: Work) -> List[str]:
127
133
  if hasattr(parameter, "is_flag") and parameter.is_flag:
128
134
  # If is_flag=True,
129
135
  # then the parameter is a flag and doesn't have a value
130
- args.append(f"{parameter_name_in_cli}")
136
+ if parameter_value_in_work:
137
+ args.append(f"{parameter_name_in_cli}")
138
+ elif parameter.secondary_opts:
139
+ # An on/off flag (e.g. --trace/--no-trace) set to False
140
+ args.append(f"{parameter.secondary_opts[-1]}")
141
+ # A plain flag set to False is left off
131
142
  else:
132
143
  space_or_equals = ""
133
144
 
@@ -13,6 +13,10 @@ from workflow.utils.logger import get_logger
13
13
 
14
14
  logger = get_logger("workflow.lifecycle.execute")
15
15
 
16
+ # The lines of a command's stdout and stderr kept in its results (the last ones),
17
+ # so a verbose command doesn't fill the database
18
+ OUTPUT_LINES = 1024
19
+
16
20
  Outcome = Union[Dict[str, Any], Tuple[Dict[str, Any], List[str], List[str]], Any, None]
17
21
 
18
22
 
@@ -75,6 +79,46 @@ def function(work: Work) -> Work:
75
79
  return work
76
80
 
77
81
 
82
+ def last_lines(stream: Optional[bytes]) -> List[str]:
83
+ """The last OUTPUT_LINES lines of a command's output.
84
+
85
+ Args:
86
+ stream (Optional[bytes]): Its stdout or stderr
87
+
88
+ Returns:
89
+ List[str]: Its last lines
90
+ """
91
+ return (
92
+ (stream or b"").decode("utf-8", errors="replace").splitlines()[-OUTPUT_LINES:]
93
+ )
94
+
95
+
96
+ def output(
97
+ work: Work,
98
+ args: Any,
99
+ stdout: Optional[bytes],
100
+ stderr: Optional[bytes],
101
+ returncode: Optional[int],
102
+ ) -> None:
103
+ """Keep a command's output in the work's results, unless it has results.
104
+
105
+ Args:
106
+ work (Work): Work object
107
+ args (Any): The command run
108
+ stdout (Optional[bytes]): Its standard output
109
+ stderr (Optional[bytes]): Its standard error
110
+ returncode (Optional[int]): Its exit code, None if it was stopped
111
+ """
112
+ if work.results or work.products or work.plots:
113
+ return
114
+ work.results = {
115
+ "args": args,
116
+ "stdout": last_lines(stdout),
117
+ "stderr": last_lines(stderr),
118
+ "returncode": returncode,
119
+ }
120
+
121
+
78
122
  def command(work: Work) -> Work:
79
123
  """Execute a command.
80
124
 
@@ -103,22 +147,20 @@ def command(work: Work) -> Work:
103
147
  timeout=work.timeout,
104
148
  shell=is_shell, # nosec
105
149
  )
106
- # Check return code
107
- process.check_returncode()
108
- # Convert stdout and stderr to strings
109
- stdout = process.stdout.decode("utf-8").splitlines()
110
- stderr = process.stderr.decode("utf-8").splitlines()
111
- # Convert last line of stdout to a Tuple
112
- if not (work.results or work.products or work.plots):
113
- work.results = {
114
- "args": process.args,
115
- "stdout": stdout,
116
- "stderr": stderr,
117
- "returncode": process.returncode,
118
- }
150
+ # Keep the output before checking the return code: a failed command's
151
+ # output is the most useful
152
+ output(work, process.args, process.stdout, process.stderr, process.returncode)
119
153
  # * Check if results are less than 4MB
120
154
  validate.size(work)
155
+ # Check return code
156
+ process.check_returncode()
121
157
  work.status = "success"
158
+ except subprocess.TimeoutExpired as error:
159
+ # Keep what it printed before it was stopped
160
+ output(work, error.cmd, error.stdout, error.stderr, None)
161
+ validate.size(work)
162
+ work.status = "failure"
163
+ logger.exception(error)
122
164
  except Exception as error:
123
165
  work.status = "failure"
124
166
  logger.exception(error)
File without changes