APIFuture
Generated from tinker 0.39.0 at commit 4801e02. Source links point at that snapshot.
class tinker.APIFuture(...)
Abstract base class for futures that can be awaited or accessed synchronously.
APIFuture provides a unified interface for handling async operations that can be accessed both synchronously (via result()) and asynchronously (via await or result_async()). This allows for flexible usage patterns in both sync and async contexts.
The future can be awaited directly in async contexts:
Or accessed synchronously:
Parameters:
- T – The type of the result value
Example:
# In async context
future = training_client.forward_backward(data, "cross_entropy")
result = await future # Or await future.result_async()
# In sync context
future = training_client.forward_backward(data, "cross_entropy")
result = future.result()
result(timeout=None)
Get the result synchronously with optional timeout.
Parameters:
- timeout (float | None, default:
None) – Maximum time to wait in seconds. None means wait indefinitely.
Returns:
- The result value of type
T
Raises:
TimeoutError: If timeout is exceeded
Async variant: result_async()
future()
The concurrent.futures.Future for this operation.
For blocking code that works with standard futures: concurrent.futures.wait,
as_completed, add_done_callback, or a library that takes a Future. Cancelling
it cancels the operation. In async code, await this future instead.
Returns:
- A
concurrent.futures.Futurethat completes with this future's result
coroutine()
This future as a coroutine, for APIs that take a coroutine rather than an awaitable,
such as asyncio.create_task. Awaiting the coroutine awaits the future.
Example:
Returns: T
Referenced by
- AdminClient.get_audit_log
- AdminClient.get_billing_usage
- AdminClient.get_current_checkpoint_storage_usage
- RestClient.assign_session_project
- RestClient.delete_checkpoint
- RestClient.delete_checkpoint_from_tinker_path
- RestClient.export_session_trace
- RestClient.external_weights_upload_finish
- RestClient.external_weights_upload_start
- RestClient.get_audit_log
- RestClient.get_billing_usage
- RestClient.get_current_checkpoint_storage_usage
- RestClient.get_external_weights_urls
- RestClient.get_sampler
- RestClient.get_server_capabilities
- RestClient.get_session
- RestClient.get_training_run
- RestClient.get_training_run_by_tinker_path
- RestClient.get_weights_info_by_tinker_path
- RestClient.list_checkpoints
- RestClient.list_sessions
- RestClient.list_training_runs
- RestClient.list_user_checkpoints
- RestClient.publish_checkpoint_from_tinker_path
- RestClient.search_checkpoints
- RestClient.search_sessions
- RestClient.set_checkpoint_ttl_from_tinker_path
- RestClient.unpublish_checkpoint_from_tinker_path
- RestClient.whoami
- SamplingClient.compute_logprobs
- SamplingClient.sample
- ServiceClient.create_custom_loss
- TrainingClient.forward
- TrainingClient.forward_backward
- TrainingClient.forward_backward_custom
- TrainingClient.load_state
- TrainingClient.load_state_with_optimizer
- TrainingClient.optim_step
- TrainingClient.save_state
- TrainingClient.save_weights_external
- TrainingClient.save_weights_for_sampler