Path: blob/master/cpd3.5/notebooks/rest_api/python/instance-management/Machine Learning artifacts management.ipynb
6405 views
Machine Learning artifacts management
This notebook contains steps and code to demonstrate how to manage and clean up Watson Machine Learning instance. This notebook contains steps and code to work with Watson Machine Learning API. This notebook introduces API calls for listing artifacts, getting artifacts details and deleting them.
Some familiarity with Python and REST API is helpful. This notebook uses Python 3.
Learning goals
The learning goals of this notebook are:
List Watson Machine Learning artifacts.
Get artifacts details.
Delete artifacts.
Contents
This notebook contains the following parts:
Connection to WML
Authenticate the Watson Machine Learning service on IBM Cloud Pack for Data. You need to provide platform url
, your username
and password
.
In order to work with REST API in python you need to import requests
package.
Request params preparation.
Token generation.
Define requests header for futher REST API calls.
Prepare payload json for space creation.
Create new space.
Get created space id.
Space creation is asynchronous. This means that you need to check space creation status after creation call. Make sure that your newly created space is active
.
Get space details.
Managing spaces.
If you want to get all spaces details you can run following REST API call. If you want to get part of spaces please change the limit
variable.
Print spaces details json.
If you want to list existing spaces names and ids run next cell.
If you want to delete one of existing spaces you can change next cell Format to code
and use following REST API call.
If you want to get all pipelines details you can run following REST API call. If you want to get part of pipelines please change the limit
variable.
If you want to list existing pipelines names and ids run next cell.
Get pipeline 0 id.
If you want to get pipeline details you must provide pipeline_id
and run following REST API call.
Print pipeline details.
You can delete pipeline by next cell API CALL.
If you want to delete more pipelines run following cell.
If you want to get all model definitions details you can run following REST API call. If you want to get part of model definitions please change the limit
variable.
If you want to list existing model definitions names and ids run next cell.
Get model definition 0 id.
If you want to get model definition details you must provide model_definition_id
and run following REST API call.
Print model definition details.
You can delete model definition by next cell API CALL.
If you want to delete more model definitions run following cell.
If you want to get all models details you can run following REST API call. If you want to get part of models please change the limit
variable.
In order to filter models by software specification you can paste software specification id to the software_spec
field.
If you want to list existing models names and ids run next cell.
Get model 0 id.
If you want to get model details you must provide model_id
and run following REST API call.
Print model details.
If you want to get model revision you must provide model_id
and run following REST API call.
Print model revision.
You can delete model by next cell API CALL.
If you want to delete more models run following cell.
If you want to get all functions details you can run following REST API call. If you want to get part of functions please change the limit
variable.
If you want to list existing functions names and ids run next cell.
Get function 0 id.
If you want to get function details you must provide function_id
and run following REST API call.
Print function details.
You can delete function by next cell API CALL.
If you want to delete more functions run following cell.
If you want to get all experiments details you can run following REST API call. If you want to get part of experiments please change the limit
variable.
If you want to list existing experiments names and ids run next cell.
Get experiment 0 id.
If you want to get experiment details you must provide experiment_id
and run following REST API call.
Print experiment details.
You can delete experiment by next cell API CALL.
If you want to delete more experiments change run following cell.
If you want to get all trainings details you can run following REST API call. If you want to get part of trainings please change the limit
variable.
In order to filter trainings by the training type (e.g. pipeline, experiment) please change training_type
variable and run next cell.
If you want to list existing trainings tags and ids run next cell.
Get training 0 id.
If you want to get training details you must provide training_id
and run following REST API call.
Print training details.
You can delete training by next cell API CALL.
Note: DELETE
CALL has parameter hard_delete
, please change it as fallows:
'true' - to delete the completed or canceled training runs.
'false' - to cancel the currently running training run.
If you want to get all deployments details you can run following REST API call. If you want to get part of deployments please change the limit
variable.
If you want to list existing deployments names and ids run next cell.
Get deployment 0 id.
If you want to get deployment details you must provide deployment_id
and run following REST API call.
Print deployment details.
You can delete deployment by next cell API CALL.
If you want to delete more deployments run following cell.
You successfully completed this notebook! You learned how to use REST API client for Watson Machine Learning instance management and clean up.
Check out our Online Documentation for more samples, tutorials, documentation, how-tos, and blog posts.
Authors
Szymon Kucharczyk, Software Engineer at IBM.
Copyright © 2020-2025 IBM. This notebook and its source code are released under the terms of the MIT License.