Important:

IBM Cloud Pak® for Data Version 4.6 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.6 reaches end of support. For more information, see Upgrading IBM Software Hub in the IBM Software Hub Version 5.1 documentation.

Customizing with conda

Conda channels are the locations (URLs) where the libraries and packages are stored and from where packages can be downloaded at the time the the model is deployed.

The following formats exist for defining conda channels:

  • defaults: Specifies the default set of public channels which are automatically searched.
  • https://some.custom/channel: Enables specifying the entire URL of the respository channel, for example https://yoururl.com:port/conda/channel. This conda configuration format enables accessing private repositories.
  • file:///some/local/directory: Enables specifying a mounted network drive, including the path to the drive, by prepending with file:///. This format enables access to private repositories on file systems.

You can change the conda channel configuration to access private repositories by modifying the conda runtime configuration file .condarc which enables you to configure:

  • If and how to use a proxy server to access repositories
  • Channels where conda searches for packages

If you want to define a separate and secure network with fine-grained access control to library repositories, you can configure conda to use a binary repository manager, for example JFrog Artifactory, for library storage and access.

You can add conda packages by:

Required roles:

  • You must be a Cloud Pak for Data cluster administrator to modify the conda configuration file .condarc.
  • You need Admin or Editor permissions on the deployment space to create a custom software specification and package extension.

Configuring conda to use a proxy server

You can configure conda to use a proxy server as an intermediary to the public conda repositories. You can use a company proxy, or create a remote repository in a binary repository manager, which acts as a proxy to public conda resources. The conda configuration file .condarc can be used.

To configure conda for use behind a proxy server:

  1. Open the conda configuration .condarc file at /user-home/_global_/config/conda/.condarc. A conda configuration file is not available by default. If a .condarcdoesn't exist, create one. If you didn't created a .condarc file, omit the oc cp command in the following code snippet:

    ibm_nginx_pod=`oc get pods -l component=ibm-nginx -o jsonpath='{.items[0].metadata.name}'`
    oc cp ${ibm_nginx_pod}:/user-home/_global_/config/conda/.condarc /Users/<username>/
    
  2. Add the proxy_servers: key to the conda configuration .condarc file. Enter the URL to a company proxy server or a remote proxy server that you configured and created in a binary repository manager of your choice by using either the http or https protocol. The format is as follows:

    proxy_servers:
        http: http://username:password@corp.com:8080
        https: https://username:password@corp.com:8080
    

    For example:

    proxy_servers:
        https: https://u:a@127.0.0.1:8080
        http: http://u:a@127.0.0.1:8080
    
  3. Copy the modified .condarc file to /user-home/_global_/config/conda/:

    oc cp <path>/.condarc ${ibm_nginx_pod}:/user-home/_global_/config/conda/.condarc
    

    The proxy server is available for running notebooks and jobs.

  4. When a custom software specification and package extension has to be created by using the Watson Machine Learning Python client or REST APIs, create a package extension with conda.yaml specification as shown in the example and associate the package extension with customer software specification.
    Note:
    This step is not required when you have a custom environment created in Watson Studio and you have a model, Python function, or Python script associated with the same custom environment. In this case, the package extensions and software extensions are created together with the custom environment and the name of the custom software specification is same as the name of the custom environment.

Configuring conda to use a local repository

You can configure conda to use a local on-site repository server with fine-grained access control. With a local repository, you can also control which package versions to use to avoid library dependency conflicts when runtimes are started. You can create local repositories on company servers or in your binary repository manager to which the conda libraries and packages that you have selected are added.

To configure conda to use a local on-site repository:

  1. Open the conda configuration .condarc file at /user-home/_global_/config/conda/.condarc. A conda configuration file is not available by default. If you haven't created a .condarc file, omit the oc cp command in the following code snippet:

    ibm_nginx_pod=`oc get pods -l component=ibm-nginx -o jsonpath='{.items[0].metadata.name}'`
    oc cp ${ibm_nginx_pod}:/user-home/_global_/config/conda/.condarc /Users/<username>/
    
  2. Add the default channels that map to the local repository URL to the conda configuration .condarc file located in /user-home/_global_/config/conda/.condarc. Replace <your_local_repository_name> with the URL to a local repository that you connect to through a proxy server.

    channel_alias: http://<your_local_repository_name>:8080/conda/
    
    channels:
        - nodefaults
        - http://<your_local_repository_name>:8080/conda/anaconda
        - http://<your_local_repository_name>:8080/conda/wakari
        - http://<your_local_repository_name>:8080/conda/r-channel
    
  3. Copy the modified .condarc file to /user-home/_global_/config/conda/:

    oc cp <path>/.condarc ${ibm_nginx_pod}:/user-home/_global_/config/conda/.condarc
    
  4. When a custom software specification and package extension has to be created by using the Watson Machine Learning Python client or REST APIs, create a package extension with conda.yaml specification as shown in the example and associate the package extension with customer software specification.
    Note:
    This step is not required when you have a custom environment created in Watson Studio and you have a model, Python function, or Python script associated with the same custom environment. In this case, the package extensions and software extensions are created together with the custom environment and the name of the custom software specification is same as the name of the custom environment.

Configuring conda to use a file channel

You can make conda packages available through a file location by uploading them to the shared user_home directory from where the libraries can be accessed via a file:// URL.

To create a custom file channel:

  1. Build a conda package that bundles the software files into a single file that can be easily installed and managed. See the conda documentation for details about building packages.

  2. Create the custom channel folder and copy the package to the shared user_home directory:

    ibm_nginx_pod=`oc get pods -l component=ibm-nginx -o jsonpath='{.items[0].metadata.name}'`
    
    oc exec ${ibm_nginx_pod} -- mkdir -p "/user-home/_global_/config/conda/custom-channel"
    
    oc cp /Users/<username>/<locationOfPackage>  ${ibm_nginx_pod}:/user-home/_global_/config/conda/custom-channel
    
    oc exec ${ibm_nginx_pod} -- chmod -R a+r "/user-home/_global_/config/conda/custom-channel"
    
  3. Test that you can access this package (the conda seawater package) from a notebook cell:

    !conda search -c file:///user-home/_global_/config/conda/custom-channel --override-channels
    !conda install seawater -c file:///user-home/_global_/config/conda/custom-channel/custom_channel
    
  4. Create a package extension with conda.yaml specification as shown in the example and associate the package extension with customer software specification. Note that you must use nodefaults and not defaults for conda channels.

  5. If you don't want the file channel to be accessible by any user, you can alternatively point to a location in a storage volume in IBM Cloud Pak for Data that can only be accessed by certain users.

Parent topic: Customizing with third-party and private Python libraries