-
Notifications
You must be signed in to change notification settings - Fork 78
Add llm-transpile command with Switch runner and integration tests
#2078
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
Merged
Merged
Changes from all commits
Commits
Show all changes
117 commits
Select commit
Hold shift + click to select a range
dd726b5
feat: integrate Switch transpiler with Lakebridge installer
hiroyukinakazato-db febb62d
Merge branch 'main' into feature/switch-installer-integration
hiroyukinakazato-db fa26b4c
fix: remove undefined URLError from exception handling
hiroyukinakazato-db 6511e20
refactor: streamline SwitchInstaller deployment logic and update tests
hiroyukinakazato-db 33ea7de
refactor: simplify SwitchInstaller test structure and improve assertions
hiroyukinakazato-db d0c63c3
Merge remote-tracking branch 'origin/main' into feature/switch-instal…
hiroyukinakazato-db 7cb9ea9
feat: add Switch transpiler installer for Lakebridge integration
hiroyukinakazato-db 467dea9
fix: support case-insensitive config lookup in SwitchInstaller
hiroyukinakazato-db 57298b0
Merge branch 'main' into feature/switch-installer-integration
hiroyukinakazato-db 09c0eb8
Merge branch 'main' into feature/switch-installer-integration
hiroyukinakazato-db 8439314
refactor: separate Switch installation from workspace deployment
hiroyukinakazato-db 5f66f3f
Merge branch 'main' into feature/switch-installer-integration
hiroyukinakazato-db fae9880
feat: add llm-transpile command with Switch integration
hiroyukinakazato-db 2ee157f
refactor: encapsulate Switch package path resolution in SwitchDeployment
hiroyukinakazato-db 9dc4b04
refactor: encapsulate Switch package path resolution in SwitchDeployment
hiroyukinakazato-db 7637234
test: update Switch installation tests for refactored interface
hiroyukinakazato-db b736965
test: update Switch installation tests for refactored interface
hiroyukinakazato-db bacd5f6
fix: update error messages to include 'true' flag for install-transpi…
hiroyukinakazato-db 729cb0d
Merge branch 'main' into feature/switch-installer-integration
hiroyukinakazato-db 21b6629
Merge branch 'main' into feature/llm-transpile
hiroyukinakazato-db 42ce0df
fix: exclude wait_for_completion from Switch job parameters
hiroyukinakazato-db 81c32e5
fix: exclude wait_for_completion from Switch job parameters
hiroyukinakazato-db 13bcc15
chore: update Switch wheel with wait_for_completion fix
hiroyukinakazato-db 8dcf8f3
feat: add E2E test for Switch transpiler with environment variable co…
hiroyukinakazato-db 83678b8
feat: enhance E2E testing for Switch with resource management and uni…
hiroyukinakazato-db f698470
Merge branch 'main' into feature/switch-installer-integration
hiroyukinakazato-db 22cadc9
Defaults in `labs.yml` are strings.
asnare b3d2441
Update flag description to use placeholder syntax.
asnare ac7e2a4
Disable flag pending completion of integration.
asnare ee5c892
chore: merge main into feature/llm-transpile
hiroyukinakazato-db f0426e1
Leave pylint's max-args as-is.
asnare 934c2e8
Remove unnecessary include_llm arguments.
asnare 74923cc
Refactor Switch installation.
asnare 084f90f
upgrade to latest switch plugin
sundarshankar89 61f796f
Merge branch 'main' into feature/switch-installer-integration
sundarshankar89 0c1d1d5
fixed package dependencies
sundarshankar89 6aeea25
Merge branch 'main' into feature/switch-installer-integration
sundarshankar89 468f8de
added additional configuration for making switch
sundarshankar89 6a57570
Latest Switch
sundarshankar89 2c3d153
Sorted List for FMAPI
sundarshankar89 f41dee8
setting logging level
sundarshankar89 950c1b8
setting logging level
sundarshankar89 6ca78ed
setting logging level
sundarshankar89 ba65df4
setting logging level
sundarshankar89 2e2abcb
setting logging level
sundarshankar89 bcbe4df
make default as first choice
sundarshankar89 486250f
fix tests
sundarshankar89 fc1ddca
fix tests
sundarshankar89 42c9c4e
fixes few bugs
sundarshankar89 1831076
update databricks-switch-plugin dependency to version 0.1.4
hiroyukinakazato-db 01a0c87
Review Comments
sundarshankar89 ccce0f2
Review Comments
sundarshankar89 ac382d6
Merge branch 'main' into feature/llm-transpile
sundarshankar89 4600583
Merge branch 'feature/switch-installer-integration' into feature/llm-…
sundarshankar89 7f0eaa4
Rebased from switch installer integration
sundarshankar89 0e22abe
Rebased from switch installer integration
sundarshankar89 43cc0f5
Intermediate check in
sundarshankar89 bb7c3d6
Intermediate check in
sundarshankar89 bd70638
Intermediate check in
sundarshankar89 0eb1570
Intermediate check in
sundarshankar89 eae5997
Merge branch 'main' into feature/switch-installer-integration
sundarshankar89 9823201
Merge branch 'feature/switch-installer-integration' into feature/llm-…
sundarshankar89 eb46f24
initial tests
sundarshankar89 34c9f8f
Merge branch 'main' into feature/switch-installer-integration
sundarshankar89 c54e68f
Merge branch 'feature/switch-installer-integration' into feature/llm-…
sundarshankar89 23df37b
added tests for configurator
sundarshankar89 4a0bf49
added tests for installer
sundarshankar89 c49c5b3
added tests for installer
sundarshankar89 fab0e87
Merge branch 'feature/switch-installer-integration' into feature/llm-…
sundarshankar89 078a0bc
added tests for switch
sundarshankar89 1e10b60
added flag to fail if users use regular transpile after installing sw…
sundarshankar89 394ad9d
Merge branch 'feature/switch-installer-integration' into feature/llm-…
sundarshankar89 69f93b2
Merge branch 'main' into feature/switch-installer-integration
sundarshankar89 aeff475
Merge branch 'feature/switch-installer-integration' into feature/llm-…
sundarshankar89 7a336f9
added additional tests improved cuj
sundarshankar89 2602577
added user agent extra
sundarshankar89 b5bcbcd
Merge branch 'main' into feature/switch-installer-integration
asnare 6132f04
removed interactive prompt with include_llm_transpiler
sundarshankar89 fb2ae71
Merge branch 'feature/switch-installer-integration' into feature/llm-…
sundarshankar89 53077ec
removed interactive prompt with include_llm_transpiler
sundarshankar89 186ab59
Merge branch 'main' into feature/switch-installer-integration
sundarshankar89 508d6c1
Merge branch 'feature/switch-installer-integration' into feature/llm-…
sundarshankar89 363a31d
execute llm transpile
sundarshankar89 c01d605
execute llm transpile
sundarshankar89 ebf969a
execute llm transpile
sundarshankar89 eb1d497
Merge branch 'main' into feature/switch-installer-integration
asnare 52d6613
Log why the configuration questionnaire won't happen.
asnare 11903f9
Logging tweaks.
asnare a62194d
Fix incorrect comment.
asnare 24ad1b3
Style tweak, mark a method as static.
asnare 4083dd6
Merge branch 'feature/switch-installer-integration' into feature/llm-…
asnare 59fe56e
Merge branch 'main' into feature/switch-installer-integration
gueniai ab3851e
Merge branch 'feature/switch-installer-integration' into feature/llm-…
gueniai 5a26f86
addressed review comments
sundarshankar89 efc3c64
Merge remote-tracking branch 'origin/feature/llm-transpile' into feat…
sundarshankar89 1a64612
addressed review comments
sundarshankar89 6ac2e68
addressed review comments
sundarshankar89 9799a23
addressed review comments
sundarshankar89 ddf7f1a
update latest switch plugin
sundarshankar89 0323ae0
Merge branch 'feature/switch-installer-integration' into feature/llm-…
sundarshankar89 cff62b1
removed duplicate
sundarshankar89 a5e06e3
Avoid raising DatabricksError ourselves.
asnare 3ce1ffd
Avoid raising DatabricksError ourselves.
asnare df7b15c
Merge branch 'feature/switch-installer-integration' into feature/llm-…
asnare a659992
Update llm-transpile CLI description and help text.
asnare 459d941
Foundational -> Foundation
asnare 1aab9bf
Improve logging if there as issue locating the Switch job.
asnare c9bfda0
Simplify logic for computing the path where sources to convert are up…
asnare 8ec00ca
Merge branch 'main' into feature/llm-transpile
asnare eefda07
Remove unnecessary exception wrapping.
asnare e0814c3
Reformat the legal disclaimer for LLM use, and adjust grammar.
asnare a54c2a5
Remove some unused code.
asnare 6d41b07
Improve variable name.
asnare 8332c41
Don't dump a JSON response: this isn't supported for commands that pr…
asnare a6f1c84
Fix tests broken by removal of JSON response.
asnare 23d9537
Merge branch 'main' into feature/llm-transpile
asnare e298db1
Update `llm-transpile` to require `--accept-terms=true` (#2136)
asnare 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
Some comments aren't visible on the classic Files Changed page.
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 |
|---|---|---|
|
|
@@ -22,3 +22,4 @@ remorph_transpile/ | |
| /linter/src/main/antlr4/library/gen/ | ||
| .databricks-login.json | ||
| .mypy_cache | ||
| .env | ||
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
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
139 changes: 139 additions & 0 deletions
139
src/databricks/labs/lakebridge/transpiler/switch_runner.py
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,139 @@ | ||
| import io | ||
| import logging | ||
| import os | ||
| import random | ||
| import string | ||
| from datetime import datetime, timezone | ||
| from pathlib import Path | ||
|
|
||
| from databricks.labs.blueprint.installation import RootJsonValue | ||
| from databricks.sdk import WorkspaceClient | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class SwitchRunner: | ||
| """Runner for Switch LLM transpilation jobs.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| ws: WorkspaceClient, | ||
| ): | ||
| self._ws = ws | ||
|
|
||
| def run( | ||
| self, | ||
| volume_input_path: str, | ||
| output_ws_folder: str, | ||
| source_tech: str, | ||
| catalog: str, | ||
| schema: str, | ||
| foundation_model: str, | ||
| job_id: int, | ||
| ) -> RootJsonValue: | ||
| """Trigger Switch job.""" | ||
|
|
||
| job_params = self._build_job_parameters( | ||
| input_dir=volume_input_path, | ||
| output_dir=output_ws_folder, | ||
| source_tech=source_tech, | ||
| catalog=catalog, | ||
| schema=schema, | ||
| foundation_model=foundation_model, | ||
| ) | ||
| logger.info(f"Triggering Switch job with job_id: {job_id}") | ||
|
|
||
| return self._run_job(job_id, job_params) | ||
|
|
||
| def upload_to_volume( | ||
| self, | ||
| local_path: Path, | ||
| catalog: str, | ||
| schema: str, | ||
| volume: str, | ||
| ) -> str: | ||
| """Upload local files to UC Volume with unique timestamped path.""" | ||
| now = datetime.now(timezone.utc) | ||
| time_part = now.strftime("%Y%m%d%H%M%S") | ||
| random_part = ''.join(random.choices(string.ascii_lowercase + string.digits, k=4)) | ||
| volume_base_path = f"/Volumes/{catalog}/{schema}/{volume}" | ||
| volume_input_path = f"{volume_base_path}/input-{time_part}-{random_part}" | ||
|
|
||
| logger.info(f"Uploading {local_path} to {volume_input_path}...") | ||
|
|
||
| # File upload | ||
| if local_path.is_file(): | ||
| if local_path.name.startswith('.'): | ||
| logger.debug(f"Skipping hidden file: {local_path}") | ||
| return volume_input_path | ||
| volume_file_path = f"{volume_input_path}/{local_path.name}" | ||
| with open(local_path, 'rb') as f: | ||
| content = f.read() | ||
| self._ws.files.upload(file_path=volume_file_path, contents=io.BytesIO(content), overwrite=True) | ||
| logger.debug(f"Uploaded: {local_path} -> {volume_file_path}") | ||
|
|
||
| # Directory upload | ||
| else: | ||
| for root, dirs, files in os.walk(local_path): | ||
| # remove hidden directories | ||
| dirs[:] = [d for d in dirs if not d.startswith('.')] | ||
| # skip hidden files | ||
| files = [f for f in files if not f.startswith('.')] | ||
| for file in files: | ||
| local_file = Path(root) / file | ||
| relative_path = local_file.relative_to(local_path) | ||
| volume_file_path = f"{volume_input_path}/{relative_path}" | ||
|
|
||
| with open(local_file, 'rb') as f: | ||
| content = f.read() | ||
|
|
||
| self._ws.files.upload(file_path=volume_file_path, contents=io.BytesIO(content), overwrite=True) | ||
| logger.debug(f"Uploaded: {local_file} -> {volume_file_path}") | ||
|
|
||
| logger.info(f"Upload complete: {volume_input_path}") | ||
| return volume_input_path | ||
|
|
||
| def _build_job_parameters( | ||
| self, | ||
| input_dir: str, | ||
| output_dir: str, | ||
| source_tech: str, | ||
| catalog: str, | ||
| schema: str, | ||
| foundation_model: str, | ||
| switch_options: dict | None = None, | ||
| ) -> dict[str, str]: | ||
| """Build Switch job parameters.""" | ||
| if switch_options is None: | ||
| switch_options = {} | ||
| return { | ||
| "input_dir": input_dir, | ||
| "output_dir": output_dir, | ||
| "source_tech": source_tech, | ||
| "catalog": catalog, | ||
| "schema": schema, | ||
| "foundation_model": foundation_model, | ||
| **switch_options, | ||
| } | ||
|
|
||
| def _run_job( | ||
| self, | ||
| job_id: int, | ||
| job_params: dict[str, str], | ||
| ) -> RootJsonValue: | ||
| """Trigger Switch job and return run information.""" | ||
| job_run = self._ws.jobs.run_now(job_id, job_parameters=job_params) | ||
|
|
||
| if not job_run.run_id: | ||
| raise SystemExit(f"Job {job_id} execution failed.") | ||
|
|
||
| job_run_url = f"{self._ws.config.host}/jobs/{job_id}/runs/{job_run.run_id}" | ||
| logger.info(f"Switch LLM transpilation job started: {job_run_url}") | ||
|
|
||
| return [ | ||
| { | ||
| "job_id": job_id, | ||
| "run_id": job_run.run_id, | ||
| "run_url": job_run_url, | ||
| } | ||
| ] | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.