API reference
CWL assertion hint models and the shared input validation interface.
Hints configure JSON Schema, Rego, or CQL2 validators and serialize to
annotation payloads. Use extract_assertion_hints to read them from a
parsed CWL process.
AssertionHint
Bases: BaseModel
Base model for an assertion hint attached to a CWL process.
| Attributes: |
|
|---|
Source code in src/assertions_mate/__init__.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
annotation
abstractmethod
property
Return the annotation key used to identify this hint.
parent_workflow = None
class-attribute
instance-attribute
validator()
abstractmethod
Create a validator configured from this hint.
Source code in src/assertions_mate/__init__.py
66 67 68 69 | |
BaseValidator
Bases: ABC
Interface for validators that check a mapping of workflow inputs.
Source code in src/assertions_mate/__init__.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
validate_inputs(data)
abstractmethod
Check workflow inputs against the configured assertions.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Implementations may raise an exception when validation cannot be performed.
Source code in src/assertions_mate/__init__.py
35 36 37 38 39 40 41 42 43 44 45 46 47 | |
Cql2FilterHint
Bases: AssertionHint
Configure CQL2 predicates for workflow inputs.
| Attributes: |
|
|---|
Source code in src/assertions_mate/__init__.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
annotation
property
Return the annotation key for CQL2 input filters.
custom_functions = None
class-attribute
instance-attribute
queries
instance-attribute
get_annotation_name()
staticmethod
Return the annotation key for CQL2 input filters.
Source code in src/assertions_mate/__init__.py
170 171 172 173 | |
ser_model()
Serialize the queries as an annotation payload, omitting custom functions.
Source code in src/assertions_mate/__init__.py
183 184 185 186 | |
validator()
Create a CQL2 validator with the configured queries and custom functions.
Source code in src/assertions_mate/__init__.py
188 189 190 191 192 | |
Cql2Query
Bases: BaseModel
Describe a CQL2 assertion and the violation reported when it is false.
| Attributes: |
|
|---|
Source code in src/assertions_mate/__init__.py
147 148 149 150 151 152 153 154 155 156 157 158 | |
cql2
instance-attribute
id
instance-attribute
message
instance-attribute
JSONSchemaHint
Bases: AssertionHint
Configure JSON Schema validation of workflow inputs.
| Attributes: |
|
|---|
Source code in src/assertions_mate/__init__.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
annotation
property
Return the annotation key for JSON Schema input constraints.
json_schema = {}
class-attribute
instance-attribute
get_annotation_name()
staticmethod
Return the annotation key for JSON Schema input constraints.
Source code in src/assertions_mate/__init__.py
83 84 85 86 | |
ser_model()
Serialize the hint as its effective JSON Schema document.
Source code in src/assertions_mate/__init__.py
102 103 104 105 | |
validator()
Create a JSON Schema validator using the effective schema.
Source code in src/assertions_mate/__init__.py
107 108 109 110 111 | |
RegoPolicyHint
Bases: AssertionHint
Configure Rego policy queries for workflow inputs.
| Attributes: |
|
|---|
Source code in src/assertions_mate/__init__.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
annotation
property
Return the annotation key for Rego input policies.
module
instance-attribute
queries
instance-attribute
get_annotation_name()
staticmethod
Return the annotation key for Rego input policies.
Source code in src/assertions_mate/__init__.py
122 123 124 125 | |
ser_model()
Serialize the policy module and queries as an annotation payload.
Source code in src/assertions_mate/__init__.py
135 136 137 138 | |
validator()
Create a Rego validator using this policy module and its queries.
Source code in src/assertions_mate/__init__.py
140 141 142 143 144 | |
extract_assertion_hints(workflow)
Collect recognized assertion hints from a parsed CWL process.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in src/assertions_mate/__init__.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
JSON Schema API
Validate workflow inputs with JSON Schema Draft 2020-12 and remote references.
JSONSchemaRegistry
Retrieve JSON or YAML schema documents through a Requests session.
Source code in src/assertions_mate/jsonschema_validator.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
session = requests.Session()
instance-attribute
timeout = timeout
instance-attribute
__init__(timeout=_REMOTE_SCHEMA_TIMEOUT_SECONDS)
Create a session for schema retrieval.
| Parameters: |
|
|---|
Source code in src/assertions_mate/jsonschema_validator.py
46 47 48 49 50 51 52 53 54 55 56 57 | |
as_referencing_registry()
Create a referencing registry backed by this instance's retrieval callback.
Source code in src/assertions_mate/jsonschema_validator.py
200 201 202 203 | |
load_schema(uri)
Fetch a schema document and parse it as JSON or YAML.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in src/assertions_mate/jsonschema_validator.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
retrieve(uri)
Load a URI as a Draft 2020-12 resource for reference resolution.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Retrieval and parsing errors from load_schema propagate to the caller.
Source code in src/assertions_mate/jsonschema_validator.py
187 188 189 190 191 192 193 194 195 196 197 198 | |
JSONSchemaValidator
Bases: BaseValidator
Validate input mappings against a JSON Schema Draft 2020-12 schema.
Source code in src/assertions_mate/jsonschema_validator.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
validator = Draft202012Validator(schema, registry=JSONSchemaRegistry().as_referencing_registry())
instance-attribute
__init__(schema)
Configure schema validation and retrieval of referenced schemas.
| Parameters: |
|
|---|
Source code in src/assertions_mate/jsonschema_validator.py
209 210 211 212 213 214 215 216 217 218 219 220 221 | |
validate_inputs(data)
Collect schema violations for a workflow input mapping.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Schema evaluation and reference resolution errors propagate to the caller.
Source code in src/assertions_mate/jsonschema_validator.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
Rego API
Evaluate Rego policies that return workflow input violation messages.
RegoValidator
Bases: BaseValidator
Run Rego queries and collect their returned expressions as violations.
Source code in src/assertions_mate/rego_validator.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
queries = queries
instance-attribute
rego = Interpreter()
instance-attribute
__init__(module, queries)
Load a policy module into a Rego interpreter.
| Parameters: |
|
|---|
Policy loading errors propagate from the interpreter.
Source code in src/assertions_mate/rego_validator.py
30 31 32 33 34 35 36 37 38 39 40 41 | |
validate_inputs(data)
Set the Rego input document and collect query result expressions.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Interpreter errors propagate to the caller.
Source code in src/assertions_mate/rego_validator.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
CQL2 Validator API
Evaluate CQL2 Text and JSON assertions against workflow input mappings.
Cql2EvaluationError
Bases: RuntimeError
A rule could not be evaluated, rather than evaluating to false.
Source code in src/assertions_mate/cql2_validator.py
57 58 | |
Cql2Validator
Bases: BaseValidator
Validate workflow inputs with CQL2 predicates and optional Python functions.
Source code in src/assertions_mate/cql2_validator.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
evaluator = NativeEvaluator(function_map=function_map, use_getattr=False)
instance-attribute
queries = queries
instance-attribute
__init__(queries, custom_functions=None)
Initialize the native evaluator and retain the configured queries.
| Parameters: |
|
|---|
Source code in src/assertions_mate/cql2_validator.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
validate_inputs(data)
Evaluate every configured CQL2 rule against the inputs.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in src/assertions_mate/cql2_validator.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
Plugin registration
Validate inputs against assertion hints on every workflow in the context.
| Parameters: |
|
|---|
| Raises: |
|
|---|
The same YAML-loaded input mapping is passed to each workflow. Document parsing errors propagate; returned validation violations are logged.
Source code in src/assertions_mate/plugin.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
Options
Bases: BaseModel
Options accepted by the Assertions Mate plugin.
| Attributes: |
|
|---|
Unknown option fields are rejected.
Source code in src/assertions_mate/plugin.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |