Important:

IBM Cloud Pak® for Data Version 4.7 will reach end of support (EOS) on 31 July, 2025. For more information, see the Discontinuance of service announcement for IBM Cloud Pak for Data Version 4.X.

Upgrade to IBM Software Hub Version 5.1 before IBM Cloud Pak for Data Version 4.7 reaches end of support. For more information, see Upgrading IBM Software Hub in the IBM Software Hub Version 5.1 documentation.

Creating a script asset with CPDCTL in Watson Machine Learning

Learn to create a script asset with Cloud Pak for Data command-line interface (CPDCTL).

  1. Install the CPDCTL library.

    CPDCTL_VERSION = ""
    
    ! curl -L https://github.com/IBM/cpdctl/releases/download/{CPDCTL_VERSION}/cpdctl_linux_amd64.tar.gz --output cpdctl_linux_amd64.tar.gz
    

    Check for the available Cloud Pak for Data versions on the GitHub releases page.

  2. Extract downloaded archive.

    ! tar xzf cpdctl_linux_amd64.tar.gz
    
  3. Ensure that the cpdctl archive is in the current working directory and the system PATH.

    %%capture
    %env PATH={CWD}:{PATH}
    
  4. Check that CLI is accessible.

    ! cpdctl version
    
  5. Optional: The following steps are not required if you are running the script in a Cloud Pak for Data environment runtime.

    URL = "<<your cluster URL>>"
    USERNAME = "<<CPD user name>>"
    APIKEY = "<<CPD user API key>>"
    
    ! cpdctl config context cpd-demo --url {URL} --username {USERNAME} --apikey {APIKEY}
    
    project_id = os.getenv('PROJECT_ID')
    
  6. Open your script.

    with open('<test_script>', 'w') as f:
        f.write("echo OK")
    
  7. Create the new script asset.

    ! cpdctl asset script create --file <test_script> --project-id {project_id}
    

    When you run this line of code, you receive the asset ID in its output.

  8. List the script asset in the project.

    ! cpdctl asset search --type-name script --query 'test.sh' --project-id {project_id}
    
  9. Optional: You can delete the script with the following code.

    SCRIPT_ASSET_ID = ""
    
    ! cpdctl asset delete --asset-id {SCRIPT_ASSET_ID} --project-id {project_id}
    

Parent topic: Managing AI lifecycle with CPDCTL