There are more AWS SDK examples available in the AWS Doc SDK Examples
Use StartModel
with an AWS SDK
The following code example shows how to use StartModel
.
For more information, see Starting your model.
- Python
-
- SDK for Python (Boto3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. class Hosting: @staticmethod def start_model( lookoutvision_client, project_name, model_version, min_inference_units ): """ Starts the hosting of a Lookout for Vision model. :param lookoutvision_client: A Boto3 Lookout for Vision client. :param project_name: The name of the project that contains the version of the model that you want to start hosting. :param model_version: The version of the model that you want to start hosting. :param min_inference_units: The number of inference units to use for hosting. """ try: logger.info( "Starting model version %s for project %s", model_version, project_name ) lookoutvision_client.start_model( ProjectName=project_name, ModelVersion=model_version, MinInferenceUnits=min_inference_units, ) print("Starting hosting...") status = "" finished = False # Wait until hosted or failed. while finished is False: model_description = lookoutvision_client.describe_model( ProjectName=project_name, ModelVersion=model_version ) status = model_description["ModelDescription"]["Status"] if status == "STARTING_HOSTING": logger.info("Host starting in progress...") time.sleep(10) continue if status == "HOSTED": logger.info("Model is hosted and ready for use.") finished = True continue logger.info("Model hosting failed and the model can't be used.") finished = True if status != "HOSTED": logger.error("Error hosting model: %s", status) raise Exception(f"Error hosting model: {status}") except ClientError: logger.exception("Couldn't host model.") raise
-
For API details, see StartModel in AWS SDK for Python (Boto3) API Reference.
-
ListProjects
StopModel