ads.model.runtime package

Submodules

ads.model.runtime.env_info module

class ads.model.runtime.env_info.EnvInfo

Bases: ABC

Env Info Base class.

classmethod from_path(env_path: str) EnvInfo

Initiate an object from a conda pack path.

Parameters

env_path (str) – conda pack path.

Returns

An EnvInfo instance.

Return type

EnvInfo

classmethod from_slug(env_slug: str, namespace: str = 'id19sfcrra6z', bucketname: str = 'service-conda-packs') EnvInfo

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.

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 = '')

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)

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 = '')

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>)

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 = '')

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 = '')

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>)

Bases: DataClassSerializable

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

classmethod from_env() RuntimeInfo

Popolate the RuntimeInfo from environment variables.

Returns

A RuntimeInfo instance.

Return type

RuntimeInfo

model_artifact_version: str = ''
model_deployment: ModelDeploymentDetails
model_provenance: ModelProvenanceDetails
save()

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)

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

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) Tuple[Dict, Dict]

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.

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