Add Packages to the Package Management Environment¶
-
POST
/api/v1.2/package/<env ID>/add_packages
¶
Use this API to add Python and R packages to a Package Management environment. A newly created environment supports the conda-forge channel which supports more packages. Viewing the List of Pre-installed Python and R Packages provides the list of pre-installed packages. Questions about Package Management provides answers to questions related to adding packages.
Note
In addition to the default Conda package repo, you can also add only R packages from the CRAN package repo. For more information, see Using the Default Package Management UI.
Required Role¶
The following users can make this API call:
- Users who belong to the system-admin or system-user group.
- Users who belong to a group associated with a role that allows updating an environment. See Managing Groups and Managing Roles for more information.
Parameters¶
Note
Parameters marked in bold are mandatory. Others are optional and have default values.
Parameter | Description |
---|---|
source_type | Only Python and R packages can be added. Specify python_package or r_package and it is
mandatory while adding packages through an environment. |
package_names | Specify the name of the package. If you just specify the name, the latest version of the
package gets installed. To install a specific version of the package, specify it in this
format: <packagename>==<version-number> . For example, biopython==0.1 . You can add any
number of packages as a comma-separated list. |
repo_url | You must set this parameter to https://cran.r-project.org\ only when you want to add the R
package from the CRAN package repo. |
Request API Syntax¶
curl -X POST -H "X-AUTH-TOKEN: <API-TOKEN>" -H "Content-Type: application/json" -H "Accept: application/json" \
-d ' {"source_type": "<package type>", "package_names": "<packagename1>,<packagename2>,....,<packagenameN>"}' \
"https://gcp.qubole.com/api/v1.2/package/<envID>/add_packages"
Sample API Requests¶
Note
If you upgrade or downgrade a Python package, the changed version is reflected only after you restart the Spark interpreter. Interpreter Operations lists the restart and other Spark interpreter operations.
Here is a sample API call for adding Python packages to an environment that has 100 as its ID.
curl -X POST -H "X-AUTH-TOKEN: <API-TOKEN>" -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"source_type": "python_package", "package_names": "numpy,bipython==0.1,tensorflow"}' \
"https://gcp.qubole.com/api/v1.2/package/100/add_packages"
Here is a sample API call for adding R packages to an environment that has 100 as its ID.
curl -X POST -H "X-AUTH-TOKEN: <API-TOKEN>" -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"source_type": "r_package", "package_names": "r-rserve,r-brew==1.0"}' \
"https://gcp.qubole.com/api/v1.2/package/100/add_packages"
Here is a sample API call for adding a R package from the CRAN package repo to an environment that has 100 as its ID.
curl -X POST -H "X-AUTH-TOKEN: <API-TOKEN>" -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"source_type": "r_package", "repo_packages": "[ {\"name\": \"RMySQL\", \"repo_url\": \"https://cran.r-project.org\"}]" }' \
"https://gcp.qubole.com/api/v1.2/package/100/add_packages"