Module wallaroo.sdk
wallaroo
– Python SDK for Wallaroo
Classes
class Bundle
-
Static methods
def upload_score_bundle_fn(gcp_bucket_name, bundle, model_id, model_ver, execution_freq='live', show_result=False, timeout_secs=120)
-
Uploads data bundles for scoring, which get scheduled for inference on a first-come first served basis. Optionally the bundles can be scheduled to be scored at pre-defined intervals: daily, monthly, weekly.
Args
gcp_bucket_name
:str
- Name of a wallaroo-enabled gcp bucket in the cluster (a nifi flow needs to be enabled for this bucket)
bundle
:dict
- Dictionary containing all required budle items: prep_queries,work_table_name,prep_fn,data_treatmetn,post_fn,model_vars,prediction_column,target_var,model.
model_id
:str
- Model storage unique identifier
model_ver
:str
- Model version
execution_freq
:str
, optional- live/daily/weekly pre-defined intervals of time in which the model will be automatically scored. Defaults to 'live' (as soon as possible).
show_results
:bool
- prints the job completion success message when set to 'True'
timeout_secs
:int
- number of seconds to wait for successful completion or error (Note: the job is executed regardless). Default 2 minutes.
class Engine (host='engine-lb', debug=False, interactive=False, rest_port=23352, data_port=29502, scheme='http')
-
Configure the connection to the Wallaroo API
Args
host
:str
- IP address of the Wallaroo model-server.
debug
:bool
, optional- SDK debug mode. Defaults to False.
rest_port
:int
, optional- Port for model upload and managent. Defaults to 23352.
data_port
:int
, optional- Port for data ingestion. Defaults to 29502.
scheme
:str
, optional- Protocol to be used for the inference generation (tcp/http). Defaults to 'http'.
Methods
def http_inference_file(self, model_id, data_path, data_type='Float', show_result=False)
-
Sends a file containing a tensor object (in json format) to score in the model server
Args
model_id
:str
- Model storage unique identifier
data_path
:str
- location of the model in the local file system
data_type
:str
- (Float/Double) defines the precision of the tensor fields
show_result
:bool
, optional- prints the model-server response on screen when set to 'True'
def http_inference_tensor(self, model_id, tensor, data_type='Float', show_result=False)
-
Sends a tensor object (in json format) to score in the model-server
Args
model_id
:str
- Model storage unique identifier
tensor
:str
- json object containing the expected inputs of the model
data_type
:str
- (Float/Double) defines the precision of the tensor fields
show_result
:bool
, optional- prints the model-server response on screen when set to 'True'
def update_model_config(self, model_id, *tensor_fields)
-
Updates the configuration of an existing model in the Wallaroo model storage
Args
model_id
:str
- Model storage unique identifier
tensor_fields
:list
- List of names of tensor fields available in the input data.
def upload_model(self, model_id, model_version, model_path)
-
Uploads a model from the local file system to the Wallaroo model-storage
Args
model_id
:str
- Model storage unique identifier
model_version
:str
- Model version
model_path
:str
- location of the model in the local file system