# Generated by SnakeBridge v0.14.0 - DO NOT EDIT MANUALLY # Regenerate with: mix compile # Library: dspy 3.1.2 # Python module: dspy.utils.saving defmodule Dspy.Utils.Saving do @moduledoc """ Submodule bindings for `dspy.utils.saving`. ## Version - Requested: 3.1.2 - Observed at generation: 3.1.2 ## Runtime Options All functions accept a `__runtime__` option for controlling execution behavior: Dspy.Utils.Saving.some_function(args, __runtime__: [timeout: 120_000]) ### Supported runtime options - `:timeout` - Call timeout in milliseconds (default: 120,000ms / 2 minutes) - `:timeout_profile` - Use a named profile (`:default`, `:ml_inference`, `:batch_job`, `:streaming`) - `:stream_timeout` - Timeout for streaming operations (default: 1,800,000ms / 30 minutes) - `:session_id` - Override the session ID for this call - `:pool_name` - Target a specific Snakepit pool (multi-pool setups) - `:affinity` - Override session affinity (`:hint`, `:strict_queue`, `:strict_fail_fast`) ### Timeout Profiles - `:default` - 2 minute timeout for regular calls - `:ml_inference` - 10 minute timeout for ML/LLM workloads - `:batch_job` - Unlimited timeout for long-running jobs - `:streaming` - 2 minute timeout, 30 minute stream_timeout ### Example with timeout override # For a long-running ML inference call Dspy.Utils.Saving.predict(data, __runtime__: [timeout_profile: :ml_inference]) # Or explicit timeout Dspy.Utils.Saving.predict(data, __runtime__: [timeout: 600_000]) # Route to a pool and enforce strict affinity Dspy.Utils.Saving.predict(data, __runtime__: [pool_name: :strict_pool, affinity: :strict_queue]) See `SnakeBridge.Defaults` for global timeout configuration. """ @doc false def __snakebridge_python_name__, do: "dspy.utils.saving" @doc false def __snakebridge_library__, do: "dspy" @doc """ Python binding for `dspy.utils.saving.get_dependency_versions`. ## Returns - `term()` """ @spec get_dependency_versions(keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def get_dependency_versions(opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, :get_dependency_versions, [], opts) end @doc """ Load saved DSPy model. This method is used to load a saved DSPy model with `save_program=True`, i.e., the model is saved with cloudpickle. ## Parameters - `path` - Path to the saved model. (type: `String.t()`) - `allow_pickle` - Whether to allow loading the model with pickle. This is dangerous and should only be used if you are sure you trust the source of the model. (type: `boolean()`) ## Returns - `term()` """ @spec load(String.t()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec load(String.t(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec load(String.t(), boolean()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec load(String.t(), boolean(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def load(path) do SnakeBridge.Runtime.call(__MODULE__, :load, [path], []) end def load(path, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :load, [path], opts) end def load(path, allow_pickle) do SnakeBridge.Runtime.call(__MODULE__, :load, [path, allow_pickle], []) end def load(path, allow_pickle, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :load, [path, allow_pickle], opts) end end