Modelarts API

The ModelartsV1 Service Class

The modelarts high-level interface is available through the modelartsv1 member of a Connection object. The modelartsv1 member will only be added if the otcextensions.sdk.register_otc_extensions(conn) method is called.

Devenv Operations

class otcextensions.sdk.modelartsv1.v1._proxy.Proxy(session, *args, **kwargs)
devenv_instances(**params)

List all Devenv Instances.

Parameters:

params (dict) – Optional query parameters to be sent to limit the instances being returned.

Returns:

a generator of Devenv instances.

create_devenv_instance(**attrs)

Create a devenv instance from attributes.

Parameters:

attrs (dict) – Keyword arguments which will be used to create a Devenv, comprised of the properties on the Devenv class.

Returns:

The results of devenv instance creation.

Return type:

Devenv

get_devenv_instance(instance)

Get details of a Devenv Instance.

Parameters:

instance – devenv instance id or an instance of Devenv.

Returns:

instance of Devenv.

find_devenv_instance(name_or_id, ignore_missing=False)

Find a single Devenv instance by name or Id.

Parameters:
  • name_or_id – The name or ID of a Devenv instance.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised if the devenv does not exist. When set to True, no exception will be set when attempting to find a nonexistent devenv.

Returns:

One Devenv or None

update_devenv_instance(instance, **attrs)

Update a Devenv Instance Configurations.

Parameters:
  • instance – devenv instance id or an instance of Devenv

  • attrs (dict) – Keyword arguments which will be used to update a Devenv, comprised of the properties on the Devenv class.

start_devenv_instance(instance)

Start a Devenv instance.

Parameters:

instance – devenv instance id or an instance of Devenv

Returns:

instance of Devenv

stop_devenv_instance(instance)

Stop a Devenv instance.

Parameters:

instance – devenv instance id or an instance of Devenv

Returns:

instance of Devenv

delete_devenv_instance(instance, ignore_missing=False)

Delete a Devenv instance.

Parameters:
  • instance – devenv instance id or an instance of Devenv.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the group does not exist. When set to True, no exception will be set when attempting to delete a nonexistent devenv.

Returns:

None

Built-In Model Operations

class otcextensions.sdk.modelartsv1.v1._proxy.Proxy(session, *args, **kwargs)
builtin_models(**params)

List all BuiltIn Models.

Parameters:

params (dict) – Optional query parameters to be sent to limit the built-in models being returned.

Returns:

a generator of BuiltInModel instances.

find_builtin_model(name_or_id, ignore_missing=True)

Find a single built-in model.

Parameters:
  • name_or_id – The name or ID of a built-in model

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised if the model does not exist. When set to True, no exception will be set when attempting to find a nonexistent built-in model.

Returns:

One BuiltInModel or None.

Model Operations

class otcextensions.sdk.modelartsv1.v1._proxy.Proxy(session, *args, **kwargs)
models(**params)

List all Models.

Parameters:

params (dict) – Optional query parameters to be sent to limit the models being returned.

Returns:

a generator of Model instances.

create_model(**attrs)

Create a model from attributes.

Parameters:

attrs (dict) – Keyword arguments which will be used to create a Model, comprised of the properties on the Model class.

Returns:

The results of model creation.

Return type:

Model

get_model(model)

Get details of a model by Id.

Parameters:

model – model id or an instance of Model

Returns:

instance of Model

find_model(name_or_id, ignore_missing=True)

Find a single model.

Parameters:
  • name_or_id – The name or ID of a model.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised if the model does not exist. When set to True, no exception will be set when attempting to find a nonexistent model.

Returns:

One Model or None.

delete_model(model, ignore_missing=False)

Delete a model.

Parameters:
  • model – model id or an instance of Model

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the model does not exist. When set to True, no exception will be set when attempting to delete a nonexistent model.

Returns:

None

Service Operations

class otcextensions.sdk.modelartsv1.v1._proxy.Proxy(session, *args, **kwargs)
services(**params)

List all Services.

Parameters:

