-
Notifications
You must be signed in to change notification settings - Fork 8
Build data ingestion infrastructure for Databricks notebook #51
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
Open
awaismirza92
wants to merge
4
commits into
master
Choose a base branch
from
50-data-ingestion-for-databricks-notebook
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,5 +150,7 @@ dmypy.json | |
|
|
||
| # generated | ||
| *_spark/ | ||
| metastore_db/ | ||
| spark-warehouse/ | ||
| *_pipeline/ | ||
| .vscode/ | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Integration modules for connecting getML with external platforms.""" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| # Databricks Data Integration | ||
|
|
||
| This directory contains modules for ingesting data from GCS into Databricks Delta Lake and preparing population tables for getML feature engineering. | ||
|
|
||
|
|
||
| ## Prerequisites | ||
|
|
||
| - **Python 3.12** | ||
| - **Databricks Free Edition account** (or higher tier) | ||
| - **Databricks CLI** installed | ||
|
|
||
| ## Setup | ||
|
|
||
| ### 1. Install Databricks CLI | ||
|
|
||
| ```bash | ||
| # macOS | ||
| brew install databricks/tap/databricks | ||
|
|
||
| # Linux & macOS & Windows | ||
| curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sh | ||
| ``` | ||
|
|
||
| More: https://docs.databricks.com/gcp/en/dev-tools/cli/install | ||
|
|
||
| ### 2. Install Dependencies with uv | ||
|
|
||
| > [!IMPORTANT] | ||
| > The `databricks` dependency group uses `databricks-connect`, which **cannot be installed alongside `pyspark`**. These packages are mutually exclusive. If you need local Spark execution (e.g., for notebooks like `imdb.ipynb`), use `uv run --group spark --isolated` instead to run in a temporary isolated environment. | ||
|
|
||
| ```bash | ||
| # From the repository root | ||
| cd getml-demo | ||
|
|
||
| # Install uv if not already installed | ||
| pipx install uv | ||
|
|
||
| # Run jupyter lab after install dependencies included in the databricks group | ||
| $ uv run --group databricks jupyter-lab | ||
| ``` | ||
|
|
||
| ### 3. Authenticate with Databricks | ||
|
|
||
| ```bash | ||
| # Get your workspace URL from your Databricks Free Edition account | ||
| # It looks like: https://<workspace-id>.cloud.databricks.com | ||
|
|
||
| databricks auth login --host https://<your-workspace>.cloud.databricks.com | ||
| ``` | ||
|
|
||
| This will open a browser for OAuth authentication. After successful login, your credentials are cached locally. | ||
|
|
||
| ### 4. Verify Authentication | ||
|
|
||
| ```bash | ||
| databricks auth profiles | ||
| ``` | ||
|
|
||
| You should see your workspace listed. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Python API (Recommended) | ||
|
|
||
| Use the modules directly in notebooks or scripts: | ||
|
|
||
| ```python | ||
| from integration.databricks.data import ingestion, preparation | ||
|
|
||
| # Load raw data from GCS to Databricks | ||
| loaded_tables = ingestion.load_from_gcs( | ||
| bucket="https://static.getml.com/datasets/jaffle_shop/", | ||
| destination_schema="jaffle_shop" | ||
| ) | ||
| print(f"Loaded {len(loaded_tables)} tables") | ||
| ``` | ||
|
|
||
| ### Load Specific Tables | ||
|
|
||
| ```python | ||
| from integration.databricks.data import ingestion | ||
|
|
||
| # Load only the tables you need | ||
| ingestion.load_from_gcs( | ||
| destination_schema="RAW", | ||
| tables=["raw_customers", "raw_orders", "raw_items", "raw_products"] | ||
| ) | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Authentication Errors | ||
|
|
||
| ```bash | ||
| # Re-authenticate | ||
| databricks auth login --host https://<your-workspace>.cloud.databricks.com | ||
|
|
||
| # Check your profile | ||
| databricks auth env | ||
| ``` | ||
|
|
||
| ### Python Version Issues | ||
|
|
||
| Databricks serverless requires Python 3.12: | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Irrelevant troubleshooting - Python version belongs in pyproject.toml, not README. |
||
| ```bash | ||
| python --version # Should show 3.12.x | ||
|
|
||
| # If not, install Python 3.12 and recreate venv | ||
| brew install python@3.12 # macOS | ||
| ``` | ||
|
|
||
| ### Connection Timeout | ||
|
|
||
| Free Edition has limited compute resources. If you see timeouts: | ||
| - Wait a few minutes and retry (serverless cold start can take few seconds or minutes) | ||
| - Check your quota in the Databricks workspace | ||
|
|
||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Databricks integration for getML demos.""" |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
References non-existent module -
preparationdoesn't exist in this PR.