Tinkex.TrainingClient.Polling (Tinkex v0.3.4)

View Source

Future polling and result awaiting for TrainingClient.

This module handles:

  • Awaiting forward/backward results from polling tasks
  • Unlink tasks to prevent process coupling
  • Safe await with error handling
  • Response conversion to typed structs

Summary

Functions

Await forward-backward polling tasks and convert results to typed structs.

Await forward-only polling tasks and convert results to typed structs.

Await forward results specifically for custom loss computation.

Poll an unload future and await its result.

Build base poll options from state and user-provided options.

Build poll options with request type metadata.

Safely await a task with timeout and error handling.

Unlink a task to prevent process coupling.

Functions

await_forward_backward_results(list, future_module)

@spec await_forward_backward_results([Task.t()], module()) ::
  {:ok, [Tinkex.Types.ForwardBackwardOutput.t()]} | {:error, Tinkex.Error.t()}

Await forward-backward polling tasks and convert results to typed structs.

Returns the results in order. If any task fails, remaining tasks are killed and an error is returned.

await_forward_results(list, future_module)

@spec await_forward_results([Task.t()], module()) ::
  {:ok, [Tinkex.Types.ForwardBackwardOutput.t()]} | {:error, Tinkex.Error.t()}

Await forward-only polling tasks and convert results to typed structs.

Similar to await_forward_backward_results but specifically for forward passes.

await_forward_results_for_custom_loss(list, future_module)

@spec await_forward_results_for_custom_loss([Task.t()], module()) ::
  {:ok, [Tinkex.Types.ForwardBackwardOutput.t()]} | {:error, Tinkex.Error.t()}

Await forward results specifically for custom loss computation.

Same as await_forward_results but with clearer naming for custom loss context.

poll_and_await_unload(future, state, opts)

@spec poll_and_await_unload(map(), map(), keyword()) ::
  {:ok, Tinkex.Types.UnloadModelResponse.t()} | {:error, Tinkex.Error.t()}

Poll an unload future and await its result.

Polls the future, unlinks the task, and converts the result to an UnloadModelResponse.

poll_opts(state, opts)

@spec poll_opts(
  map(),
  keyword()
) :: keyword()

Build base poll options from state and user-provided options.

poll_opts_with_type(state, opts, request_type)

@spec poll_opts_with_type(map(), keyword(), String.t()) :: keyword()

Build poll options with request type metadata.

safe_await(future_module, task, timeout)

@spec safe_await(module(), Task.t(), timeout()) ::
  {:ok, any()} | {:error, Tinkex.Error.t()}

Safely await a task with timeout and error handling.

Wraps Task.await with exception and exit handling to ensure errors are returned in a consistent format.