Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misalignment between Databricks CLI and Databricks APIs - importing generic file to workspace #648

Open
luigibrancati opened this issue Jun 7, 2023 · 1 comment

Comments

@luigibrancati
Copy link

luigibrancati commented Jun 7, 2023

We use Databricks on Azure and have a few init scripts that are automatically deployed using Azure releases.

Following this announcement about vulnerabilities in init scripts, we decided to move our init scripts (bash scripts) from the DBFS to the Workspace. While doing so, we encountered a few issues:

  • There's no task on Azure releases to deploy anything but notebooks to the Databricks Workspace
  • The Databricks CLI command databricks workspace import can import only notebooks, since it requires the language option

We solved this falling back to using curl and directly calling the Databricks APIs. The API requires just a base64 string and the language field is optional.

Example code

# script.sh - Example
#!/bin/bash
pip install numpy

# Databricks CLI command - doesn't work
databricks workspace import ./script.sh /InitScripts/script.sh --language PYTHON --profile AZDO --overwrite

# Databricks API - works
export encoded=$(base64 ./script.sh -w 0)
curl --location '<workspace>/api/2.0/workspace/import' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{"format": "AUTO", "path": "/InitScripts/script.sh", "content": "'$encoded'", "overwrite": "true"}'
@luigibrancati
Copy link
Author

I think I can open a PR if this isn't intentional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant