cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

examples on python sdk for install libraries

houstonamoeba
New Contributor III

Hi Everyone,

I'm planning to use databricks python cli "install_libraries"

can some one pls post examples on function install_libraries

https://github.com/databricks/databricks-cli/blob/main/databricks_cli/libraries/api.py

1 ACCEPTED SOLUTION

Accepted Solutions

houstonamoeba
New Contributor III

okay, i figured it out , here is the example

from databricks_cli.sdk.api_client import ApiClient

from databricks_cli.libraries.api import LibrariesApi

awsapi_client = ApiClient(

    host="********************",

    token="*******************",

)

awslibrary_api = LibrariesApi(awsapi_client)

awslibrary_api.install_libraries('0510-140152-aaaaaaaa', {'pypi': {'package': 'mlflow==2.2.2'}} )

View solution in original post

7 REPLIES 7

pvignesh92
Honored Contributor

@saiprasad ambati prabhakarโ€‹ Are you having any issues while installing that?

i dont have any issues with installation, im looking for examples to use the python function install_libraries , i want to install libraries via python sdk

artsheiko
Databricks Employee
Databricks Employee

databricks libraries install --cluster-id 1234-567890-lest123 --jar dbfs:/test-dir/test.jar

Doc : https://docs.databricks.com/dev-tools/cli/libraries-cli.html

hi @Artem Sheikoโ€‹ , im looking for python sdk example to install libraries in the cluster, pls let me know if you have any

โ€‹

here is the github link im following

โ€‹https://github.com/databricks/databricks-cli/blob/main/databricks_cli/libraries/api.py

brina
New Contributor II

Hello! I was able to install a library using python sdk - Task configuration. Please see the code below! Hope it helps! ๐Ÿ™‚ 

from databricks.sdk.service.jobs import Task
from databricks.sdk.service.compute import ( Library,
PythonPyPiLibrary,
)

Task(...<other config>,
     libraries=[Library(pypi=PythonPyPiLibrary(package="package_name==version"))],
)

 

houstonamoeba
New Contributor III

okay, i figured it out , here is the example

from databricks_cli.sdk.api_client import ApiClient

from databricks_cli.libraries.api import LibrariesApi

awsapi_client = ApiClient(

    host="********************",

    token="*******************",

)

awslibrary_api = LibrariesApi(awsapi_client)

awslibrary_api.install_libraries('0510-140152-aaaaaaaa', {'pypi': {'package': 'mlflow==2.2.2'}} )

Loop-Insist
New Contributor II

Here you go using Python SDK

from databricks.sdk import WorkspaceClient
from databricks.sdk.service import compute
w = WorkspaceClient(host="yourhost", token="yourtoken")

# Create an array of Library objects to be installed
libraries_to_install = [
compute.Library(pypi=compute.PythonPyPiLibrary(package="packagename==version")) # Specify the PyPi package
]

w.libraries.install(cluster_id="yourclusterid", libraries=libraries_to_install)

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group