Validation
The preflight and the dependency walk behind it. See Study Schema for the finding codes.
mdo_framework.validation
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
LinearConstraint
dataclass
Linear inequality over design variables, as sum(c * x) <= bound.
Attributes:
| Name | Type | Description |
|---|---|---|
expression |
str
|
Original constraint text. |
coefficients |
dict[str, float]
|
Coefficient of each referenced variable, none being zero. |
bound |
float
|
Right-hand side of the normalized inequality. |
Source code in src/mdo_framework/validation.py
44 45 46 47 48 49 50 51 52 53 54 55 56 | |
ParameterConstraintError
Bases: ValueError
Raised when a parameter constraint expression is not usable.
Source code in src/mdo_framework/validation.py
59 60 | |
check_tool_signature(tool, func)
Check that a tool function accepts exactly the graph inputs by keyword.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
ToolSpec
|
Tool declaration whose inputs are passed as keyword arguments. |
required |
func
|
Callable[..., Any]
|
Python callable registered for the tool. |
required |
Returns:
| Type | Description |
|---|---|
list[Finding]
|
The error findings and the warning findings. A tool whose inputs are |
list[Finding]
|
not all passed as distinct arguments gets |
tuple[list[Finding], list[Finding]]
|
and no signature check, as there is no single call to check. |
Source code in src/mdo_framework/validation.py
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 204 205 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 | |
dependency_findings(walk)
Turn the unresolved parts of a dependency walk into error findings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
walk
|
DependencyWalk
|
Result of |
required |
Returns:
| Type | Description |
|---|---|
list[Finding]
|
|
list[Finding]
|
in that order. |
Source code in src/mdo_framework/validation.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
parse_parameter_constraints(expressions, design_variables)
Parse linear constraints written in the Ax grammar.
Each expression is <lhs> <= <rhs> or <lhs> >= <rhs> where a side is
a sum of numbers, names and <number>*<name> terms. It is normalized to
sum(coefficient * variable) <= bound.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expressions
|
Sequence[str]
|
Constraint expressions. |
required |
design_variables
|
Sequence[DesignVariable]
|
Design variables the expressions may reference. |
required |
Returns:
| Type | Description |
|---|---|
list[LinearConstraint]
|
One normalized constraint per expression, in order. |
Raises:
| Type | Description |
|---|---|
ParameterConstraintError
|
If an expression cannot be parsed, references an unknown variable or a choice variable, or has no variable left. |
Source code in src/mdo_framework/validation.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
thread_safety_findings(schema, couplings)
Flag the coupled tools that do not declare thread_safe.
A tool belongs to a coupled group when it produces a coupling variable; a tool that only reads one runs outside the group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
StudySchema
|
Study whose tools are checked. |
required |
couplings
|
Collection[str]
|
Names of the coupling variables, as returned by
|
required |
Returns:
| Type | Description |
|---|---|
list[Finding]
|
One |
Source code in src/mdo_framework/validation.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | |
validate_registry(schema, registry)
Check every schema tool against the tool registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
StudySchema
|
Study whose tools must be registered. |
required |
registry
|
Mapping[str, Callable[..., Any]]
|
Tool name to Python function. |
required |
Returns:
| Type | Description |
|---|---|
ValidationReport
|
Report whose errors are |
ValidationReport
|
then, for each tool in order, its |
ValidationReport
|
|
ValidationReport
|
collision, the signature errors. The warnings are the signature |
ValidationReport
|
warnings. |
Source code in src/mdo_framework/validation.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
validate_study(schema, *, objectives, constraints=(), parameter_constraints=(), registry=None)
Check that a study can run, without calling any tool.
Every applicable finding is reported; nothing stops at the first error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
StudySchema
|
Study to validate. |
required |
objectives
|
Sequence[ObjectiveSpec]
|
Objectives, whose names are the first targets. |
required |
constraints
|
Sequence[ConstraintSpec]
|
Constraints, whose names follow the objectives as targets. |
()
|
parameter_constraints
|
Sequence[str]
|
Linear constraints on the design variables, in the Ax grammar. |
()
|
registry
|
Mapping[str, Callable[..., Any]] | None
|
Optional mapping of tool name to Python function. When given, every schema tool must be registered with a compatible signature. |
None
|
Returns:
| Type | Description |
|---|---|
ValidationReport
|
Report listing the errors and warnings. |
Source code in src/mdo_framework/validation.py
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | |
mdo_framework.core.dependencies
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
DependencyWalk
dataclass
Everything a set of target outputs depends on in a study.
Variables and tools follow the order of the schema (FalkorDB insertion order), never the traversal or alphabetical order.
Attributes:
| Name | Type | Description |
|---|---|---|
design_variables |
tuple[DesignVariable, ...]
|
Required range and choice variables. |
fixed_parameters |
tuple[FixedParam, ...]
|
Required fixed parameters. |
tools |
tuple[str, ...]
|
Names of the required tools. |
unknown_targets |
tuple[str, ...]
|
Targets that are not declared variables, in target order. |
unproduced_targets |
tuple[str, ...]
|
Declared targets that no tool produces, in target order. |
unproduced_states |
tuple[str, ...]
|
Required state inputs that no tool produces. |
couplings |
tuple[str, ...]
|
State variables exchanged inside a tool cycle, over the whole schema and not only the required tools. |
Source code in src/mdo_framework/core/dependencies.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
walk_dependencies(schema, targets)
Resolve the tools and inputs required to compute the target outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
StudySchema
|
Study whose variables and tools are traversed. |
required |
targets
|
Sequence[str]
|
Names of the variables to compute. |
required |
Returns:
| Type | Description |
|---|---|
DependencyWalk
|
The required design variables, fixed parameters and tools, the targets |
DependencyWalk
|
and inputs that cannot be resolved, and the coupling variables. |
Source code in src/mdo_framework/core/dependencies.py
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 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 | |