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

Update Databricks docs #3360

Open
AhdraMeraliQB opened this issue Nov 29, 2023 · 35 comments · Fixed by #4265
Open

Update Databricks docs #3360

AhdraMeraliQB opened this issue Nov 29, 2023 · 35 comments · Fixed by #4265
Assignees
Labels
Component: Documentation 📄 Issue/PR for markdown and API documentation Type: Parent Issue

Comments

@AhdraMeraliQB
Copy link
Contributor

AhdraMeraliQB commented Nov 29, 2023

Description

It looks like Databricks have deprecated their cli tools, which has had the knock on effect of breaking our docs. A quick fix in #3358 adds the necessary /archive/ to the broken links, but maybe we should rethink the section as a whole?

CC: @stichbury

docs: https://docs.kedro.org/en/stable/deployment/databricks/databricks_ide_development_workflow.html

Edit: See #3360 (comment) for current status of this parent issue

@astrojuanlu
Copy link
Member

And also dbx:

Databricks recommends that you use Databricks asset bundles instead of dbx by Databricks Labs. See What are Databricks asset bundles? and Migrate from dbx to bundles.

https://docs.databricks.com/en/archive/dev-tools/dbx/index.html

@astrojuanlu astrojuanlu changed the title Update docs that reference Databricks CLI Update docs that reference Databricks CLI and dbx Nov 29, 2023
@astrojuanlu astrojuanlu added the Component: Documentation 📄 Issue/PR for markdown and API documentation label Nov 29, 2023
@stichbury
Copy link
Contributor

I'll take a look at this in an upcoming sprint -- we did some updates for the asset bundles recently as suggested by Harmony.

@astrojuanlu astrojuanlu changed the title Update docs that reference Databricks CLI and dbx Update Databricks docs Dec 1, 2023
@astrojuanlu
Copy link
Member

Another couple of things I found in our Databricks workspace guide databricks_notebooks_development_workflow.md:

  • The first half of the guide, which tells users to set up a GitHub repository, a personal access token, push the code, then create a Databricks Repo, is not strictly needed: kedro new works fine on Databricks notebooks.
    • One has to be careful that the files are created in the Workspace, and not in the ephemeral driver storage. Depending on the runtime version, the default working directory is different, so a cd /Workspace/... might be needed.
  • "On Databricks, Kedro cannot access data stored directly in your project’s directory." this is not correct. From the docs:
    • "Spark cannot directly interact with workspace files on compute configured with shared access mode." however, clusters configured with Single User access mode should, and can, access workspace files.
    • However: “You can use Spark to read data files. You must provide Spark with the fully qualified path." https://learn.microsoft.com/en-us/azure/databricks/files/workspace-interact#read-data-workspace-files this means that spark.read.load("/Workspace/...") won't work (because it will assume dbfs:/), but spark.read.load("file:/Workspace/...") will.
      • Now, whether or not this can be incorporated in actual Kedro catalogs (in other words: whether or not our fsspec mangling will work on paths like these) is a different story. One can't just simply add file:/ in front of the dataset filepath, because then it will be taken as an absolute path and not a relative one.

It's true that creating a Databricks Repo synced with a GH repo gives some nice advantages, like being able to edit the code in an actual IDE (whether a local editor or a cloud development environment like Gitpod or GitHub Codespaces). And it's also true that Databricks recommends in different places that data should live in the DBFS root.

However, it would be nice to consider what's the shortest and simplest guide we can write for users to get started with Kedro on Databricks, and then build from there.

@astrojuanlu
Copy link
Member

To clarify on the initial comment:

Both things above require the Databricks CLI version 0.205 and above. Apart from that, the commands haven't changed, so what we should do in this regard is making sure we're not sending users to legacy docs and that's it.

@astrojuanlu
Copy link
Member

To summarise:

  • Replace references to DBFS and Jobs legacy CLI docs
  • Rewrite docs from dbx to Asset Bundles (migration guide)
  • Simplify Databricks notebooks guide to better serve as starting point for Kedro on Databricks

@stichbury
Copy link
Contributor

@astrojuanlu Is this something that the team can pick up or do we need to ask for time from Jannic or another databricks expert (maybe @deepyaman could ultimately review)?

What are we prioritising this? I'm guessing it's relatively high importance to keep databricks docs tracking with their tech.

@astrojuanlu
Copy link
Member

astrojuanlu commented Dec 19, 2023

