Skip to main content

WorkflowDag

Struct WorkflowDag 

Source
pub struct WorkflowDag { /* private fields */ }
Expand description

Workflow DAG structure.

Implementations§

Source§

impl WorkflowDag

Source

pub fn new() -> Self

Create a new empty workflow DAG.

Source

pub fn add_task(&mut self, task: TaskNode) -> Result<NodeIndex>

Add a task to the DAG.

Source

pub fn add_dependency( &mut self, from_task_id: &str, to_task_id: &str, edge: TaskEdge, ) -> Result<()>

Add a dependency edge between two tasks.

Source

pub fn get_task(&self, task_id: &str) -> Option<&TaskNode>

Get a task by ID.

Source

pub fn get_task_mut(&mut self, task_id: &str) -> Option<&mut TaskNode>

Get a task by ID (mutable).

Source

pub fn get_dependencies(&self, task_id: &str) -> Vec<String>

Get task dependencies (tasks that must complete before this task).

Source

pub fn get_dependents(&self, task_id: &str) -> Vec<String>

Get task dependents (tasks that depend on this task).

Source

pub fn validate(&self) -> Result<()>

Validate the DAG structure.

Source

pub fn tasks(&self) -> Vec<&TaskNode>

Get all tasks in the DAG.

Source

pub fn task_count(&self) -> usize

Get the number of tasks in the DAG.

Source

pub fn dependency_count(&self) -> usize

Get the number of dependencies in the DAG.

Source

pub fn root_tasks(&self) -> Vec<&TaskNode>

Get root tasks (tasks with no dependencies).

Source

pub fn leaf_tasks(&self) -> Vec<&TaskNode>

Get leaf tasks (tasks with no dependents).

Source

pub fn edges(&self) -> Vec<(&str, &str, &TaskEdge)>

Get all edges in the DAG as (from_task_id, to_task_id, edge_data) tuples.

This method is useful for visualization and serialization purposes. Returns edges in the order they are stored in the graph.

Source

pub fn edge_pairs(&self) -> Vec<(String, String)>

Get all edges with their edge types as (from_task_id, to_task_id, edge_type) tuples.

A simplified version of edges() that only returns edge types.

Source

pub fn get_dependencies_with_edges( &self, task_id: &str, ) -> Vec<(String, &TaskEdge)>

Get task dependencies along with their edge data.

Returns a vector of (dependency_task_id, edge_data) tuples for the given task. Dependencies are tasks that must complete before the specified task can start.

Source

pub fn get_dependents_with_edges( &self, task_id: &str, ) -> Vec<(String, &TaskEdge)>

Get task dependents along with their edge data.

Returns a vector of (dependent_task_id, edge_data) tuples for the given task. Dependents are tasks that wait for the specified task to complete.

Source

pub fn get_edge_between( &self, from_task_id: &str, to_task_id: &str, ) -> Option<&TaskEdge>

Get the edge data between two specific tasks, if it exists.

Returns None if either task does not exist or no edge connects them.

Source

pub fn has_dependency(&self, from_task_id: &str, to_task_id: &str) -> bool

Check if a dependency exists between two tasks.

Returns true if from_task_id has a direct edge to to_task_id.

Source

pub fn has_dependencies(&self, task_id: &str) -> bool

Check if a task has any dependencies (incoming edges).

Source

pub fn has_dependents(&self, task_id: &str) -> bool

Check if a task has any dependents (outgoing edges).

Source

pub fn in_degree(&self, task_id: &str) -> usize

Get the in-degree of a task (number of dependencies).

Source

pub fn out_degree(&self, task_id: &str) -> usize

Get the out-degree of a task (number of dependents).

Source

pub fn task_ids(&self) -> Vec<String>

Get all task IDs in the DAG.

Source

pub fn contains_task(&self, task_id: &str) -> bool

Check if a task exists in the DAG.

Source

pub fn remove_task(&mut self, task_id: &str) -> Option<TaskNode>

Remove a task from the DAG along with all its edges.

Returns the removed task, or None if the task did not exist.

Source

pub fn edges_by_type(&self, edge_type: EdgeType) -> Vec<(&str, &str, &TaskEdge)>

Get edges filtered by edge type.

Source

pub fn subgraph(&self, task_ids: &[&str]) -> WorkflowDag

Get a subgraph containing only the specified tasks and edges between them.

Tasks not present in the original DAG are silently ignored.

Source

pub fn transitive_dependencies(&self, task_id: &str) -> Vec<String>

Compute the transitive closure of dependencies for a task.

Returns all tasks that must complete (directly or transitively) before the given task can execute.

Source

pub fn transitive_dependents(&self, task_id: &str) -> Vec<String>

Compute the transitive closure of dependents for a task.

Returns all tasks that (directly or transitively) depend on the given task.

Source

pub fn summary(&self) -> DagSummary

Get summary statistics about the DAG structure.

Trait Implementations§

Source§

impl Clone for WorkflowDag

Source§

fn clone(&self) -> WorkflowDag

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkflowDag

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WorkflowDag

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for WorkflowDag

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for WorkflowDag

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,