cmem-plugin-validation 1.3.2__tar.gz → 1.3.3rc2__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.3rc2
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 (
@@ -229,13 +234,26 @@ class ValidateGraph(WorkflowPlugin):
229
234
  continue
230
235
  # when reported as finished, error or cancelled break out
231
236
  break
237
+ if state.status != STATUS_FINISHED:
238
+ failure = state.error or f"Validation process ended in state {state.status}."
239
+ context.report.update(
240
+ ExecutionReport(
241
+ entity_count=state.completed,
242
+ operation="read",
243
+ operation_desc=f"/ {state.total} Resources validated",
244
+ error=failure,
245
+ )
246
+ )
247
+ raise RuntimeError(failure)
232
248
  summary: list[tuple[str, str]] = [
233
249
  (data_key, str(state.data[data_key])) for data_key in state.data
234
250
  ]
235
- validation_message = (
236
- f"Found {state.violations} Violations "
237
- f"in {state.with_violations} / {state.total} Resources."
238
- )
251
+ validation_message = None
252
+ if state.with_violations:
253
+ validation_message = (
254
+ f"Found {state.violations} Violations "
255
+ f"in {state.with_violations} / {state.total} Resources."
256
+ )
239
257
  context.report.update(
240
258
  ExecutionReport(
241
259
  entity_count=state.with_violations,
@@ -243,7 +261,9 @@ class ValidateGraph(WorkflowPlugin):
243
261
  operation_desc=f"/ {state.total} Resources have violations",
244
262
  summary=summary,
245
263
  error=validation_message if self.fail_on_violations else None,
246
- warnings=[validation_message] if not self.fail_on_violations else [],
264
+ warnings=[validation_message]
265
+ if validation_message and not self.fail_on_violations
266
+ else [],
247
267
  )
248
268
  )
249
269
  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.3rc2"
4
4
  license = "Apache-2.0"
5
5
  description = "Validate graph and data structures."
6
6
  authors = ["eccenca GmbH <cmempy-developer@eccenca.com>"]
@@ -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
  ]