ads.model.deployment.common package

Submodules

ads.model.deployment.common.progress_bar module

ads.model.deployment.common.utils module

Utilities used by the model deployment package

class ads.model.deployment.common.utils.OCIClientManager(config=None)[source]

Bases: object

OCIClientManager is a helper class used for accessing DataScienceClient and DataScienceCompositeClient objects

ds_client - class attribute for data science client
ds_composite_client - class attribute for data science composite client
default_compartment_id()[source]

Determines the default compartment OCID This method finds the compartment OCID from (in priority order): an environment variable, an API key config or a resource principal signer.

Parameters:

config (dict, optional) –

The model deployment config, which contains the following keys: auth: Authentication method, must be either “resource_principal” or “api_key”. If auth is not specified:

  1. api_key will be used if available.

  2. If api_key is not available, resource_principal will be used.

oci_config_file: OCI API key config file location. Defaults to “~/.oci/config” oci_config_profile: OCI API key config profile name. Defaults to “DEFAULT”

Returns:

The compartment OCID if found. Otherwise None.

Return type:

str or None

prepare_artifact(model_uri: str, properties: Dict) str[source]

Prepare model artifact. Returns model ocid.

Parameters:
  • model_uri (str) – uri to model files, can be local or in cloud storage

  • properties (dict) – dictionary of properties that are needed for creating a model.

  • ds_client (DataScienceClient) – OCI DataScienceClient

Returns:

model ocid

Return type:

str

class ads.model.deployment.common.utils.State(value)[source]

Bases: Enum

An enumeration.

ACTIVE = 1
CREATING = 2
DELETED = 3
DELETING = 4
FAILED = 5
INACTIVE = 6
UNKNOWN = 8
UPDATING = 7
ads.model.deployment.common.utils.get_logger()[source]
ads.model.deployment.common.utils.is_notebook()[source]

is_notebook returns True if the environment is a Jupyter notebook and False otherwise

Parameters:

None

Returns:

True if Jupyter notebook; False otherwise

Return type:

bool

Raises:

NameError – If retrieving the shell name from get_ipython() throws an error

ads.model.deployment.common.utils.seconds_since(t)[source]

seconds_since returns the seconds since t. t is assumed to be a time in epoch seconds since time.time() returns the current time in epoch seconds.

Parameters:

t (int)

Returns

int: the number of seconds since t

ads.model.deployment.common.utils.send_request(data, endpoint: str, dry_run: bool = False, is_json_payload: bool = False, header: dict = {}, **kwargs)[source]

Sends the data to the predict endpoint.

Parameters:
  • data (bytes or Json serializable) – data need to be sent to the endpoint.

  • endpoint (str) – The model HTTP endpoint.

  • dry_run (bool, optional) – Defaults to False.

  • is_json_payload (bool, optional) – Indicate whether to send data with a application/json MIME TYPE. Defaults to False.

  • header (dict, optional) – A dictionary of HTTP headers to send to the specified url. Defaults to {}.

Returns:

A JSON representive of a requests.Response object.

ads.model.deployment.common.utils.set_log_level(level='INFO')[source]

set_log_level sets the logger level

Parameters:

level (str, optional) – The logger level. Defaults to “INFO”

Returns:

Nothing

Module contents