params (dict) – Optional query parameters to be sent to limit the services being returned.

Returns:

a generator of Service instances

create_service(**attrs)

Deploy a modelarts service from attributes.

Parameters:

attrs (dict) – Keyword arguments which will be used to create a Service, comprised of the properties on the Service class.

Returns:

The result of service creation.

Return type:

Service

delete_service(service, ignore_missing=False)

Delete a modelarts service.

Parameters:
  • service – service id or an instance of Service

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the service does not exist. When set to True, no exception will be set when attempting to delete a nonexistent service.

Returns:

None

get_service(service)

Get details of a modelarts service.

Parameters:

service – service id or an instance of Service

Returns:

instance of Service

find_service(name_or_id, ignore_missing=True)

Find a single service

Parameters:
  • name_or_id – The name or ID of a ModelArts service

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised if the service does not exist. When set to True, no exception will be set when attempting to find a nonexistent service.

Returns:

instance of Service

update_service(service, **attrs)

Update a Service Configurations.

Parameters:
  • service – service id or an instance of Service

  • attrs (dict) – Keyword arguments which will be used to update a Service, comprised of the properties on the Service class.

Returns:

instance of Service

start_service(service)

Start a Service.

Parameters:

service – service id or an instance of Service

Returns:

instance of Service

stop_service(service)

Stop a Service.

Parameters:

service – service id or an instance of Service

Returns:

instance of Service

service_logs(service, **params)

List update logs of a real-time service.

Parameters:
  • service – service id or an instance of Service

  • params (dict) – Optional query parameters to be sent to limit the service logs being returned.

Returns:

a generator of ServiceLog instances

service_events(service, **params)

List events logs of a service.

Parameters:
  • service – service id or an instance of Service

  • params (dict) – Optional query parameters to be sent to limit the service events being returned.

Returns:

a generator of ServiceEvent instances

service_monitor(service, **params)

List a service monitoring informations.

Parameters:

service – service id or an instance of Service

Returns:

a generator of ServiceMonitor instances

service_flavors(**params)

List all flavors for a service deployment.

Parameters:

params (dict) – Optional query parameters to be sent to limit the service flavors being returned.

Returns:

a generator of ServiceFlavor instances

service_clusters(**params)

List all dedicated resource pools (clusters) available for a service deployment.

Parameters:

params (dict) – Optional query parameters to be sent to limit the service clusters being returned.

Returns:

a generator of ServiceCluster instances

Training Job Operations

class otcextensions.sdk.modelartsv1.v1._proxy.Proxy(session, *args, **kwargs)
training_jobs(**params)

List all training jobs.

Parameters:

params (dict) – Optional query parameters to be sent to limit the training jobs being returned.

Returns:

a generator of TrainingJob instances

create_training_job(**attrs)

Create a training job from attributes.

Parameters:

attrs (dict) – Keyword arguments which will be used to create a TrainingJob, comprised of the properties on the TrainingJob class.

Returns:

The results of training job creation.

Return type:

TrainingJob

find_training_job(name_or_id, ignore_missing=True)

Find a single training job by name or Id.

Parameters:
  • name_or_id – The name or ID of a modelarts training job

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised if the trainjob does not exist. When set to True, no exception will be set when attempting to find a nonexistent trainjob.

Returns:

instance of TrainingJob or None

update_training_job(training_job, description)

Update training job description.

Parameters:
  • training_job – training job id or an instance of TrainingJob

  • description – Description of a training job.

Returns:

instance of TrainingJob

delete_training_job(training_job, ignore_missing=False)

Delete a training job

Parameters:
  • training_job – training job id or an instance of TrainingJob

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the training_job does not exist. When set to True, no exception will be set when attempting to delete a nonexistent training job.

returns: None

Training Job Config Operations

class otcextensions.sdk.modelartsv1.v1._proxy.Proxy(session, *args, **kwargs)
training_job_configs(**params)

List all training job configurations.

Parameters:

params (dict) – Optional query parameters to be sent to limit the training job configs being returned.

Returns:

a generator of (TrainingjobConfig) instances.

