GraphManager
mdo_framework.db.graph_manager.GraphManager
Typed access to the study graph stored in FalkorDB.
Variables and tools are created from the models of mdo_framework.schema and
read back as models. Each node carries a seq number, assigned at creation,
that defines the order of every listing: design variable order is meaningful.
The numbers may have gaps. Creating or replacing a node is one atomic query, so
concurrent writers cannot duplicate a name; checks spanning several queries
(role conflicts, duplicate producers) assume a single writer.
Attributes:
| Name | Type | Description |
|---|---|---|
graph |
The FalkorDB graph that is queried. |
Source code in src/mdo_framework/db/graph_manager.py
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 238 239 240 241 242 243 244 245 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 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 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 334 335 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 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | |
__init__(graph=None)
Bind the manager to a graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Any | None
|
Graph exposing |
None
|
Source code in src/mdo_framework/db/graph_manager.py
190 191 192 193 194 195 196 197 | |
add_tool(tool)
Create a tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
ToolNode
|
The tool to store. |
required |
Raises:
| Type | Description |
|---|---|
NodeExistsError
|
If a tool with this name exists. |
Example
gm.add_tool(ToolNode(name="CFD_Solver", fidelity="high"))
Source code in src/mdo_framework/db/graph_manager.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
add_variable(variable)
Create a variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
Variable
|
The variable to store. |
required |
Raises:
| Type | Description |
|---|---|
NodeExistsError
|
If a variable with this name exists. |
Example
gm.add_variable(RangeVar(name="x", lower=-10.0, upper=10.0))
gm.add_variable(StateVar(name="f_xy"))
Source code in src/mdo_framework/db/graph_manager.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
clear_graph()
Delete every node and edge, and restart the seq numbering.
Source code in src/mdo_framework/db/graph_manager.py
199 200 201 | |
connect_input_to_tool(variable_name, tool_name)
Connect a variable to a tool that consumes it (Variable -> Tool).
Connecting twice is harmless.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
The consumed variable. |
required |
tool_name
|
str
|
The consuming tool. |
required |
Raises:
| Type | Description |
|---|---|
NodeNotFoundError
|
If the variable or the tool does not exist. The hint
suggests |
RoleConflictError
|
If the variable is already an output of the tool. |
Example
gm.connect_input_to_tool("x", "Paraboloid")
Source code in src/mdo_framework/db/graph_manager.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
connect_tool_to_output(tool_name, variable_name)
Connect a tool to a variable it produces (Tool -> Variable).
Connecting twice is harmless.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_name
|
str
|
The producing tool. |
required |
variable_name
|
str
|
The produced variable, which must be of kind |
required |
Raises:
| Type | Description |
|---|---|
NodeNotFoundError
|
If the tool or the variable does not exist. The hint
suggests |
DuplicateProducerError
|
If another tool already produces the variable. |
RoleConflictError
|
If the variable is a design or fixed variable, or is already an input of the tool. |
Example
gm.connect_tool_to_output("Paraboloid", "f_xy")
Source code in src/mdo_framework/db/graph_manager.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | |
delete_tool(name)
Delete a tool and its edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Tool name. |
required |
Raises:
| Type | Description |
|---|---|
NodeNotFoundError
|
If there is no such tool. |
Source code in src/mdo_framework/db/graph_manager.py
324 325 326 327 328 329 330 331 332 333 | |
delete_variable(name)
Delete a variable and its edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Variable name. |
required |
Raises:
| Type | Description |
|---|---|
NodeNotFoundError
|
If there is no such variable. |
Source code in src/mdo_framework/db/graph_manager.py
250 251 252 253 254 255 256 257 258 259 | |
get_study_schema()
Read the whole graph as a typed study.
Returns:
| Type | Description |
|---|---|
StudySchema
|
The variables and the tools with their inputs and outputs, in creation |
StudySchema
|
order. |
Raises:
| Type | Description |
|---|---|
StudyValidationError
|
If a variable node is a legacy one without a
|
Source code in src/mdo_framework/db/graph_manager.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
get_tool_inputs(tool_name)
List the variables a tool consumes, in variable creation order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_name
|
str
|
Tool name. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Variable names; empty for an unknown tool. |
Source code in src/mdo_framework/db/graph_manager.py
419 420 421 422 423 424 425 426 427 428 | |
get_tool_outputs(tool_name)
List the variables a tool produces, in variable creation order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_name
|
str
|
Tool name. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Variable names; empty for an unknown tool. |
Source code in src/mdo_framework/db/graph_manager.py
430 431 432 433 434 435 436 437 438 439 | |
get_tools()
List the tools in creation order.
Returns:
| Type | Description |
|---|---|
list[ToolNode]
|
The stored tools, without their connections. |
Source code in src/mdo_framework/db/graph_manager.py
335 336 337 338 339 340 341 | |
get_variables()
List the variables in creation order.
Returns:
| Type | Description |
|---|---|
list[Variable]
|
The stored variables. |
Raises:
| Type | Description |
|---|---|
StudyValidationError
|
With a |
Source code in src/mdo_framework/db/graph_manager.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
put_tool(tool)
Create a tool, or replace every property of an existing one.
The seq number, hence the position, and the edges are kept on replace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
ToolNode
|
The tool to store. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/mdo_framework/db/graph_manager.py
311 312 313 314 315 316 317 318 319 320 321 322 | |
put_variable(variable)
Create a variable, or replace every property of an existing one.
The seq number, hence the position, and the edges are kept on replace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
Variable
|
The variable to store. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
RoleConflictError
|
If the existing variable is produced by a tool and
the new kind is not |
Source code in src/mdo_framework/db/graph_manager.py
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 | |