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.
Adding code packages to a deployment space
To use code packages in a deployment space, you must create a ZIP file with one or more files or directories. These can be files that you created in JupyterLab or RStudio in Cloud Pak for Data or from files that you created elsewhere, for example using PyCharm on your local machine. Depending on how the code package was created, you can then use the CPDCTL command-line interface or import them directly into your space.
What is a code package
A code package is a way of organizing a set of dependent files in a folder structure. Each code package has a main executable file that in turn accesses other files in the code package. For example, a code package can contain a notebook file that calls other notebook files or functions in scripts in the folder structure in a notebook job. With code packages, you can start a job on a collection of dependent files and not on one file only.
Adding code packages to a deployment space
You cannot create a code package through the UI in projects or deployment spaces. To use code packages in a deployment space, you must create a ZIP file with one or more files or directories. These can be files that you created in JupyterLab or RStudio in Cloud Pak for Data or from files you created elsewhere, for example using PyCharm on your local machine.
After you create the ZIP file, to add a code package to your deployment space:
- Use the CPDCTL command-line interface to create a code package asset in a deployment space. Refer to Creating and registering code package assets by using CPDCTL.
- If you import an exported Git archive, for example a ZIP file that was created based on a project with default Git integration into a deployment space, the code package is automatically created. For more information refer to Importing assets into a deplyment space.
The code package asset contains all the code files that were archived in the ZIP file.
After the code package asset is created in your deployment space, to deploy it, create a new job, select the code package asset, and then run the files in the code package. For more details, refer to Creating jobs in deployment spaces. You can also deploy the code package programmatically by using CPDCTL commands in your CI/CD pipeline to create and run a job.
Creating and registering code package assets by using CPDCTL
To create a code package asset in a deployment space by using CPDCTL:
-
Commit/push any changes to the project that you are working on.
-
Create a ZIP archive that contains all the assets that you want to move to the deployment space.
-
Download, install and configure the CPDCTL command-line interface for your operating system. Refer to CPDCTL.
-
Enable the code package module in CPDCTL:
export CPDCTL_ENABLE_CODE_PACKAGE=1 -
Upload the ZIP file to the storage associated with the deployment space:
cpdctl asset file upload --path code_package/${FILE_NAME} --file ${LOCAL_FILE_PATH} --space-id ${SPACE_ID}Input parameters include:
- FILE_NAME: The name of the ZIP file in the storage associated with the deployment space
- LOCAL_FILE_PATH: The path to the ZIP file to be uploaded
- SPACE_ID: The ID of the deployment space
-
Create a code package in the deployment space:
cpdctl code-package create --file-reference code_package/${FILE_NAME} --name ${CODE_PACKAGE_NAME} --description ${CODE_PACKAGE_DESCRIPTION} --space-id ${SPACE_ID}Input parameters include:
- FILE_NAME: The name of the ZIP file in the storage associated with the deployment space
- CODE_PACKAGE_NAME: The name of the code package in the deployment space
- CODE_PACKAGE_DESCRIPTION: The description of the code package in the deployment space
- SPACE_ID: The ID of the deployment space
The ZIP file is added as a code package asset on the Assets page in your deployment space.
Useful links:
- Reference to more CPDCTL commands
- A Jupyter notebook example of how to create a code package with CPDCTL commands in a deployment space
Parent topic: Assets in deployment spaces