snowflake.ml.model.custom_model.MethodRef¶
- class snowflake.ml.model.custom_model.MethodRef(model_ref: ModelRef, method_name: str)¶
Bases:
object
Represents a method invocation of an instance of ModelRef.
- This allows us to:
Customize the place of actual execution of the method (inline, thread/process pool, or remote).
Enrich the way of execution (sync versus async).
Example
If you have an SKL model, you would normally invoke it by skl_ref.predict(df), which has a synchronous API. Within the inference graph, you could invoke await skl_ref.predict.async_run(df), which will automatically run on a thread with an asynchronous interface.
Methods
- async async_run(*args: Any, **kwargs: Any) Any ¶
Run the method in an asynchronous way. If the method is defined as async, this will simply run it. If not, this will be run in a separate thread.
- Parameters:
*args – Arguments of the original method.
**kwargs – Keyword arguments of the original method.
- Returns:
The result of the original method.