mistk.model.service module¶
-
class
mistk.model.service.
ModelInstanceEndpoint
¶ Bases:
object
-
add_task
(task)¶ Adds a task to this ModelEndpointService and starts it using a pool of worker threads
- Parameters
task – The Task to register and start
- Returns
The running task
-
build_model
(modelPath=None)¶ Creates and returns a Task which builds the model using the modelPath provided
- Parameters
modelPath – The path to where the model image can be found
- Returns
The created Task object
-
delete_task
(task)¶ Deletes the specified Task. This function is currently not supported
- Parameters
task – The task to delete
-
generate
()¶ Creates and returns a Task which kicks off a generation activity
- Returns
The created Task object
-
get_api_version
()¶ Returns the version of the MISTK API
- Returns
The MISTK API version as text
-
get_status
(watch=None, resourceVersion=None)¶ Retrieves the status of this ModelEndpointService
- Parameters
watch – Optional flag indicating whether state changes should be monitored
resourceVersion – Optional version id that will be used as the minimum version number for watched status changes.
- Returns
The current status of this ModelEndpointService
-
initialize_model
(initializationParameters)¶ Creates and returns an Task which initializes the model with the optional parameters provided
- Parameters
initializationParameters – The parameters used for initialization
- Returns
The created Task object
-
load_data
(datasets)¶ Creates and returns a Task which loads data into a model using the bindings provided
- Parameters
datasets – dictionary mapping dataset function to dataset
- Returns
The create Task object
-
property
model
¶ Retrieves the model associated with this ModelEndpointService
- Returns
the model
-
pause
()¶ Pauses the model during its current operation This operation is currently not supported.
-
predict
()¶ Creates and returns a Task which kicks off a prediction activity
- Returns
The created Task object
-
put_response
(response)¶ Adds a response to the response queue
-
reset
()¶ Resets the model
-
resume_predict
()¶ Resumes a paused model into its prediction operation This operation is currently not supported.
-
resume_training
()¶ Resumes a paused model into its training operation This operation is currently not supported.
-
save_generations
(dataPath)¶ Creates and returns a Task which saves the generations generated by a model to the path specified
- Parameters
dataPath – The location in which to save the model generations
- Returns
The created Task object
-
save_model
(modelPath)¶ Creates and returns a Task which saves the model to the path provided
- Parameters
modelPath – The path where the model will be saved.
- Returns
The created Task object
-
save_predictions
(dataPath)¶ Creates and returns a Task which saves the predictions generated by a model to the path specified
- Parameters
dataPath – The location in which to save the model predictions
- Returns
The created Task object
-
start_server
(port=8080)¶ Starts the http server of the Service
- Parameters
port – The port on which to start the server, defaults to 8080
-
property
state_machine
¶ Retrieves the state machine associated with this ModelEndpointService
- Returns
the state machine
-
stream_predict
(dataMap, details=None)¶ Creates a Task which kicks off a stream prediction activity
- Parameters
dataMap – Dictionary of IDs to b64 encoded data
- Returns
Dictionary of IDs to predictions
-
terminate
()¶ Shuts down the model and the endpoint service
-
train
()¶ Creates and returns a Task which kicks off a training activity
- Returns
The created Task object
-
update_state
(state=None, payload=None)¶ Updates the state of the ModelEndpointService
- Parameters
state – The new state. If not given, the current state will be used.
payload – Additional data to attach to the state
-
update_stream_properties
(props)¶ Creates a task for updating the streaming prediction properties.
- Parameters
props – Dictionary of metadata properties to be used by the model
-
-
class
mistk.model.service.
ModelInstanceTask
(operation, parameters=None, submitted=None, completed=None, status=None, message=None)¶ Bases:
object
A task to be submitted to the Model Instance that will be performed and report status of.
-
mistk.model.service.
initializeEndpointController
(handler, *modules)¶ This method iterates over the functions defined in the auto-generated flask modules And creates a function in this package which points bound member methods of the handler
- Parameters
handler – The handler object which must implement bound member methods which otherwise have the same signature as those defined in the controller_modules
modules – These are the autogenerated swagger controller modules