mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
Build, copy and edit taskmaestro workflows in ResInsight and save them as standard workflow.yaml + input.yaml. - Python helper: catalog, load, save and export-registered subcommands, and run --registered for installed workflows - C++ definition model with pure edit operations, port type checks, config field derivation, static validation and undo/redo - Installed folder listing registered workflows (read-only, runnable, can be duplicated) - Graph editor dock with task palette, drag-to-connect, context menus, automatic layout and debounced live validation - New/Duplicate/Save/Save As/Rescan commands; unsaved edits run from a temporary folder and prompt before being discarded - Update the design document and the user README
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""ResInsight object references in taskmaestro input files.
|
|
|
|
The Workflow UI writes a `{__resinsight_ref__: <type>, ...id...}` map into
|
|
input.yaml for fields that refer to a ResInsight object. `run` resolves these
|
|
maps back to live `rips` objects. The C++ side maps Python types to the
|
|
`<type>` labels in RimWorkflowDescribeTools.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
# Marker used inside input.yaml to denote a ResInsight object reference.
|
|
REF_MARKER = "__resinsight_ref__"
|
|
|
|
|
|
def _is_ref(value: Any) -> bool:
|
|
return isinstance(value, dict) and REF_MARKER in value
|
|
|
|
|
|
def _holds_ref(value: Any) -> bool:
|
|
"""A reference, or a list with a reference among its items."""
|
|
return _is_ref(value) or (
|
|
isinstance(value, list) and any(_holds_ref(item) for item in value)
|
|
)
|
|
|
|
|
|
def strip_refs(value: Any) -> Any:
|
|
"""Remove ResInsight object references, which are only valid for one run.
|
|
|
|
A list that holds a reference is removed as a whole: dropping only the
|
|
reference would shorten the list and change what the remaining items mean.
|
|
"""
|
|
if isinstance(value, dict):
|
|
return {
|
|
key: strip_refs(item) for key, item in value.items() if not _holds_ref(item)
|
|
}
|
|
if isinstance(value, list):
|
|
return [strip_refs(item) for item in value if not _holds_ref(item)]
|
|
return value
|