cmem-plugin-validation 1.3.2__tar.gz → 1.3.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cmem-plugin-validation
3
- Version: 1.3.2
3
+ Version: 1.3.3
4
4
  Summary: Validate graph and data structures.
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -14,6 +14,7 @@ Classifier: License :: OSI Approved :: Apache Software License
14
14
  Classifier: Programming Language :: Python :: 3
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: cmem-client (>=1.0.0,<2.0.0)
18
19
  Requires-Dist: cmem-plugin-base (>=4.20.0,<5.0.0)
19
20
  Requires-Dist: httpx (>=0.27.0,<0.28.0)
@@ -14,6 +14,7 @@ class State:
14
14
  total: int
15
15
  with_violations: int
16
16
  violations: int
17
+ error: str | None
17
18
 
18
19
  def __init__(self, client: Client, id_: str):
19
20
  self.client = client
@@ -29,3 +30,4 @@ class State:
29
30
  self.total = aggregation.resource_count
30
31
  self.with_violations = aggregation.resources_with_violations_count
31
32
  self.violations = aggregation.violations_count
33
+ self.error = aggregation.error
@@ -6,7 +6,12 @@ from time import sleep
6
6
 
7
7
  from cmem_client.client import Client
8
8
  from cmem_client.models.query_catalog import Query
9
- from cmem_client.models.validation import STATUS_RUNNING, STATUS_SCHEDULED, ValidationViolation
9
+ from cmem_client.models.validation import (
10
+ STATUS_FINISHED,
11
+ STATUS_RUNNING,
12
+ STATUS_SCHEDULED,
13
+ ValidationViolation,
14
+ )
10
15
  from cmem_plugin_base.dataintegration.context import ExecutionContext, ExecutionReport
11
16
  from cmem_plugin_base.dataintegration.description import Icon, Plugin, PluginParameter
12
17
  from cmem_plugin_base.dataintegration.entity import (
@@ -44,7 +49,8 @@ Every resource is validated regardless of the outcome. The task can then either:
44
49
  - Report violations only as warnings, allowing follow-up tasks to run based on the results.
45
50
 
46
51
  The error handling behavior is configurable through the **Fail workflow on violations**
47
- parameter.
52
+ parameter. If the validation process itself ends with an error or is cancelled on the server,
53
+ the task fails regardless of this parameter.
48
54
  """
49
55
 
50
56
  CONTEXT_GRAPH_CLASSES = [
@@ -229,13 +235,26 @@ class ValidateGraph(WorkflowPlugin):
229
235
  continue
230
236
  # when reported as finished, error or cancelled break out
231
237
  break
238
+ if state.status != STATUS_FINISHED:
239
+ failure = state.error or f"Validation process ended in state {state.status}."
240
+ context.report.update(
241
+ ExecutionReport(
242
+ entity_count=state.completed,
243
+ operation="read",
244
+ operation_desc=f"/ {state.total} Resources validated",
245
+ error=failure,
246
+ )
247
+ )
248
+ raise RuntimeError(failure)
232
249
  summary: list[tuple[str, str]] = [
233
250
  (data_key, str(state.data[data_key])) for data_key in state.data
234
251
  ]
235
- validation_message = (
236
- f"Found {state.violations} Violations "
237
- f"in {state.with_violations} / {state.total} Resources."
238
- )
252
+ validation_message = None
253
+ if state.with_violations:
254
+ validation_message = (
255
+ f"Found {state.violations} Violations "
256
+ f"in {state.with_violations} / {state.total} Resources."
257
+ )
239
258
  context.report.update(
240
259
  ExecutionReport(
241
260
  entity_count=state.with_violations,
@@ -243,7 +262,9 @@ class ValidateGraph(WorkflowPlugin):
243
262
  operation_desc=f"/ {state.total} Resources have violations",
244
263
  summary=summary,
245
264
  error=validation_message if self.fail_on_violations else None,
246
- warnings=[validation_message] if not self.fail_on_violations else [],
265
+ warnings=[validation_message]
266
+ if validation_message and not self.fail_on_violations
267
+ else [],
247
268
  )
248
269
  )
249
270
  if not self.output_results:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cmem-plugin-validation"
3
- version = "1.3.2"
3
+ version = "1.3.3"
4
4
  license = "Apache-2.0"
5
5
  description = "Validate graph and data structures."
6
6
  authors = ["eccenca GmbH <cmempy-developer@eccenca.com>"]
@@ -42,7 +42,7 @@ pytest-dotenv = "^0.5.2"
42
42
  pytest-html = "^4.2.0"
43
43
  pytest-memray = { version = "^1.10.0", markers = "platform_system != 'Windows'" }
44
44
  ruff = "^0.16.2"
45
- trivy-py-ecc = "^0.73.0.1"
45
+ trivy-py-ecc = "^0.76.0.1"
46
46
 
47
47
  [build-system]
48
48
  requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
@@ -103,10 +103,12 @@ ignore = [
103
103
  "ISC001", # single-line-implicit-string-concatenation
104
104
  "PD", # opinionated linting for pandas code
105
105
  "TRY003", # Avoid specifying long messages outside the exception class
106
+ "TRY400", # PluginLogger has no exception(), so error() is the only option
106
107
  ]
107
108
 
108
109
  [tool.ruff.lint.per-file-ignores]
109
110
  "tests/**/*.py" = [
110
111
  "S101", # asserts allowed in tests
111
112
  "ARG", # unused function args (pytest fixtures)
113
+ "PLR2004", # in an assertion the expected value is the literal
112
114
  ]