Shortcuts

modelzoo

The Model Zoo Python client.

modelzoo.auth(api_key: Optional[str] = None) → str

Initialize or overwrite the API key used by this environment. This will edit or create the configuration file (~/.modelzoo/config.json).

Parameters
  • api_key – Optional string API key. If not provided, this function will

  • the user to input an API key. (prompt) –

Returns

The API key

modelzoo.delete(model_name: str, api_key: Optional[str] = None, silent: bool = False) → Dict[str, Any]

Delete a model from your model zoo.

Before calling this function, the model must be in a STOPPED or STOPPING state.

Warning

This operation is irreversible. If you might need to start this model in the future and want to save costs by shutting it down, consider using modelzoo.stop().

Parameters
  • model_name – String name of the model.

  • api_key – Optional API key that, if provided, will override the API key available to the environment.

  • silent – Boolean that disables the confirmation prompt when deleting a model. Defaults to False.

Returns

Dictionary of model metadata.

modelzoo.info(model_name: str, api_key: Optional[str] = None) → Dict[str, Any]

Retrieve information about a deployed model.

Parameters
  • model_name – String name of the model.

  • api_key – Optional API key that, if provided, will override the API key available to the environment.

Returns

Dictionary of model metadata.

modelzoo.list(api_key: Optional[str] = None) → Dict[str, Any]

Retrieve information about all of the user’s deployed models.

Parameters

api_key – Optional API key that, if provided, will override the API key available to the environment.

Returns

Dictionary containing a list of models.

modelzoo.logs(model_name: str, api_key: Optional[str] = None, max_num_logs: Optional[int] = None) → Dict[str, Any]

Print the most recent logs emitted by the model.

Parameters
  • model_name – String name of the model.

  • max_num_logs – The maximum number of log lines to retrieve. Defaults to the maximum allowed number, 10,000 log lines. If there are more log lines than max_num_logs, the most recent log lines will be returned.

  • api_key – Optional API key that, if provided, will override the API key available to the environment.

Returns

Dictionary containing a list of models.

modelzoo.predict(model_name: str, payload: Dict[str, Any], headers: Dict[str, Any] = None, api_key: Optional[str] = None) → Dict[str, Any]

Send a prediction to a model.

Parameters
  • model_name – String name of the model.

  • payload – Dictionary of data to send to the model endpoint. Must be JSON-serializable.

  • api_key – Optional API key that, if provided, will override the API key available to the environment.

modelzoo.start(model_name: str, wait: bool = True, api_key: Optional[str] = None) → None

Start a model. This function has no effect if the model is already started.

Parameters
  • model_name – String name of the model.

  • wait – Boolean that specifies whether this function blocks until the model reaches a HEALTHY state.

  • api_key – Optional API key that, if provided, will override the API key available to the environment.

Returns

Nothing

Raises

APIError if the model doesn't exist.

modelzoo.stop(model_name: str, wait: bool = True, api_key: Optional[str] = None) → None

Stop a model. This function has no effect if the model is already stopped.

Parameters
  • model_name – String name of the model.

  • wait – Boolean that specifies whether this function blocks until the model reaches a STOPPED state.

  • api_key – Optional API key that, if provided, will override the API key available to the environment.

Returns

Nothing

Raises

APIError if the model doesn't exist.

modelzoo.wait(model_name: str, target_state: modelzoo.model_state.ModelState, api_key: Optional[str] = None, timeout_seconds: int = 300) → None

Wait for a model to transition to a desired state.

Parameters
  • model_name – String name of the model

  • target_state – A target modelzoo.ModelState to wait for the model to transition to.

  • timeout_seconds – Maximum number of seconds to wait for.

  • api_key – Optional API key that, if provided, will override the API key available to the environment.

Returns

Dictionary of model metadata

class modelzoo.ModelState

Represents the possible states of a model in the zoo. Use modelzoo.start() and modelzoo.stop() to change the state of a model.

HEALTHY:

The model is ready to make predictions.

STOPPED:

The model is stopped.

STARTING:

The model is transitioning into a HEALTHY state but not yet ready to make predictions.

STOPPING:

The model is transitioning into a STOPPED state and will not be able to make predictions.

Error

Something went wrong when loading the model.

class modelzoo.ResourcesConfig(memory_mb: int = 512, cpu_units: int = 256)

ResourcesConfig specifies optional configuration to use when provisioning a model serving container.

memory_mb:

integer number of megabytes of memory each model container should use.

cpu_units:

integer number of CPU units each model container should use (1024 CPU units = 1 vCPU).