snowflake.snowpark.functions.service¶
- snowflake.snowpark.functions.service(service_name: str) Callable[source]¶
Creates a service function that can be used to call a service method.
- Parameters:
service_name – The name of the service to call.
Example:
>>> service_instance = service("TESTSCHEMA_SNOWPARK_PYTHON.FORECAST_MODEL_SERVICE") >>> # Prepare a DataFrame with the ten expected features >>> df = session.create_dataframe( ... [ ... (0.038076, 0.050680, 0.061696, 0.021872, -0.044223, -0.034821, -0.043401, -0.002592, 0.019907, -0.017646), ... ], ... schema=["age", "sex", "bmi", "bp", "s1", "s2", "s3", "s4", "s5", "s6"], ... ) >>> # Invoke the model's predict method exposed by the service >>> result_df = df.select( ... service_instance("predict")(col("age"), col("sex"), col("bmi"), col("bp"), col("s1"), col("s2"), col("s3"), col("s4"), col("s5"), col("s6"))["output_feature_0"] ... ) >>> result_df.show() ------------------------------------------------------ |"TESTSCHEMA_SNOWPARK_PYTHON.FORECAST_MODEL_SERV... | ------------------------------------------------------ |220.2223358154297 | ------------------------------------------------------