create_training_job_config(**attrs)

Create a Training Job Configuration from attributes.

Parameters:

attrs (dict) – Keyword arguments which will be used to create a TrainingjobConfig, comprised of the properties on the TrainingJobConfig class.

Returns:

The results of Training Job Configuration creation.

Return type:

TrainingJobConfig

get_training_job_config(name)

Get the Training Job Configuration by config name.

Parameters:

name – Name of a training job configuration.

Returns:

instance of TrainingJobConfig.

update_training_job_config(name, **attrs)

Update training job configuration.

Parameters:
  • name – Name of a training job configuration.

  • attrs (dict) – Keyword arguments which will be used to update a TrainingJobConfig, comprised of the properties on the class.

Returns:

instance of TrainingJobConfig.

delete_training_job_config(name, ignore_missing=False)

Delete Training Job Configuration.

Parameters:
  • name – Name of a training job configuration.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the config does not exist. When set to True, no exception will be set when attempting to delete a nonexistent Training Job Configuration.

returns: None

Training Job Version Operations

class otcextensions.sdk.modelartsv1.v1._proxy.Proxy(session, *args, **kwargs)
training_job_versions(training_job, **attrs)

List versions of a training job.

Parameters:
  • training_job – training job id or an instance of TrainingJob

  • params (dict) – Optional query parameters to be sent to limit the training job versions being returned.

Returns:

a generator of TrainingJobVersion instances.

get_training_job_version(training_job, version)

Get details of a training job by version id.

Parameters:
  • training_job – training job id or an instance of TrainingJob

  • version – training job version id or an instance of TrainingJobVersion

Returns:

instance of TrainingJobVersion

create_training_job_version(training_job, **attrs)

Create a training job from attributes

Parameters:
  • training_job – training job id or an instance of TrainingJob

  • attrs (dict) – Keyword arguments which will be used to create a Trainjob, comprised of the properties on the Trainjob class.

Returns:

The results of trainjobs creation

Return type:

TrainingJobVersion

delete_training_job_version(training_job, version, ignore_missing=False)

Delete a training job version.

Parameters:
  • training_job – training job id or an instance of TrainingJob

  • version – training job version id or an instance of TrainingJobVersion

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the training job version does not exist. When set to True, no exception will be set when attempting to delete a nonexistent training job version.

returns: None

stop_training_job_version(training_job, version)

Stop a training job version.

Parameters:
  • training_job – training job id or an instance of TrainingJob

  • version – training job version id or an instance of TrainingJobVersion

Return type:

TrainingJobVersion

Visualization Job Operations

class otcextensions.sdk.modelartsv1.v1._proxy.Proxy(session, *args, **kwargs)
visualization_jobs(**params)

List all Visualization Jobs.

Parameters:

params (dict) – Optional query parameters to be sent to limit the visualization jobs being returned.

Returns:

a generator of VisualizationJob instances.

create_visualization_job(**attrs)

Create a Visualization Job from attributes.

Parameters:

attrs (dict) – Keyword arguments which will be used to create a VisualizationJob comprised of the properties on the Visualization Job class.

Returns:

The results of Visualization Job creation.

Return type:

VisualizationJob.

get_visualization_job(visualization_job)

Get details of a Visualization Job.

Parameters:

visualization_job – visualization job id or an instance of VisualizationJob.

Returns:

instance of VisualizationJob.

update_visualization_job(visualization_job, description)

Update visualization job description.

Parameters:
  • visualization_job – visualization job id or an instance of VisualizationJob.

  • description – Description of a visualization job to update.

Returns:

instance of VisualizationJob

delete_visualization_job(visualization_job, ignore_missing=False)

Delete a Visualization Job

Parameters:
  • visualization_job – visualization job id or an instance of VisualizationJob.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the group does not exist. When set to True, no exception will be set when attempting to delete a nonexistent Visualization Job.

returns: None

stop_visualization_job(visualization_job)

Stop a Visualization Job.

Parameters:

visualization_job – visualization job id or an instance of VisualizationJob.

