Skip to content

New hidden install-pipelines-cli command that creates pipelines symlink to databricks #3009

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 27 commits into from
Jun 20, 2025

Conversation

alyssa-db
Copy link
Collaborator

@alyssa-db alyssa-db commented Jun 6, 2025

Changes

  • New file: pipelines.go (package pipelines)
  • New file: install_pipelines_cli.go (package pipelines)
    • To databricks, implements a hidden install-pipelines-cli command that creates a symlink named pipelines pointing to the real databricks binary.
    • Handles symlink creation, permission checks, and error handling for existing files/symlinks.
  • New folder: pipelines/install-pipelines-cli acceptance test
  • main.go returns a root depending on if the binary is invoked as pipelines/pipelines.exe or databricks

Why

  • Symlink installation: This enables users to invoke pipelines as a standalone CLI, which internally points to the main databricks binary. This is a step towards a dedicated Pipelines CLI experience, while minimizing code duplication.
  • Stub CLI: Lays groundwork for future pipelines-specific commands and workflows
  • Testing: Acceptance test.

Tests

  • Added acceptance tests for install-pipelines-cli in pipelines to check if success message pipelines successfully installed is printed
  • Test descriptions:
    1. Fresh installation:
      Creates temporary directory and verifies successful symlink creation.
      Validates CLI output and stub command functionality.
    2. Already installed scenario:
      Confirms graceful handling when symlink already exists.
    3. File collision test:
      Ensures installation fails when regular file exists at target path.
    4. Aliased binary execution:
      Verifies installation works when databricks binary is renamed/called via alias.

@alyssa-db alyssa-db requested a review from kanterov June 10, 2025 23:38
Copy link
Collaborator

@kanterov kanterov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left few comments

@@ -150,7 +150,8 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
repls.SetPath(execPath, "[CLI]")

// Make helper scripts available
t.Setenv("PATH", fmt.Sprintf("%s%c%s", filepath.Join(cwd, "bin"), os.PathListSeparator, os.Getenv("PATH")))
pathDirs := []string{filepath.Join(cwd, "bin"), buildDir}
t.Setenv("PATH", fmt.Sprintf("%s%c%s", strings.Join(pathDirs, string(os.PathListSeparator)), os.PathListSeparator, os.Getenv("PATH")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds buildDir to PATH? What for?

Copy link
Contributor

@denik denik Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the goal is to expose dlt command to test then we should

  • modify BuildCLI to link databricks to dlt
  • export $DLT env var pointing to built dlt (+ replacement)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention here was probably so dlt can be found on the build path when it's built, but we should probably export the $DLT env var the same way we do it for CLI and other envs.

qq: maybe I misunderstood, wdym by "+ replacement" here?

@jefferycheng1
Copy link
Collaborator

I think it's better to write it as an acceptance test, for example as here
https://github.com/databricks/cli/tree/main/acceptance/cmd/unknown-subcommand

Here you can see a short guide how to do that https://github.com/databricks/cli/tree/main/acceptance

@denik / @kanterov high level question here: we should be definitely adding acceptance tests, but in general does it hurt to have unit tests as well? A quick look through the repo and it feels like some files have more unit tests while others don't.

For this command specifically, I think it's helpful to test the edge cases for which PATH might not contain databricks, target local isn't writable etc... WDYT?

@denik
Copy link
Contributor

denik commented Jun 11, 2025

@denik / @kanterov high level question here: we should be definitely adding acceptance tests, but in general does it hurt to have unit tests as well? A quick look through the repo and it feels like some files have more unit tests while others don't.

For this command specifically, I think it's helpful to test the edge cases for which PATH might not contain databricks, target local isn't writable etc... WDYT?

Depends on code being test; if it's a pure function / class, makes sense to cover edge cases with unit tests. If it involves reading env vars, command line arguments then acceptance tests typically provide more realistic setup.

@alyssa-db alyssa-db force-pushed the install-dlt-feat branch 2 times, most recently from 085a428 to 9d53ff8 Compare June 12, 2025 23:39

title "Executable not called as databricks"
cp $CLI notdatabricks
dlt=$(trace errcode ./notdatabricks install-dlt -o json | jq -r .symlink_path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also not clear here what's being asserted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case that the user has databricks aliased, want to make sure the install-dlt command still works.

main.go Outdated
// binary to be used for both DLT and databricks CLI commands.
func getCommand(ctx context.Context) *cobra.Command {
invokedAs := filepath.Base(os.Args[0])
if invokedAs == "dlt" || (runtime.GOOS == "windows" && invokedAs == "dlt.exe") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can replace it with strings.StartsWith for invokedAs as nit

@alyssa-db alyssa-db enabled auto-merge June 18, 2025 18:43
@alyssa-db alyssa-db disabled auto-merge June 18, 2025 20:08
Copy link
Contributor

@andrewnester andrewnester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved to unblock but first symlink needs to be renamed from dlt to pipelines

@alyssa-db alyssa-db requested a review from andrewnester June 19, 2025 01:38
Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the PR title and summary to reflect the new state of the PR.

@alyssa-db alyssa-db changed the title New hidden install-dlt command that creates dlt symlink to databricks New hidden install-pipelines-cli command that creates pipelines symlink to databricks Jun 19, 2025
@alyssa-db alyssa-db changed the title New hidden install-pipelines-cli command that creates pipelines symlink to databricks New hidden install-pipelines-cli command that creates pipelines symlink to databricks Jun 19, 2025
Copy link

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 3009
  • Commit SHA: 9156ad52393b0c5260b7573fe18c969c2ae82723

Checks will be approved automatically on success.

@alyssa-db alyssa-db requested a review from pietern June 19, 2025 19:15
@andrewnester andrewnester dismissed pietern’s stale review June 20, 2025 15:38

Already addressed

@andrewnester andrewnester merged commit d5108bf into databricks:main Jun 20, 2025
9 checks passed
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

Successfully merging this pull request may close these issues.

8 participants