@@ -26,7 +26,8 @@ def create_endpoint(
2626 labels = None ,
2727 registry = None ,
2828 base_image = "clipper/pyspark-container:{}" .format (__version__ ),
29- num_replicas = 1 ):
29+ num_replicas = 1 ,
30+ batch_size = - 1 ):
3031 """Registers an app and deploys the provided predict function with PySpark model as
3132 a Clipper model.
3233
@@ -79,13 +80,19 @@ def create_endpoint(
7980 The number of replicas of the model to create. The number of replicas
8081 for a model can be changed at any time with
8182 :py:meth:`clipper.ClipperConnection.set_num_replicas`.
83+ batch_size : int, optional
84+ The user-defined query batch size for the model. Replicas of the model will attempt
85+ to process at most `batch_size` queries simultaneously. They may process smaller
86+ batches if `batch_size` queries are not immediately available.
87+ If the default value of -1 is used, Clipper will adaptively calculate the batch size for individual
88+ replicas of this model.
8289 """
8390
8491 clipper_conn .register_application (name , input_type , default_output ,
8592 slo_micros )
8693 deploy_pyspark_model (clipper_conn , name , version , input_type , func ,
8794 pyspark_model , sc , base_image , labels , registry ,
88- num_replicas )
95+ num_replicas , batch_size )
8996
9097 clipper_conn .link_model_to_app (name , name )
9198
@@ -101,7 +108,8 @@ def deploy_pyspark_model(
101108 base_image = "clipper/pyspark-container:{}" .format (__version__ ),
102109 labels = None ,
103110 registry = None ,
104- num_replicas = 1 ):
111+ num_replicas = 1 ,
112+ batch_size = - 1 ):
105113 """Deploy a Python function with a PySpark model.
106114
107115 The function must take 3 arguments (in order): a SparkSession, the PySpark model, and a list of
@@ -141,7 +149,12 @@ def deploy_pyspark_model(
141149 The number of replicas of the model to create. The number of replicas
142150 for a model can be changed at any time with
143151 :py:meth:`clipper.ClipperConnection.set_num_replicas`.
144-
152+ batch_size : int, optional
153+ The user-defined query batch size for the model. Replicas of the model will attempt
154+ to process at most `batch_size` queries simultaneously. They may process smaller
155+ batches if `batch_size` queries are not immediately available.
156+ If the default value of -1 is used, Clipper will adaptively calculate the batch size for individual
157+ replicas of this model.
145158
146159 Example
147160 -------
@@ -214,7 +227,7 @@ def predict(spark, model, inputs):
214227 # Deploy model
215228 clipper_conn .build_and_deploy_model (name , version , input_type ,
216229 serialization_dir , base_image , labels ,
217- registry , num_replicas )
230+ registry , num_replicas , batch_size )
218231
219232 # Remove temp files
220233 shutil .rmtree (serialization_dir )
0 commit comments