Returns:

instance of VisualizationJob.

restart_visualization_job(visualization_job)

Restart a Visualization Job.

Parameters:

visualization_job – visualization job id or an instance of VisualizationJob.

Returns:

instance of VisualizationJob.

The ModelartsV2 Service Class

The modelarts high-level interface is available through the modelartsv2 member of a Connection object. The modelartsv2 member will only be added if the otcextensions.sdk.register_otc_extensions(conn) method is called.

Dataset Operations

class otcextensions.sdk.modelartsv2.v2._proxy.Proxy(session, *args, **kwargs)
datasets(**params)

List all Datasets.

Parameters:

params (dict) – Optional query parameters to be sent to limit the datasets being returned.

Returns:

A generator of (Dataset) instances.

create_dataset(**attrs)

Create a dataset from attributes.

Parameters:

attrs (dict) – Keyword arguments which will be used to create a Dataset, comprised of the properties on the Dataset class.

Returns:

The result of dataset creation.

Return type:

Instance of Dataset.

get_dataset(dataset)

Query details of a dataset.

Parameters:

dataset – Dataset id or an instance of Dataset.

Returns:

Instance of Dataset.

find_dataset(name_or_id, ignore_missing=True)

Find a dataset by name or id.

Parameters:
  • name_or_id – The name or ID of a dataset.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the dataset does not exist. When set to True, no exception will be set when attempting to find a nonexistent dataset.

Returns:

Instance of Dataset.

update_dataset(dataset, **attrs)

Get details of a dataset.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • attrs (dict) – Keyword arguments which will be used to update a Dataset, comprised of the properties on the Dataset class.

Returns:

Instance of Dataset.

delete_dataset(dataset, ignore_missing=False)

Delete a dataset.

Parameters:
  • dataset – Dataset id or an instance of Dataset.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the dataset does not exist. When set to True, no exception will be set when attempting to delete a nonexistent dataset.

returns: None

Dataset Label Operations

class otcextensions.sdk.modelartsv2.v2._proxy.Proxy(session, *args, **kwargs)
dataset_labels(dataset, **params)

List all Labels in a dataset.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • params (dict) – Optional query parameters to be sent to limit the instances being returned.

Returns:

A generator of (DatasetLabel) instances.

create_dataset_label(dataset, **attrs)

Create a dataset label from attributes.

Parameters:
  • dataset – Dataset id or an instance of Dataset.

  • attrs (dict) – Keyword arguments which will be used to create a DatasetLabel, comprised of the properties on the DatasetLabel class.

Returns:

The results of label creation.

Return type:

Instance of DatasetLabel.

update_dataset_labels(dataset, labels=[], **attrs)

Modify dataset labels in batches.

Parameters:
  • dataset – Dataset id or an instance of Dataset.

  • labels – List of Labels to update.

  • attrs (dict) – Keyword arguments which will be used to update a DatasetLabel, comprised of the properties on the DatasetLabel class.

Returns:

Instance of DatasetLabel

delete_dataset_labels(dataset, labels=[], delete_policy=None, **attrs)

Delete dataset labels in batches.

Parameters:
  • dataset – Dataset id or an instance of Dataset.

  • labels – List of labels dict to delete.

  • attrs (dict) – Keyword arguments which will be used to delete a DatasetLabel, comprised of the properties on the DatasetLabel class.

Returns:

None

Dataset Version Operations

class otcextensions.sdk.modelartsv2.v2._proxy.Proxy(session, *args, **kwargs)
delete_dataset_labels(dataset, labels=[], delete_policy=None, **attrs)

Delete dataset labels in batches.

Parameters:
  • dataset – Dataset id or an instance of Dataset.

  • labels – List of labels dict to delete.

  • attrs (dict) – Keyword arguments which will be used to delete a DatasetLabel, comprised of the properties on the DatasetLabel class.

Returns:

None

dataset_versions(dataset, **params)

List all versions of a dataset.

Parameters:

dataset – Dataset id or an instance of Dataset.

Returns:

a generator of (DatasetVersion) instances.

