ads.model.runtime package

Submodules

ads.model.runtime.env_info module

class ads.model.runtime.env_info.EnvInfo[source]

Bases: ABC

Env Info Base class.

classmethod from_path(env_path: str, auth: dict | None = None) EnvInfo[source]

Initiate an object from a conda pack path.

Parameters:
  • env_path (str) – conda pack path.

  • auth ((Dict, optional). Defaults to None.) – The default authetication is set using ads.set_auth API. If you need to override the default, use the ads.common.auth.api_keys or ads.common.auth.resource_principal to create appropriate authentication signer and kwargs required to instantiate IdentityClient object.

Returns:

An EnvInfo instance.

Return type:

EnvInfo

classmethod from_slug(env_slug: str, namespace: str = 'id19sfcrra6z', bucketname: str = 'service-conda-packs', auth: dict | None = None) EnvInfo[source]

Initiate an EnvInfo object from a slug. Only service pack is allowed to use this method.

Parameters:
  • env_slug (str) – service pack slug.

  • namespace ((str, optional)) – namespace of region.

  • bucketname ((str, optional)) – bucketname of service pack.

  • auth ((Dict, optional). Defaults to None.) – The default authetication is set using ads.set_auth API. If you need to override the default, use the ads.common.auth.api_keys or ads.common.auth.resource_principal to create appropriate authentication signer and kwargs required to instantiate IdentityClient object.

Returns:

An EnvInfo instance.

Return type:

EnvInfo

class ads.model.runtime.env_info.InferenceEnvInfo(inference_env_slug: str = '', inference_env_type: str = '', inference_env_path: str = '', inference_python_version: str = '')[source]

Bases: EnvInfo, DataClassSerializable

Inference conda environment info.

inference_env_path: str = ''
inference_env_slug: str = ''
inference_env_type: str = ''
inference_python_version: str = ''
class ads.model.runtime.env_info.PACK_TYPE(value)[source]

Bases: Enum

Conda Pack Type

SERVICE_PACK = 'data_science'
USER_CUSTOM_PACK = 'published'
class ads.model.runtime.env_info.TrainingEnvInfo(training_env_slug: str = '', training_env_type: str = '', training_env_path: str = '', training_python_version: str = '')[source]

Bases: EnvInfo, DataClassSerializable

Training conda environment info.

training_env_path: str = ''
training_env_slug: str = ''
training_env_type: str = ''
training_python_version: str = ''

ads.model.runtime.model_deployment_details module

class ads.model.runtime.model_deployment_details.ModelDeploymentDetails(inference_conda_env: ~ads.model.runtime.env_info.InferenceEnvInfo = <factory>)[source]

Bases: DataClassSerializable

ModelDeploymentDetails class.

inference_conda_env: InferenceEnvInfo

ads.model.runtime.model_provenance_details module

class ads.model.runtime.model_provenance_details.ModelProvenanceDetails(project_ocid: str = '', tenancy_ocid: str = '', training_code: ~ads.model.runtime.model_provenance_details.TrainingCode = <factory>, training_compartment_ocid: str = '', training_conda_env: ~ads.model.runtime.env_info.TrainingEnvInfo = <factory>, training_region: str = '', training_resource_ocid: str = '', user_ocid: str = '', vm_image_internal_id: str = '')[source]

Bases: DataClassSerializable

ModelProvenanceDetails class.

project_ocid: str = ''
tenancy_ocid: str = ''
training_code: TrainingCode
training_compartment_ocid: str = ''
training_conda_env: TrainingEnvInfo
training_region: str = ''
training_resource_ocid: str = ''
user_ocid: str = ''
vm_image_internal_id: str = ''
class ads.model.runtime.model_provenance_details.TrainingCode(artifact_directory: str = '')[source]

Bases: DataClassSerializable

TrainingCode class.

artifact_directory: str = ''

ads.model.runtime.runtime_info module

class ads.model.runtime.runtime_info.RuntimeInfo(model_artifact_version: str = '', model_deployment: ~ads.model.runtime.model_deployment_details.ModelDeploymentDetails = <factory>, model_provenance: ~ads.model.runtime.model_provenance_details.ModelProvenanceDetails = <factory>)[source]

Bases: DataClassSerializable

RuntimeInfo class which is the data class represenation of the runtime yaml file.

classmethod from_env() RuntimeInfo[source]

Popolate the RuntimeInfo from environment variables.

Returns:

A RuntimeInfo instance.

Return type:

RuntimeInfo

model_artifact_version: str = ''
model_deployment: ModelDeploymentDetails
model_provenance: ModelProvenanceDetails
save(storage_options=None)[source]

Save the RuntimeInfo object into runtime.yaml file under the artifact directory.

Returns:

Nothing.

Return type:

None

ads.model.runtime.utils module

class ads.model.runtime.utils.SchemaValidator(schema_file_path: str)[source]

Bases: object

Base Schema Validator which validate yaml file.

Initiate a SchemaValidator instance.

Parameters:

schema_file_path ((str)) – schema file path. The schema is used to validate the yaml file.

Returns:

A SchemaValidator instance.

Return type:

SchemaValidator

validate(document: Dict) bool[source]

Validate the schema.

Parameters:

document ((Dict)) – yaml file content to validate.

Raises:

DocumentError – Raised when the validation schema is missing, has the wrong format or contains errors.:

Returns:

validation result.

Return type:

bool

ads.model.runtime.utils.get_service_packs(namespace: str, bucketname: str, auth: dict | None = None) Tuple[Dict, Dict][source]

Get the service pack path mapping and service pack slug mapping. Note: deprecated packs are also included.

Parameters:
  • namespace (str) – namespace of the service pack.

  • bucketname (str) – bucketname of the service pack.

  • auth ((Dict, optional). Defaults to None.) – The default authentication is set using ads.set_auth API. If you need to override the default, use the ads.common.auth.api_keys or ads.common.auth.resource_principal to create appropriate authentication signer and kwargs required to instantiate IdentityClient object.

Returns:

Service pack path mapping(service pack path -> (slug, python version)) and the service pack slug mapping(service pack slug -> (pack path, python version)).

Return type:

(Dict, Dict)

Module contents