We need to build Databricks expertise in the team, so I hope we don't need to ask external experts to do it (it's OK if they give assistance, but we need to own this).

@astrojuanlu
Copy link
Member

Added this to the Inbox so that we prioritise.

@deepyaman
Copy link
Member

@astrojuanlu Is this something that the team can pick up or do we need to ask for time from Jannic or another databricks expert (maybe @deepyaman could ultimately review)?

At this point, it's been almost 4 years since I've used Databricks (and don't currently have any interest in getting back into it), so I'd defer to somebody else. 🙂

@stichbury
Copy link
Contributor

More than fair enough @deepyaman! Good to confirm though.

@astrojuanlu
Copy link
Member

I'm adding one more item:

  • Document integration with Databricks Unity Catalog

Every time I give a talk or workshop, invariably somebody from the audience asks "how does the Kedro Catalog play along with Databricks Unity Catalog?".

Our reference docs for kedro-datasets mention it exactly once, in the API docs of pandas.DeltaTableDataset.

And there's one subtle mention of it in databricks.ManagedTableDataset ("the name of the catalog in Unity".

The broader question of Delta datasets is a topic for kedro-org/kedro-plugins#542.

@astrojuanlu
Copy link
Member

@felipemonroy
Copy link

Maybe this could help:
https://github.com/JenspederM/databricks-kedro-bundle

@astrojuanlu
Copy link
Member

This looks really cool. @JenspederM do you want to share a bit more insight on how far do you intend to go with your project?

@JenspederM
Copy link

JenspederM commented Jun 3, 2024

Hey @astrojuanlu

Actually I don't really know if there's more to do. I almost want the project to be as barebone as possible.

The way I left it now is with a very simple datasets implementation for unity so that people can customize as required.

As for the DAB resource generator, I'm considering if I could find a better way for users to set defaults such as which job clusters, instance pools, etc..

One thing that is generally lacking is the documentation so that will definitely receive some attention once I have the time.

Do you have any suggestions?

@astrojuanlu
Copy link
Member

However, it would be nice to consider what's the shortest and simplest guide we can write for users to get started with Kedro on Databricks, and then build from there.

I gave two Kedro on Databricks demos yesterday, so I'm sharing that very simple notebook here https://github.com/astrojuanlu/kedro-databricks-demo hopefully it can be the basis of what I proposed in #3360 (comment) (still no Kedro Framework there)

@astrojuanlu
Copy link
Member

Hey @astrojuanlu

Actually I don't really know if there's more to do. I almost want the project to be as barebone as possible.

The way I left it now is with a very simple datasets implementation for unity so that people can customize as required.

As for the DAB resource generator, I'm considering if I could find a better way for users to set defaults such as which job clusters, instance pools, etc..

One thing that is generally lacking is the documentation so that will definitely receive some attention once I have the time.

Do you have any suggestions?

@JenspederM I gave your kedro-databricks a quick try yesterday and it didn't work out of the box, so if you're open to me opening issues, I'll gladly start doing so 😄

@JenspederM
Copy link

@astrojuanlu Go for it!

I've been a bit busy these last few days and haven't had the chance to make any progress.

But it's always nice to have some concrete issues to address. 😉

@JenspederM
Copy link

@astrojuanlu Just fyi, I'll merge a quite big PR soon so hopefully that will address most issues that you found.

The substitution algorithm was a bit more cumbersome than first anticipated..

@noklam
Copy link
Contributor

noklam commented Sep 9, 2024

There is now a community plugin exists: https://github.com/JenspederM/kedro-databricks

We need to update the documentation according to the readme to walkthrough the steps to setup on Databricks.

@noklam
Copy link
Contributor

noklam commented Oct 15, 2024

To summarise:

  • Replace references to DBFS and Jobs legacy CLI docs[ ] Rewrite docs from dbx to Asset Bundles (migration guide)[ ] Simplify Databricks notebooks guide to better serve as starting point for Kedro on Databricks

This comment is also 10 months old. Do we want to mention the kedro-databricks plugin as the shortest path to experiment Kedro on Databricks? @astrojuanlu

Document integration with Databricks Unity Catalog

There is also a comment about UnityCatalog, is it in the scope of this ticket or should we separate this out? Not quite sure what should be done, maybe we can mention there are some databricks dataset that can work with UnityCatalog (Databricks platform version)

How do we think about the VSCode IDE Databricks

Do we want to mention it?

@astrojuanlu
Copy link
Member

Do we want to mention the kedro-databricks plugin as the shortest path to experiment Kedro on Databricks?

Yes!

There is also a comment about UnityCatalog, is it in the scope of this ticket or should we separate this out?

It's in the scope of this ticket because this is a parent ticket. No need to do everything in the same PR.

The key thing is that we explain clearly how the Kedro Catalog and Unity Catalog can be used together. Example: https://github.com/astrojuanlu/kedro-databricks-demo/blob/main/First%20Steps%20with%20Kedro%20on%20Databricks.ipynb

How do we think about the VSCode IDE Databricks

Do you mean https://docs.databricks.com/en/dev-tools/vscode-ext/index.html ? Not sure if there's anything Kedro-specific about that extension. We can discuss about that in another ticket.

@noklam
Copy link
Contributor

noklam commented Oct 16, 2024

@astrojuanlu

Do you mean https://docs.databricks.com/en/dev-tools/vscode-ext/index.html ? Not sure if there's anything Kedro-specific about that extension. We can discuss about that in another ticket.

Not directly, but it could be a better way to work with Databricks for the IDE experience. (no manual sync etc). Will keep this outside of the ticket.

Also, I think we should add new pages instead of just deleting the old one. I think there are still a significant amount of users are using dbx, we can recommend the new page and marked the old one as legacy.

@noklam
Copy link
Contributor

noklam commented Oct 27, 2024

Steps to use kedro-databricks

  1. Create starter kedro new -s databrick-iris
  2. Install databricks-cli curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sudo sh
  3. databricks configure copy link & create tokens
  4. Install kedro-databricks
  5. kedro databricks init #databricks.yml
  6. kedro databricks bundle
  7. kedro databricks deploy
  8. databricks bundle run or use the UI to trigger the job.

Notes

2024-10-25 13:59:33,723 - databrick_iris - INFO - Substituting DBFS paths: Checking conf/base/catalog.yml
2024-10-25 13:59:33,724 - databrick_iris - INFO - Substituting DBFS paths: Checking conf/local/catalog.yml
2024-10-25 13:59:33,724 - databrick_iris - WARNING - Substituting DBFS paths: conf/local/catalog.yml does not exist.

When I run kedro databricks init, I see these logs showing up. I am a bit nervous about updating user file directly. For new file it's fine. This Create the databricks.yml that is needed

kedro databricks bundle

This create the resource/databricks-iris.yml, wrapper around databricks bundle init

Uploading databrick_iris-0.1-py3-none-any.whl...
Uploading bundle files to /Workspace/Users/[email protected]/.bundle/databrick_iris/local/files...
Deploying resources...
Updating deployment state...
Deployment complete!

kedro databricks deploy

wrapper around databricks bundle deploy

Changes

  • The step to run a bundled job is not mentioned. Either through UI or using the databricks CLI directly with databricks bundle run

@JenspederM
Copy link

Yeah, I'm not too happy about having to change user paths either.

But what is done, is simply to check that paths that refer to dbfs use the correct package name.

This is mostly a legacy feature that helped developer experience with the old version of the starter, where dbfs paths were not aligned with the package name. Since that has now changed, I might also remove this from the init command.

@noklam
Copy link
Contributor

noklam commented Oct 28, 2024

@DimedS Do you want to take the rest of the docs as I am working on the data asset bundles ?

@DimedS
Copy link
Contributor

DimedS commented Oct 28, 2024

@DimedS Do you want to take the rest of the docs as I am working on the data asset bundles ?

Yes, I’m ready to take care of them. I just need to wrap up the synthesis of our deployment interviews. Four of them were about Databricks, and we identified four distinct ways people deploy there. I believe we’ll complete the Databricks synthesis in the next two days. After that, I’ll share my thoughts on updating the Databricks docs here and will start making updates once we align on the changes.

@noklam
Copy link
Contributor

noklam commented Oct 28, 2024

Just want to share some notes for my DAB deployment experience with our own internal infra, there are two options: 1. Azure, 2. AWS instance

With Azure Databricks (the more common one), everything works well until the step 8 (run job with CLI) because we don't have job cluster with the sandbox.

With AWS Databricks, we do have job cluster, but I get stuck even earlier at step 7 (kedro databricks deploy). After some investigation, it seems to related to permission issue. For some reason, I have permission to run a job, create a job through the UI but not with the CLI. I spent a good afternoon on it and decide it's not worth the effort to continue. This is the error that I see repeatly.

Error: exit status 1
Error: cannot read job: User [email protected] does not have Admin or Manage Run or Owner or View permissions on job 1111051477632764

To proceed, I will go with the Azure Databricks option, and use the UI to run the job as the last step. I expect users will likely encounter cryptic error message related to security/permission. I am not sure what kind of help we can provide other

@DimedS
Copy link
Contributor

DimedS commented Oct 31, 2024

Hi, I'd like to share a part of synthesis of our recent interviews with four users who deploy projects to Databricks. In the following diagram, I’ve outlined their user flows, highlighting the main steps for deploying to Databricks. While there are many similarities, certain parts of the process differ.

Screenshot 2024-10-31 at 09 50 28

As you can see, the overall workflow is quite similar across users, but there are a few points where multiple options are available. I believe adding a diagram like this to our main Databricks documentation page (https://docs.kedro.org/en/stable/deployment/databricks/index.html) would be helpful. It could provide a concise overview of the steps required to deploy code and the various options for each step. This approach would be more efficient than detailing each complete workflow as we currently do.

For instance, these two pages:

currently overlap by about 50%. Instead, we could focus on describing specific differences and options at each step, such as:

  1. Transferring Project Code to Databricks:

    • Using the Databricks asset bundle
    • Manually syncing the repository
    • Using the VSCode plugin
  2. Running Kedro on Databricks:

    • Via a packaged .whl file
    • Running code directly
    • Running code through a notebook
  3. Creating a Databricks Job to Schedule Runs:

    • Setting up manually
    • Using the Databricks asset bundle
    • Using the Kedro-Databricks plugin (and its advantages)
  4. Choosing the Right Cluster for Jobs:

    • Job cluster: Provides isolation but requires 5–10 minutes to start up
    • Existing cluster: Ready immediately but lacks isolation and can be costly to maintain 24/7

This structure would allow users to better understand the options available at each step without redundant information.

@astrojuanlu
Copy link
Member

This diagram is fantastic, and probably more useful than the current one we have.

Also +1 on trying to reduce overlap between the pages.

And finally, I noticed that some users didn't really want to kedro package their code, is that something you observed as well @DimedS ?

@DimedS
Copy link
Contributor

DimedS commented Oct 31, 2024

This diagram is fantastic, and probably more useful than the current one we have.

Also +1 on trying to reduce overlap between the pages.

And finally, I noticed that some users didn't really want to kedro package their code, is that something you observed as well @DimedS ?

Yes, from what I gathered, users didn’t find much benefit from packaging their projects - they only followed that approach because we recommended it. Some simplified the process and realised they could just upload code directly to their Databricks Repo, and they mentioned they don't need to package their projects. One user, Miguel, figured out that by specifying the notebook that runs the Kedro project within the Databricks Job deployment, he could use the same notebook during development, making debugging easier.

@noklam
Copy link
Contributor

noklam commented Nov 12, 2024

Do you plan to write these documentation, or it will be created as separate ticket from the current issue?

@noklam noklam linked a pull request Nov 12, 2024 that will close this issue
7 tasks
@astrojuanlu
Copy link
Member

astrojuanlu commented Nov 12, 2024

Another think we could try to document at some point is how to make use of the VS Code extension + databricks-connect. I tried and I got a MissingConfigException: Given configuration path either does not exist or is not a valid directory: /Workspace/Users/[email protected]/.bundle/kedro_databricks_playground/local/files/conf/local

image

And the workaround seems to be to do git add -f conf/local to un-ignore conf/local on .gitignore (see #2593).

@DimedS
Copy link
Contributor

DimedS commented Nov 12, 2024

Do you plan to write these documentation, or it will be created as separate ticket from the current issue?

I don’t think I proceed with it in the current sprint. Let’s create a new issue as a follow-up to the Databricks deployment research #4317. We can probably close current one after merging your PR, which transitions from dbx to Databricks asset bundles.

@github-project-automation github-project-automation bot moved this from In Review to Done in Kedro Framework Nov 26, 2024
@astrojuanlu astrojuanlu reopened this Nov 26, 2024
@github-project-automation github-project-automation bot moved this from Done to In Progress in Kedro Framework Nov 26, 2024
@astrojuanlu
Copy link
Member

Current status of this issue:

@astrojuanlu astrojuanlu moved this from In Progress to To Do in Kedro Framework Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Documentation 📄 Issue/PR for markdown and API documentation Type: Parent Issue
Projects
Status: To Do
Development

Successfully merging a pull request may close this issue.

9 participants