Aludel.Runs (aludel v0.2.0)

Copy Markdown View Source

Context for managing runs and run results.

Summary

Functions

Returns a changeset for tracking run changes.

Creates a new run.

Creates a new run result.

Deletes a run.

Executes a run through the executor service and returns a structured outcome.

Gets a run by ID, raising if not found.

Gets a run result by ID, raising if not found.

Launches a run under the executor supervisor.

Lists the most recent runs with preloaded associations.

Lists all runs in the system.

Calculates the total cost across all run results and suite runs.

Updates an existing run.

Updates an existing run result.

Functions

change_run(run, attrs \\ %{})

@spec change_run(Aludel.Runs.Run.t(), map()) :: Ecto.Changeset.t()

Returns a changeset for tracking run changes.

create_run(attrs \\ %{})

@spec create_run(map()) :: {:ok, Aludel.Runs.Run.t()} | {:error, Ecto.Changeset.t()}

Creates a new run.

create_run_result(attrs \\ %{})

@spec create_run_result(map()) ::
  {:ok, Aludel.Runs.RunResult.t()} | {:error, Ecto.Changeset.t()}

Creates a new run result.

delete_run(run)

@spec delete_run(Aludel.Runs.Run.t()) ::
  {:ok, Aludel.Runs.Run.t()} | {:error, Ecto.Changeset.t()}

Deletes a run.

execute_run(run, providers)

@spec execute_run(Aludel.Runs.Run.t(), [Aludel.Providers.Provider.t()]) ::
  {:ok, Aludel.Runs.Execution.t()} | {:error, term()}

Executes a run through the executor service and returns a structured outcome.

get_run!(id)

@spec get_run!(binary()) :: Aludel.Runs.Run.t()

Gets a run by ID, raising if not found.

Preloads run_results and their associated providers, as well as the prompt through the prompt_version.

get_run_result!(id)

@spec get_run_result!(binary()) :: Aludel.Runs.RunResult.t()

Gets a run result by ID, raising if not found.

Preloads the associated provider so the result is ready for rendering without additional database lookups.

launch_run(run, providers)

Launches a run under the executor supervisor.

list_recent_runs(limit \\ 10)

@spec list_recent_runs(integer()) :: [Aludel.Runs.Run.t()]

Lists the most recent runs with preloaded associations.

Returns up to the specified limit of runs, ordered by insertion time descending.

list_runs()

@spec list_runs() :: [Aludel.Runs.Run.t()]

Lists all runs in the system.

total_cost()

@spec total_cost() :: float()

Calculates the total cost across all run results and suite runs.

Returns the sum of cost_usd from all run_results plus the summed per-test costs stored in suite_run results.

update_run(run, attrs)

@spec update_run(Aludel.Runs.Run.t(), map()) ::
  {:ok, Aludel.Runs.Run.t()} | {:error, Ecto.Changeset.t()}

Updates an existing run.

update_run_result(run_result, attrs)

@spec update_run_result(Aludel.Runs.RunResult.t(), map()) ::
  {:ok, Aludel.Runs.RunResult.t()} | {:error, Ecto.Changeset.t()}

Updates an existing run result.