Gust.Flows (gust v0.1.25)

The Flows context.

This module serves as the boundary for accessing and manipulating Flow-related data, such as DAGs, Runs, Tasks, and Secrets.

Summary

Functions

Returns an %Ecto.Changeset{} for tracking secret changes.

Returns the number of runs associated with a given DAG.

Creates a DAG.

Creates a log.

Creates a run.

Creates a secret.

Creates a task.

Creates a test run.

Creates a test task.

Deletes a DAG.

Deletes all DAGs whose IDs are not in the provided list.

Deletes the given run from the database.

Deletes a secret.

Gets a single DAG.

Gets a DAG by name.

Gets a DAG by name with its runs preloaded, with pagination for runs.

Gets a DAG with its runs preloaded.

Gets a DAG with its runs and tasks preloaded, with pagination for runs.

Gets a single log.

Gets a single run.

Gets a single run with its tasks preloaded.

Gets runs for a list of DAG IDs with the given statuses.

Gets a single secret.

Gets a single secret by name.

Gets a single task.

Gets a task by name and run ID.

Gets a task by name and run ID, with logs preloaded.

Gets a task with its logs preloaded.

Lists all DAGs.

Lists all secrets.

Toggles the enabled status of a DAG.

Updates a run status.

Updates a secret.

Updates a task attempt count.

Updates a task error.

Updates a task result.

Updates a task result and error.

Updates a task status.

Functions

change_secret(secret, attrs \\ %{})

Returns an %Ecto.Changeset{} for tracking secret changes.

Examples

iex> change_secret(secret)
%Ecto.Changeset{data: %Secret{}}

count_runs_on_dag(dag_id)

Returns the number of runs associated with a given DAG.

Parameters

  • dag_id - The identifier of the DAG whose runs should be counted.

Returns

  • The integer count of runs associated with the specified DAG.

create_dag(attrs \\ %{})

Creates a DAG.

Examples

iex> create_dag(%{field: value})
{:ok, %Dag{}}

iex> create_dag(%{field: bad_value})
{:error, %Ecto.Changeset{}}

create_log(attrs \\ %{})

Creates a log.

create_run(attrs \\ %{})

Creates a run.

Examples

iex> create_run(%{field: value})
{:ok, %Run{}}

iex> create_run(%{field: bad_value})
{:error, %Ecto.Changeset{}}

create_secret(attrs \\ %{})

Creates a secret.

Examples

iex> create_secret(%{field: value})
{:ok, %Secret{}}

iex> create_secret(%{field: bad_value})
{:error, %Ecto.Changeset{}}

create_task(attrs \\ %{})

Creates a task.

create_test_run(attrs \\ %{})

Creates a test run.

create_test_task(attrs \\ %{})

Creates a test task.

delete_dag!(dag)

Deletes a DAG.

delete_not_found_ids(ids)

Deletes all DAGs whose IDs are not in the provided list.

delete_run(run)

Deletes the given run from the database.

The run must be a persisted %Run{} struct. This function delegates to Repo.delete/1 and returns {:ok, %Run{}} if the run is successfully deleted, or {:error, %Ecto.Changeset{}} if the delete operation fails.

Examples

iex> delete_run(run)
{:ok, %Run{}}

iex> delete_run(invalid_run)
{:error, %Ecto.Changeset{}}

delete_secret(secret)

Deletes a secret.

get_dag!(id)

Gets a single DAG.

Raises Ecto.NoResultsError if the Dag does not exist.

get_dag_by_name(name)

Gets a DAG by name.

get_dag_by_name_with_runs!(name, list)

Gets a DAG by name with its runs preloaded, with pagination for runs.

The DAG is looked up by its name. The associated runs are ordered by descending inserted_at and paginated using the provided limit and offset keyword arguments.

Parameters

  • name - The name of the DAG to retrieve.
  • limit - The maximum number of runs to preload.
  • offset - The number of runs to skip before starting to preload.

Returns

Returns the %Dag{} struct with its :runs association preloaded according to the given pagination options. Raises Ecto.NoResultsError if no DAG with the given name exists.

get_dag_with_runs!(id)

Gets a DAG with its runs preloaded.

get_dag_with_runs_and_tasks!(name, list)

Gets a DAG with its runs and tasks preloaded, with pagination for runs.

get_log!(id)

Gets a single log.

Raises Ecto.NoResultsError if the Log does not exist.

get_run!(id)

Gets a single run.

Raises Ecto.NoResultsError if the Run does not exist.

Examples

iex> get_run!(123)
%Run{}

iex> get_run!(456)
** (Ecto.NoResultsError)

get_run_with_tasks!(id)

Gets a single run with its tasks preloaded.

get_running_runs_by_dag(dag_ids, statuses)

Gets runs for a list of DAG IDs with the given statuses.

Parameters

  • dag_ids: List of DAG IDs to filter runs by.
  • statuses: List of statuses (atoms) to filter runs by (e.g., [:running, :queued]).

Examples

iex> get_running_runs_by_dag([1, 2, 3], [:running, :retrying])
[%Run{}, ...]

get_secret!(id)

Gets a single secret.

Raises Ecto.NoResultsError if the Secret does not exist.

get_secret_by_name(name)

Gets a single secret by name.

get_task!(id)

Gets a single task.

Raises Ecto.NoResultsError if the Task does not exist.

get_task_by_name_run(name, run_id)

Gets a task by name and run ID.

get_task_by_name_run_with_logs(name, run_id, log_level \\ nil)

Gets a task by name and run ID, with logs preloaded.

Accepts an optional log_level argument:

  • When log_level is nil (the default), all logs for the task are preloaded.
  • When log_level is provided, only logs with the matching level are preloaded.

Logs are ordered by their inserted_at timestamp in ascending order.

get_task_with_logs!(id)

Gets a task with its logs preloaded.

list_dags()

Lists all DAGs.

list_secrets()

Lists all secrets.

toggle_enabled(dag)

Toggles the enabled status of a DAG.

update_run_status(run, status)

Updates a run status.

update_secret(secret, attrs)

Updates a secret.

update_task_attempt(task, attempt)

Updates a task attempt count.

update_task_error(task, error)

Updates a task error.

update_task_result(task, result)

Updates a task result.

update_task_result_error(task, result, error)

Updates a task result and error.

update_task_status(task, status)

Updates a task status.