Created
December 6, 2024 19:18
-
-
Save tonio-m/dee704c40525e119f12b3b90b6411e7d to your computer and use it in GitHub Desktop.
create a repl inside a databricks cluster. for terminal development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from prompt_toolkit import prompt | |
| from databricks.sdk import WorkspaceClient | |
| from databricks.sdk.service import compute | |
| w = WorkspaceClient() | |
| cluster_id = 'existing-cluster-id' | |
| new_context = w.command_execution.create(cluster_id=cluster_id, language=compute.Language.python).result() | |
| while True: | |
| cmd = prompt("databricks>") | |
| response = w.command_execution.execute(cluster_id=cluster_id, context_id=new_context.id, language=compute.Language.python, command=cmd).result() | |
| print(response.results.data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment