Skip to content

Commit 014dd77

Browse files
Mig assist deps (#247)
it now works when executing databricks labs sandbox sql-migration-assistant can test by running ```bash databricks labs install sandbox@mig-assist-deps && databricks labs sandbox sql-migration-assistant ```
1 parent 62947b6 commit 014dd77

10 files changed

+43
-36
lines changed

labs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ install:
44
script: install.py
55
description: Databricks Labs Sandbox
66
entrypoint: cli.py
7-
min_python: 3.8
7+
min_python: 3.10
88
commands:
99
- name: ip-access-list-analyzer
1010
description: "Analyzer/Fixer for Databricks IP Access Lists"

pyproject.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ version = "0.0.1"
44
description = "Experimental and low-maturity scripts"
55
authors = ["Databricks Labs"]
66
packages = [
7-
{include = "ip_access_list_analyzer"}
7+
{include = "ip_access_list_analyzer"},
8+
{include = "sql_migration_assistant"}
89
]
910

1011
[tool.poetry.dependencies]
11-
python = ">=3.8,<3.12"
12-
databricks-sdk = "^0.25.1"
12+
python = ">=3.10,<3.12"
13+
databricks-sdk = "0.30.0"
14+
pyyaml = "^6.0.2"
15+
mlflow = {extras = ["databricks"], version = "^2.16.0"}
16+
databricks-labs-blueprint = "0.8.2"
17+
databricks-labs-lsql = "0.9.0"
1318

1419
[build-system]
15-
requires = ["poetry-core>=1.0.0"]
20+
requires = [
21+
"poetry-core>=1.0.0"
22+
]
1623
build-backend = "poetry.core.masonry.api"

sql_migration_assistant/README.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ customise the application to their needs and entirely own the IP.
2929

3030
## Installation Videos
3131

32-
https://github.com/user-attachments/assets/b43372fb-95ea-49cd-9a2c-aec8e0d6700f
32+
33+
https://github.com/user-attachments/assets/e665bcf4-265f-4a47-81eb-60845a72c798
3334

3435
https://github.com/user-attachments/assets/fa622f96-a78c-40b8-9eb9-f6671c4d7b47
3536

@@ -38,27 +39,17 @@ https://github.com/user-attachments/assets/1a58a1b5-2dcf-4624-b93f-214735162584
3839

3940

4041
Setting Legion up is a simple and automated process. Ensure you have the [Databricks CLI]
41-
(https://docs.databricks.com/en/dev-tools/cli/index.html) installed and configured with the correct workspace. Install
42-
the [Databricks Labs Sandbox](https://github.com/databrickslabs/sandbox).
42+
(https://docs.databricks.com/en/dev-tools/cli/index.html) installed and configured with the correct workspace.
4343

44-
First, navigate to where you have installed the Databricks Labs Sandbox. For example
44+
Once the Databricks CLI has been installed and configured, run the following command to install the Databricks Labs
45+
Sandbox and the SQL Migration Assistant.
4546
```bash
46-
cd /Documents/sandbox
47-
```
48-
49-
You'll need to install the python requirements in the `requirements.txt` file in the root of the project.
50-
You may wish to do this in a virtual environment.
51-
```bash
52-
pip install -r sql-migration-assistant/requirements.txt -q
53-
```
54-
Run the following command to start the installation process, creating all the necessary resources in your workspace.
55-
```bash
56-
databricks labs sandbox sql-migration-assistant
47+
databricks labs install sandbox && databricks labs sandbox sql-migration-assistant
5748
```
5849

5950
### What Legion needs - during setup above you will create or choose existing resources for the following:
6051

61-
- A no-isolation shared cluster running the ML runtime (tested on DBR 15.0 ML) to host the front end application.
52+
- A no-isolation shared cluster to host the front end application.
6253
- A catalog and schema in Unity Catalog.
6354
- A table to store the code intent statements and their embeddings.
6455
- A vector search endpoint and an embedding model: see docs

sql_migration_assistant/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
from databricks.sdk import WorkspaceClient
33
from databricks.labs.blueprint.tui import Prompts
44
import yaml
5+
from pathlib import Path
56

67

78
def hello():
89
w = WorkspaceClient(product="sql_migration_assistant", product_version="0.0.1")
910
p = Prompts()
1011
setter_upper = SetUpMigrationAssistant()
1112
final_config = setter_upper.setup_migration_assistant(w, p)
12-
with open("sql_migration_assistant/config.yml", "w") as f:
13+
current_path = Path(__file__).parent.resolve()
14+
15+
local_config = str(current_path) + "/config.yml"
16+
with open(local_config, "w") as f:
1317
yaml.dump(final_config, f)
14-
setter_upper.upload_files(w)
18+
setter_upper.upload_files(w, current_path)
1519
setter_upper.launch_review_app(w, final_config)
Binary file not shown.
Binary file not shown.
Binary file not shown.

sql_migration_assistant/run_app_from_databricks_notebook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
pip install databricks-sdk -U
1111

1212
# COMMAND ----------
13-
pip install gradio==4.27.0 pyyaml aiohttp databricks-labs-blueprint==0.8.2 databricks-labs-lsql==0.9.0
13+
pip install gradio==4.27.0 pyyaml aiohttp==3.10.5 databricks-labs-blueprint==0.8.2 databricks-labs-lsql==0.9.0
1414

1515
# COMMAND ----------
16-
pip install dbtunnel==0.14.6
16+
pip install fastapi==0.112.2 pydantic==2.8.2 dbtunnel==0.14.6
1717

1818
# COMMAND ----------
1919
dbutils.library.restartPython()

sql_migration_assistant/utils/initialsetup.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from sql_migration_assistant.utils.upload_files_to_workspace import FileUploader
1515
from sql_migration_assistant.utils.run_review_app import RunReviewApp
1616

17-
1817
class SetUpMigrationAssistant:
1918

2019
# this is a decorator to handle errors and do a retry where user is asked to choose an existing resource
@@ -134,22 +133,26 @@ def setup_migration_assistant(self, w, p):
134133

135134
return config
136135

137-
def upload_files(self, w):
136+
def upload_files(self, w, path):
137+
# all this nastiness becomes unnecessary with lakehouse apps, or if we upload a whl it simplifies things.
138+
# But for now, this is the way.
139+
# TODO - MAKE THIS NICE!!
138140
logging.info("Uploading files to workspace")
139141
print("\nUploading files to workspace")
140142
uploader = FileUploader(w)
141143
files_to_upload = [
142-
"sql_migration_assistant/utils/runindatabricks.py",
143-
"sql_migration_assistant/gradio_app.py",
144-
"sql_migration_assistant/run_app_from_databricks_notebook.py",
145-
"sql_migration_assistant/utils/configloader.py",
146-
"sql_migration_assistant/utils/run_review_app.py",
147-
"sql_migration_assistant/config.yml",
144+
"utils/runindatabricks.py",
145+
"gradio_app.py",
146+
"run_app_from_databricks_notebook.py",
147+
"utils/configloader.py",
148+
"utils/run_review_app.py",
149+
"config.yml",
148150
]
151+
files_to_upload = [os.path.join(path, x) for x in files_to_upload]
149152
files_to_upload.extend(
150153
[
151-
f"sql_migration_assistant/app/{x}"
152-
for x in os.listdir("sql_migration_assistant/app")
154+
os.path.join(path, "app", x)
155+
for x in os.listdir(os.path.join(path, "app"))
153156
if x[-3:] == ".py"
154157
]
155158
)

sql_migration_assistant/utils/run_review_app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ def __init__(self, w: WorkspaceClient, config: dict):
2323
"gradio==4.27.0",
2424
"pyyaml",
2525
"databricks-sdk==0.30.0",
26-
"aiohttp",
26+
"aiohttp==3.10.5",
2727
"databricks-labs-blueprint==0.8.2",
28+
"fastapi==0.112.2",
29+
"pydantic==2.8.2",
2830
"dbtunnel==0.14.6",
2931
"databricks-labs-lsql==0.9.0",
3032
]

0 commit comments

Comments
 (0)