Skip to content

Best Graph

best_graph

Best_graph workflow action.

Extracts the optimal DAG from a PDG with the greedy algorithm. The action reads the matched PDG cache entry (MAP pattern) and writes a single dag object to the output cache. The action is stateless, so validation and execution delegate to module-level helpers and each step stays within the module and method limits.

Classes:

BestGraphAction

Extract the optimal DAG from a PDG.

Attributes:

  • action_name –

    Action name as used in workflow definitions.

  • pattern –

    Workflow action pattern used for cache validation.

Methods:

  • run –

    Execute optimal DAG extraction from a PDG.

  • validate –

    Validate best_graph parameters before execution.

run
run(
    parameters: Dict[str, Any],
    mode: str,
    context: Optional[Any] = None,
    logger: Optional[Any] = None,
) -> ActionResult

Execute optimal DAG extraction from a PDG.

Reads the PDG from the matched workflow cache entry (MAP pattern), extracts the optimal DAG and returns it as a GraphML object for the output cache.

Parameters:

  • parameters
    (Dict[str, Any]) –

    Action parameter values.

  • mode
    (str) –

    Execution mode ('dry-run', 'run' or 'compare').

  • context
    (Optional[Any], default: None ) –

    Workflow context for optimisation.

  • logger
    (Optional[Any], default: None ) –

    Logger for reporting.

Returns:

  • ActionResult –

    Tuple of (status, metadata, objects).

Raises:

  • ActionExecutionError –

    If execution fails.

validate
validate(parameters: Dict[str, Any]) -> None

Validate best_graph parameters before execution.

Parameters:

  • parameters
    (Dict[str, Any]) –

    Action parameter values.

Raises:

  • ValueError –

    If a parameter is missing or invalid. The provider converts this to an ActionValidationError.