Path: blob/main/L4assets/DSandMLOpsAssets/CLIandSDK/Notebooks/CPDall-03 Project Management.ipynb
1928 views
Project management
This notebook should be run on the platform of your choice.
The functionality demonstrated are:
Load support functions using the
ibm_watson_studio_liblibraryList available projects
Get the current project information and display it
List possible project asset types
List assets: data_asset, notebook, connection
Read a CSV file (make sure you have a csv file in your current project)
Write a file to the current project
Remove the newly created file from the current project
Make sure to set the variables in the next cell
For Cloud Pak for data (CPD):
Set the
cpd_urlvalue to the endpoint for your CPD clusterSet the
API_keyto the API key for your user
For Cloud Pak for Data as a Service (CPDaaS):
set
cpd_urltohttps://api.dataplatform.cloud.ibm.com/Set the
API_keyto the API key for your user
Get an access token
We have a chicken and egg problem here: we need the support functions to get the token but we need the token to use the support function. To solve the problem, we define the support function we need before we loadd all the support functions.
An access token is used to identify a user in API requests. Note that the token becomes invalid after an hour and must be re-created.
Create a bearer (access) token
Support functions
On CPSaaS, get the details of the API key
List available projects
Get the current project
Working with assets in the project
Listing asset types
List some assets: files notebooks, connections
Read a CSV file
Earlier in the Noteboook, we read a zip file into a streaming body object using wslib.load_data.
You could write the streaming body object to a local file but it can be done with wslib.download_file
Then you can use the file as a local file. For example, you can read a csv file into a Pandas dataframe:
Write a file
Simply take an existing file and re-write it with another name.
If it is a local file, it can be uploaded with wslib.upload_file()
Remove a file from the project
The wslib function starts with "_" which usually indicate an internal function. No other functions are available.
Author
Jacques Roy is a member of the IBM Enablement for Data and AI
Copyright © 2023. This notebook and its source code are released under the terms of the MIT License.