cmem-plugin-validation 1.3.0__tar.gz → 1.3.2__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.
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2021 CMEM
189
+ Copyright eccenca GmbH
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cmem-plugin-validation
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Validate graph and data structures.
5
5
  License: Apache-2.0
6
6
  License-File: LICENSE
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
17
  Requires-Dist: cmem-client (>=1.0.0,<2.0.0)
18
- Requires-Dist: cmem-plugin-base (>=4.19.0,<5.0.0)
18
+ Requires-Dist: cmem-plugin-base (>=4.20.0,<5.0.0)
19
19
  Requires-Dist: httpx (>=0.27.0,<0.28.0)
20
20
  Requires-Dist: jsonschema (>=4.25.1,<5.0.0)
21
21
  Project-URL: Homepage, https://github.com/eccenca/cmem-plugin-validation
@@ -27,7 +27,7 @@ Validate graph and data structures.
27
27
 
28
28
  [![eccenca Corporate Memory][cmem-shield]][cmem-link]
29
29
 
30
- This is a plugin for [eccenca](https://eccenca.com) [Corporate Memory](https://documentation.eccenca.com). You can install it with the [cmemc](https://eccenca.com/go/cmemc) command line client like this:
30
+ This is a plugin for [eccenca Corporate Memory](https://documentation.eccenca.com). You can install it with the [cmemc](https://eccenca.com/go/cmemc) command line client like this:
31
31
 
32
32
  ```
33
33
  cmemc admin workspace python install cmem-plugin-validation
@@ -36,7 +36,7 @@ cmemc admin workspace python install cmem-plugin-validation
36
36
  [![poetry][poetry-shield]][poetry-link] [![ruff][ruff-shield]][ruff-link] [![mypy][mypy-shield]][mypy-link] [![copier][copier-shield]][copier]
37
37
 
38
38
  [cmem-link]: https://documentation.eccenca.com
39
- [cmem-shield]: https://img.shields.io/endpoint?url=https://dev.documentation.eccenca.com/badge.json
39
+ [cmem-shield]: https://img.shields.io/endpoint?url=https://documentation.eccenca.com/latest/badge.json
40
40
  [poetry-link]: https://python-poetry.org/
41
41
  [poetry-shield]: https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json
42
42
  [ruff-link]: https://docs.astral.sh/ruff/
@@ -4,7 +4,7 @@ Validate graph and data structures.
4
4
 
5
5
  [![eccenca Corporate Memory][cmem-shield]][cmem-link]
6
6
 
7
- This is a plugin for [eccenca](https://eccenca.com) [Corporate Memory](https://documentation.eccenca.com). You can install it with the [cmemc](https://eccenca.com/go/cmemc) command line client like this:
7
+ This is a plugin for [eccenca Corporate Memory](https://documentation.eccenca.com). You can install it with the [cmemc](https://eccenca.com/go/cmemc) command line client like this:
8
8
 
9
9
  ```
10
10
  cmemc admin workspace python install cmem-plugin-validation
@@ -13,7 +13,7 @@ cmemc admin workspace python install cmem-plugin-validation
13
13
  [![poetry][poetry-shield]][poetry-link] [![ruff][ruff-shield]][ruff-link] [![mypy][mypy-shield]][mypy-link] [![copier][copier-shield]][copier]
14
14
 
15
15
  [cmem-link]: https://documentation.eccenca.com
16
- [cmem-shield]: https://img.shields.io/endpoint?url=https://dev.documentation.eccenca.com/badge.json
16
+ [cmem-shield]: https://img.shields.io/endpoint?url=https://documentation.eccenca.com/latest/badge.json
17
17
  [poetry-link]: https://python-poetry.org/
18
18
  [poetry-shield]: https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json
19
19
  [ruff-link]: https://docs.astral.sh/ruff/
@@ -39,32 +39,26 @@ The used JSON Schema needs to be provided as a JSON Dataset in the project.
39
39
 
40
40
  ### Input Modes
41
41
 
42
- The plugin supports two input modes for validation:
43
-
44
- 1. **Validate Entities**: Validates entities received from the input port in the workflow.
45
- 2. **Validate JSON Dataset**: Validates a JSON dataset stored in the project.
46
- - If the JSON dataset is a JSON array, the schema will validate each object inside the array.
47
- - If the JSON dataset is a JSON object, it will be validated against the schema directly.
48
-
49
- Validated data objects can be sent to an output port for further processing in the workflow
50
- or saved in a JSON dataset in the project.
42
+ Entities arrive on the input port by default. Switching the input mode to a JSON dataset
43
+ removes the input port, and the resources to validate are instead read from a JSON dataset in
44
+ the project. A JSON array in that dataset has each of its objects validated individually; a
45
+ JSON object is validated directly.
51
46
 
52
47
  ### Output Modes
53
48
 
54
- 1. **Valid JSON objects sent to Output Port**: Valid JSON objects can be sent as entities
55
- to the output port.
56
- 2. **Saved in JSON Dataset**: Valid JSON objects can be stored in a specified JSON dataset
57
- in the project.
49
+ Valid JSON objects are sent to an output port by default, ready for further processing in the
50
+ workflow. Switching the output mode to a JSON dataset removes the output port, and the valid
51
+ JSON objects are instead saved to a JSON dataset in the project, replacing its existing content.
58
52
 
59
53
  ### Error Handling
60
54
 
61
- The task can either:
55
+ Every entity or object is validated regardless of the outcome. The task can then either:
62
56
 
63
- - Fail instantly if there is a data violation, halting the workflow.
64
- - Provide warnings in the workflow report, allowing follow-up tasks to run based on the
57
+ - Fail once validation completes if any entity has violations, halting the workflow.
58
+ - Report violations only as warnings, allowing follow-up tasks to run based on the
65
59
  validated data.
66
60
 
67
- The error handling behavior is configurable through the `Fail on violations` parameter.
61
+ The error handling behavior is configurable through the **Fail on violations** parameter.
68
62
  """
69
63
 
70
64
 
@@ -88,9 +82,9 @@ TARGET.dataset = "dataset"
88
82
  TARGET.options = OrderedDict(
89
83
  {
90
84
  TARGET.dataset: f"{TARGET.dataset}: "
91
- "Valid JSON objects will be is saved in a JSON dataset (see advanced options).",
85
+ "Valid JSON objects are saved in a JSON dataset (see advanced options).",
92
86
  TARGET.entities: f"{TARGET.entities}: "
93
- "Valid JSON objects will be send as entities to the output port.",
87
+ "Valid JSON objects are sent as entities to the output port.",
94
88
  }
95
89
  )
96
90
 
@@ -105,21 +99,24 @@ TARGET.options = OrderedDict(
105
99
  PluginParameter(
106
100
  name="source_mode",
107
101
  label="Source / Input Mode",
108
- description="",
102
+ description="Selects where entities to validate come from: the input port or"
103
+ " a JSON dataset.",
109
104
  param_type=ChoiceParameterType(SOURCE.options),
110
105
  default_value=SOURCE.entities,
111
106
  ),
112
107
  PluginParameter(
113
108
  name="target_mode",
114
109
  label="Target / Output Mode",
115
- description="",
110
+ description="Selects where valid JSON objects are written to: the output port"
111
+ " or a JSON dataset.",
116
112
  param_type=ChoiceParameterType(TARGET.options),
117
113
  default_value=TARGET.entities,
118
114
  ),
119
115
  PluginParameter(
120
116
  name="source_dataset",
121
117
  label="Source JSON Dataset",
122
- description="This dataset holds the resources you want to validate.",
118
+ description="This dataset holds the resources you want to validate. Required when"
119
+ " Source / Input Mode is set to dataset; leave it empty when using entities.",
123
120
  param_type=DatasetParameterType(dataset_type="json"),
124
121
  advanced=True,
125
122
  default_value="",
@@ -127,8 +124,9 @@ TARGET.options = OrderedDict(
127
124
  PluginParameter(
128
125
  name="target_dataset",
129
126
  label="Target JSON Dataset",
130
- description="This dataset will be used to store the valid JSON objects"
131
- " after validation.",
127
+ description="This dataset stores the valid JSON objects after validation,"
128
+ " replacing any existing content. Required when Target / Output Mode is set to"
129
+ " dataset; leave it empty when using entities.",
132
130
  param_type=DatasetParameterType(dataset_type="json"),
133
131
  default_value="",
134
132
  advanced=True,
@@ -142,7 +140,9 @@ TARGET.options = OrderedDict(
142
140
  PluginParameter(
143
141
  name="fail_on_violations",
144
142
  label="Fail on violations",
145
- description="If enabled, the task will fail on the first data violation.",
143
+ description="If enabled, the workflow fails once validation completes if any"
144
+ " entity has violations. All entities are validated either way; disabling this"
145
+ " instead reports the violations as warnings.",
146
146
  default_value=DEFAULT_FAIL_ON_VIOLATION,
147
147
  ),
148
148
  ],
@@ -286,7 +286,9 @@ class ValidateEntity(WorkflowPlugin):
286
286
  Client.from_context(context=context).datasets.post_file_resource(
287
287
  project_id=context.task.project_id(),
288
288
  dataset_id=self.target_dataset,
289
- file_resource=io.BytesIO(json.dumps(valid_json_objects).encode("utf-8")),
289
+ file_resource=io.BytesIO(
290
+ json.dumps(valid_json_objects, ensure_ascii=False).encode("utf-8")
291
+ ),
290
292
  )
291
293
  return None
292
294
 
@@ -27,10 +27,32 @@ from httpx import HTTPStatusError
27
27
  from cmem_plugin_validation.validate_graph.state import State
28
28
 
29
29
  DOCUMENTATION = """
30
- Start a graph validation process which verifies, that resources in a specific graph are valid
31
- according to the node shapes in a shape catalog graph.
30
+ Starts a graph validation process which verifies that resources in a specific graph are valid
31
+ according to the node shapes in a shape catalog graph. The task waits for the validation to
32
+ finish before completing.
33
+
34
+ The task has no input port. Violations found during validation are always summarized in the
35
+ workflow report, and can also be materialized into a result graph in the project. Sending each
36
+ violation as an entity to an output port is optional; when that is disabled, the task has no
37
+ output port either.
38
+
39
+ ### Error Handling
40
+
41
+ Every resource is validated regardless of the outcome. The task can then either:
42
+
43
+ - Fail once validation completes if any resource has violations, halting the workflow.
44
+ - Report violations only as warnings, allowing follow-up tasks to run based on the results.
45
+
46
+ The error handling behavior is configurable through the **Fail workflow on violations**
47
+ parameter.
32
48
  """
33
49
 
50
+ CONTEXT_GRAPH_CLASSES = [
51
+ "https://vocab.eccenca.com/di/Dataset",
52
+ "http://rdfs.org/ns/void#Dataset",
53
+ "https://vocab.eccenca.com/shui/QueryCatalog",
54
+ "http://www.w3.org/2002/07/owl#Ontology",
55
+ ]
34
56
  DEFAULT_SHAPE_GRAPH = "https://vocab.eccenca.com/shacl/"
35
57
  DEFAULT_RESULT_GRAPH = ""
36
58
  DEFAULT_CLEAR_RESULT_GRAPH = False
@@ -54,6 +76,7 @@ WHERE { ?resource a ?class . FILTER isIRI(?resource) }
54
76
  label="Context Graph",
55
77
  description="This graph holds the resources you want to validate.",
56
78
  param_type=GraphParameterType(
79
+ classes=CONTEXT_GRAPH_CLASSES,
57
80
  show_di_graphs=False,
58
81
  show_graphs_without_class=True,
59
82
  show_system_graphs=True,
@@ -85,23 +108,30 @@ WHERE { ?resource a ?class . FILTER isIRI(?resource) }
85
108
  PluginParameter(
86
109
  name="clear_result_graph",
87
110
  label="Clear result graph before validation",
111
+ description="If enabled, the existing content of the result graph is deleted"
112
+ " before validation starts. Has no effect when Result graph is left empty.",
88
113
  default_value=DEFAULT_CLEAR_RESULT_GRAPH,
89
114
  ),
90
115
  PluginParameter(
91
116
  name="fail_on_violations",
92
117
  label="Fail workflow on violations",
118
+ description="If enabled, the workflow fails once validation completes if any"
119
+ " resource has violations. All resources are validated either way; disabling this"
120
+ " instead reports the violations as warnings.",
93
121
  default_value=DEFAULT_FAIL_ON_VIOLATION,
94
122
  ),
95
123
  PluginParameter(
96
124
  name="output_results",
97
125
  label="Output violations as entities",
126
+ description="If enabled, each violation is sent as an entity to an output port"
127
+ " for further processing in the workflow. Disabling this removes the output port.",
98
128
  default_value=DEFAULT_OUTPUT_RESULTS,
99
129
  ),
100
130
  PluginParameter(
101
131
  name="sparql_query",
102
132
  label="Resource Selection Query",
103
133
  description="The query to select the resources to validate. "
104
- "Use {{context_graph}} as a placeholder for the select context graph for validation.",
134
+ "Use `{{context_graph}}` as a placeholder for the selected Context Graph.",
105
135
  default_value=DEFAULT_SPARQL_QUERY,
106
136
  advanced=True,
107
137
  ),
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cmem-plugin-validation"
3
- version = "1.3.0"
3
+ version = "1.3.2"
4
4
  license = "Apache-2.0"
5
5
  description = "Validate graph and data structures."
6
6
  authors = ["eccenca GmbH <cmempy-developer@eccenca.com>"]
@@ -25,7 +25,7 @@ cmem-client = "^1.0.0"
25
25
  httpx = "^0.27.0"
26
26
 
27
27
  [tool.poetry.dependencies.cmem-plugin-base]
28
- version = "^4.19.0"
28
+ version = "^4.20.0"
29
29
  allow-prereleases = false
30
30
 
31
31
  [tool.poetry.group.dev.dependencies.cmem-cmemc]
@@ -58,8 +58,12 @@ bump = true
58
58
  warn_return_any = true
59
59
  ignore_missing_imports = true
60
60
 
61
+ # Deliberately empty. pytest walks upward until a file *loads* a configuration,
62
+ # and only the presence of this table makes pyproject.toml one - without it the
63
+ # walk carries on into the parent directories, where any pytest.ini, tox.ini or
64
+ # setup.cfg, even an empty one, would set this project's rootdir and could push
65
+ # its own addopts into this test suite. Do not tidy it away.
61
66
  [tool.pytest.ini_options]
62
- addopts = ""
63
67
 
64
68
  [tool.coverage.report]
65
69
  exclude_also = [
@@ -85,6 +89,7 @@ select = ["ALL"]
85
89
  ignore = [
86
90
  "ANN204", # Missing return type annotation for special method `__init__`
87
91
  "COM812", # missing-trailing-comma
92
+ "CPY001", # Missing copyright notice
88
93
  "D107", # Missing docstring in __init__
89
94
  "D203", # [*] 1 blank line required before class docstring
90
95
  "D211", # No blank lines allowed before class docstring
@@ -97,7 +102,11 @@ ignore = [
97
102
  "G004", # Logging statement uses f-string
98
103
  "ISC001", # single-line-implicit-string-concatenation
99
104
  "PD", # opinionated linting for pandas code
100
- "S101", # use of assert detected
101
105
  "TRY003", # Avoid specifying long messages outside the exception class
102
- "CPY001", # Missing copyright notice
106
+ ]
107
+
108
+ [tool.ruff.lint.per-file-ignores]
109
+ "tests/**/*.py" = [
110
+ "S101", # asserts allowed in tests
111
+ "ARG", # unused function args (pytest fixtures)
103
112
  ]