create_dataset_version(dataset, **attrs)

Create a dataset version from attributes.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • attrs (dict) – Keyword arguments which will be used to create a DatasetVersion, comprised of the properties on the DatasetVersion class.

Returns:

The results of dataset creation.

Return type:

Instance of DatasetVersion.

get_dataset_version(dataset, dataset_version)

Get details of a dataset version.

Parameters:
  • dataset – Dataset id or an instance of Dataset.

  • dataset_version – Dataset version id or an instance of DatasetVersion.

Returns:

Instance of DatasetVersion.

Dataset Sample Operations

class otcextensions.sdk.modelartsv2.v2._proxy.Proxy(session, *args, **kwargs)
dataset_samples(dataset, **params)

List all samples in a Dataset.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • params (dict) – Optional query parameters to be sent to limit the dataset samples being returned.

Returns:

a generator of (DatasetSample) instances.

add_dataset_samples(dataset, directory_path=None, file_path=None, sample_type=None, labels=[], metadata={}, data_source={})

Upload samples to a dataset.

Parameters:
  • dataset – Dataset id or an instance of Dataset.

  • attrs (dict) – Keyword arguments which will be used to create upload samples to a dataset and obtain instance of a DatasetSample # noqa: E501

Returns:

The result after uploading the dataset samples.

Return type:

Instance of DatasetSample.

delete_dataset_samples(dataset, samples=[], delete_source=False)

Delete dataset samples in batches.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • samples – List of sample ID(s) to delete.

  • delete_source (bool) – When set to True sample source files will be also deleted.

Returns:

None

get_dataset_sample(dataset, dataset_sample)

Get details of the dataset sample.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • dataset_sample – Dataset sample id or an instance of DatasetSample

Returns:

Instance of DatasetSample

Dataset Import Task Operations

class otcextensions.sdk.modelartsv2.v2._proxy.Proxy(session, *args, **kwargs)
dataset_import_tasks(dataset, **params)

List all dataset import tasks.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • params (dict) – Optional query parameters to be sent to limit the dataset import tasks being returned.

Returns:

A generator of (DatasetImportTask).

create_dataset_import_task(dataset, **attrs)

Create a data import task from attributes.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • attrs (dict) – Keyword arguments which will be used to create a DatasetImportTask, comprised of the properties on the DatasetImportTask class.

Returns:

The results of dataset import task.

Return type:

Instance of DatasetImportTask.

get_dataset_import_task(dataset, import_task)

Get details of a dataset import task.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • import_task – Import task id or an instance of DatasetImportTask.

Returns:

Instance of DatasetImportTask.

Dataset Export Task Operations

class otcextensions.sdk.modelartsv2.v2._proxy.Proxy(session, *args, **kwargs)
dataset_export_tasks(dataset, **params)

List all dataset export tasks.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • params (dict) – Optional query parameters to be sent to limit the dataset export tasks being returned.

Returns:

A generator of (DatasetExportTask) instances.

create_dataset_export_task(dataset, **attrs)

Create a data import task from attributes.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • attrs (dict) – Keyword arguments which will be used to create a DatasetExportTask, comprised of the properties on the DatasetExportTask class.

Returns:

The results of dataset export task.

Return type:

Instance of DatasetExportTask.

get_dataset_export_task(dataset, export_task)

Get details of a dataset export task.

Parameters:
  • dataset – Dataset id or an instance of Dataset

  • export_task – Export Task id or an instance of DatasetExportTask.

Returns:

Instance of DatasetExportTask.

Dataset Sync Operations

class otcextensions.sdk.modelartsv2.v2._proxy.Proxy(session, *args, **kwargs)
dataset_sync(dataset)
Synchronize samples and labeling information

from the input dataset path to the dataset.

Parameters:

dataset – Dataset id or an instance of Dataset.

Returns:

Instance of DatasetSync.

get_dataset_sync_status(dataset)

Query Dataset sync task status.

Parameters:

dataset – Dataset id or an instance of Dataset.

Returns:

Instance of DatasetSync.