Commit Graph

476 Commits

Author SHA1 Message Date
Lennart Kats 9c064a8ca4 WIP 2023-07-15 16:10:40 +02:00
Lennart Kats d68d054160 Merge remote-tracking branch 'databricks/main' into extend-deployment-modes 2023-07-15 16:08:44 +02:00
shreyas-goenka a7a109a5d8
Remove base path checks during sync (#576)
## Changes
Earlier we removed recursive deletion from sync. This makes it safe
enough for us to not restrict sync to just the namespace of the user.

This PR removes that base path validation. 

Note: If the sync destination is under `/Repos` we still only create
missing directories required if the path is under my namespace ie
matches `/Repos/@me/`

## Tests
Manually

Before:
```
shreyas.goenka@THW32HFW6T hello-bundle % cli bundle deploy
Starting upload of bundle files
Error: path must be nested under /Users/shreyas.goenka@databricks.com or /Repos/shreyas.goenka@databricks.com
```

After:
```
shreyas.goenka@THW32HFW6T hello-bundle % cli bundle deploy
Starting upload of bundle files
Uploaded bundle files at /Shared/common-test/hello-bundle/files!

Starting resource deployment
Resource deployment completed!
```
2023-07-14 11:43:20 +02:00
Miles Yucht 9a0888126c
Improve auth login experience (#570)
## Changes
Currently, `databricks auth login` is difficult to use. If a user types
this command in, the command fails with
```
Error: init: cannot fetch credentials
```
after prompting for a profile name.

To make this experience smoother, this change ensures that the host, and
if necessary, the account ID, are prompted for input from the user if
they aren't provided on the CLI.


## Tests
Manual tests:

```
$ ./cli auth token                   
Databricks Host: https://<HOST>.staging.cloud.databricks.com
{
  "access_token": "...",
  "token_type": "Bearer",
  "expiry": "2023-07-11T12:56:59.929671+02:00"
}
$ ./cli auth login
Databricks Host: https://<HOST>.staging.cloud.databricks.com
Databricks Profile Name: <HOST>-test
Profile <HOST>-test was successfully saved
$ ./cli auth login
Databricks Host: https://accounts.cloud.databricks.com
Databricks Account ID: <ACCOUNTID>
Databricks Profile Name: ACCOUNT-<ACCOUNTID>-test
Profile ACCOUNT-<ACCOUNTID>-test was successfully saved 
```

---------

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
2023-07-12 15:36:09 +00:00
shreyas-goenka f00488d81d
Disallow notebooks in paths where files are expected (#573)
## Changes
Uploading a notebook strips it's file extension. This PR returns an
error if a notebook is specified where a file is expected. For example:
A spark python task in a job or `libraries.file.path` DLT library (where
instead `libraries.notebook.path` should be used

This PR also adds test coverage for the opposite case, when files are
not notebooks where notebooks are expected.

## Tests
Integration tests and manually
2023-07-12 12:25:00 +00:00
Andrew Nester 650fb0e8b6
Correctly use --profile flag passed for all bundle commands (#571)
## Changes
Correctly use --profile flag passed for all bundle commands.

Also adds a validation that if bundle configured host mismatches
provided profile, it throws an error.

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
2023-07-12 14:09:25 +02:00
dependabot[bot] 14cfc80666
Bump golang.org/x/mod from 0.11.0 to 0.12.0 (#568) 2023-07-12 11:49:35 +00:00
dependabot[bot] d28133fd3e
Bump golang.org/x/oauth2 from 0.9.0 to 0.10.0 (#566) 2023-07-12 11:42:46 +00:00
dependabot[bot] d2b7c6d611
Bump golang.org/x/term from 0.9.0 to 0.10.0 (#567) 2023-07-12 11:36:07 +00:00
Miles Yucht f203731fe6
Support tab completion for profiles (#572)
## Changes
Currently, `databricks --profile <TAB>` autocompletes with the shell
default behavior, listing files in the local directory. This is not a
great experience. Especially given that the suggested profile names for
accounts are so long, it can be cumbersome to type them out by hand.
This PR configures autocompletion for `--profile` to inspect the
profiles of ~/.databrickscfg.

One potential improvement is to filter the response based on whether the
command is known to be account-level or workspace-level.

## Tests
Manual test.
<img width="579" alt="Screenshot_11_07_2023__18_31"
src="https://github.com/databricks/cli/assets/1850319/d7a3acd0-2511-45ac-bd82-95567775c10a">
2023-07-12 12:05:51 +02:00
Lennart Kats (databricks) 57e75d3e22
Add development runs (#522)
This implements the "development run" functionality that we desire for DABs in the workspace / IDE.

## bundle.yml changes

In bundle.yml, there should be a "dev" environment that is marked as
`mode: debug`:
```
environments:
  dev:
    default: true
    mode: development # future accepted values might include pull_request, production
```

Setting `mode` to `development` indicates that this environment is used
just for running things for development. This results in several changes
to deployed assets:
* All assets will get '[dev]' in their name and will get a 'dev' tag
* All assets will be hidden from the list of assets (future work; e.g.
for jobs we would have a special job_type that hides it from the list)
* All deployed assets will be ephemeral (future work, we need some form
of garbage collection)
* Pipelines will be marked as 'development: true'
* Jobs can run on development compute through the `--compute` parameter
in the CLI
* Jobs get their schedule / triggers paused
* Jobs get concurrent runs (it's really annoying if your runs get
skipped because the last run was still in progress)

Other accepted values for `mode` are `default` (which does nothing) and
`pull-request` (which is reserved for future use).

## CLI changes

To run a single job called "shark_sighting" on existing compute, use the
following commands:
```
$ databricks bundle deploy --compute 0617-201942-9yd9g8ix
$ databricks bundle run shark_sighting
```

which would deploy and run a job called "[dev] shark_sightings" on the
compute provided. Note that `--compute` is not accepted in production
environments, so we show an error if `mode: development` is not used.

The `run --deploy` command offers a convenient shorthand for the common
combination of deploying & running:
```
$ export DATABRICKS_COMPUTE=0617-201942-9yd9g8ix
$ bundle run --deploy shark_sightings
```
The `--deploy` addition isn't really essential and I welcome feedback 🤔
I played with the idea of a "debug" or "dev" command but that seemed to
only make the option space even broader for users. The above could work
well with an IDE or workspace that automatically sets the target
compute.

One more thing I added is`run --no-wait` can now be used to run
something without waiting for it to be completed (useful for IDE-like
environments that can display progress themselves).
```
$ bundle run --deploy shark_sightings --no-wait
```
2023-07-12 08:51:54 +02:00
Pieter Noordhuis e11704618c
Release v0.200.2 (#564)
## Changes

CLI:
* Fix secrets put-secret command
([#545](https://github.com/databricks/cli/pull/545)).
* Fixed ignoring required positional parameters when --json flag is
provided ([#535](https://github.com/databricks/cli/pull/535)).
* Update cp help message to not require file scheme
([#554](https://github.com/databricks/cli/pull/554)).

Bundles:
* Fix: bundle destroy fails when bundle.tf.json file is deleted
([#519](https://github.com/databricks/cli/pull/519)).
* Fixed error reporting when included invalid files in include section
([#543](https://github.com/databricks/cli/pull/543)).
* Make top level workspace optional in JSON schema
([#562](https://github.com/databricks/cli/pull/562)).
* Propagate TF_CLI_CONFIG_FILE env variable
([#555](https://github.com/databricks/cli/pull/555)).
* Update Terraform provider schema structs
([#563](https://github.com/databricks/cli/pull/563)).
* Update inline JSON schema documentation
([#557](https://github.com/databricks/cli/pull/557)).

Dependencies:
* Bump Go SDK to v0.12.0
([#540](https://github.com/databricks/cli/pull/540)).
* Bump github.com/hashicorp/terraform-json from 0.17.0 to 0.17.1
([#541](https://github.com/databricks/cli/pull/541)).
2023-07-10 13:26:19 +02:00
Lennart Kats f59e73a026 WIP 2023-07-10 09:21:14 +02:00
Lennart Kats 368796ba12 WIP 2023-07-10 09:12:50 +02:00
Lennart Kats 77fcc92e65 Add comment 2023-07-07 18:05:38 +02:00
Lennart Kats 54a66c0120 Fix paths on Windows 2023-07-07 18:04:28 +02:00
shreyas-goenka 47f4d30229
Make top level workspace optional in JSON schema (#562)
## Tests
Tested manually. `"workspace"` is no longer a required field in the
generated JSON schema

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
2023-07-07 13:10:25 +00:00
shreyas-goenka 057f328879
Update inline JSON schema documentation (#557)
## Changes
Add docs for experiments and models to the json schema. Update the
schema to the latest openapi spec.

## Tests
Manually
2023-07-07 13:00:12 +00:00
Pieter Noordhuis b6665f4b30
Update Terraform provider schema structs (#563)
## Changes

Generated from 47857a63c7242fc43aba833cdd28b222fd25c399 (next release
after 1.20).

## Tests

The change is additive and unit tests pass.
2023-07-07 14:52:41 +02:00
Gleb Kanterov 179154477e
Propagate TF_CLI_CONFIG_FILE env variable (#555)
## Changes
Propagate `TF_CLI_CONFIG_FILE` env variable.

From Terraform documentation:

> The location of the Terraform CLI configuration file can also be
specified using the TF_CLI_CONFIG_FILE [environment
variable](https://developer.hashicorp.com/terraform/cli/config/environment-variables)

It allows using custom builds of terraform-provider-databricks, using
config files like:

```tf
provider_installation {
  dev_overrides {
    "databricks/databricks" = "/Users/gleb.kanterov/terraform-provider-databricks"
  }

  direct {}
}
```

## Tests
I added unit tests.
2023-07-07 13:20:37 +02:00
Andrew Nester b14920cd12
Fixed error reporting when included invalid files in include section (#543)
## Changes
Fixed error reporting when included invalid files in include section

Case 1. When the file to include is invalid, throw an error
Case 2. When the file is loaded but the schema is wrong, indicate which
file is failed to load

## Tests

With non-existent notexists.yml

```
databricks bundle deploy
Error: notexists.yml defined in 'include' section does not match any files

```

With malformed notexists.yml
```
databricks bundle deploy
Error: failed to load /Users/andrew.nester/dabs/wheel/notexists.yml: error unmarshaling JSON: json: cannot unmarshal string into Go value of type config.Root
```
2023-07-07 10:22:58 +00:00
Lennart Kats cbd306825b Support experiment names that use full paths 2023-07-07 11:49:02 +02:00
Lennart Kats 6b221c02e5 Cleanup 2023-07-07 11:12:14 +02:00
Lennart Kats 50b76bb41e Cleanup 2023-07-07 11:09:09 +02:00
Lennart Kats d221d4d348 Make it possible to override the compute id in an environment 2023-07-07 11:09:04 +02:00
Lennart Kats be2dd4f769 Improve DATABRICKS_CLUSTER_ID handling for non-development modes 2023-07-07 09:38:30 +02:00
shreyas-goenka 6f023f46d8
Update cp help message to not require file scheme (#554)
## Tests
Manually

---------

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
2023-07-06 13:16:14 +02:00
Andrew Nester 8eccc3442f
Renamed method to HasRequiredNonBodyField (#553)
## Changes
Renamed method to HasRequiredNonBodyField in line with 
https://github.com/databricks/databricks-sdk-go/pull/536
2023-07-06 11:59:53 +02:00
stikkireddy 533234f148
Fix: bundle destroy fails when bundle.tf.json file is deleted (#519)
## Changes

Adds the following steps to the destroy phase:
1. interpolate
2. write

Resolves #518 

## Tests

Tested manually due there not being an examples for tests to use.
2023-07-05 21:58:06 +02:00
Pieter Noordhuis db6313e99c
Fix secrets put-secret command (#545)
## Changes

Two issues with this command:
* The command line arguments for the secret value were ignored
* If the secret value was piped through stdin, it would still prompt

The second issue prevented users from using multi-line strings because
the prompt reads until end-of-line.

This change adds testing infrastructure for:
* Setting up a workspace focused test (common between many tests)
* Running a snippet of Python through the command execution API

Porting more integration tests to use this infrastructure will be done
in later commits.

## Tests

New integration test passes.

The interactive path cannot be integration tested just yet.
2023-07-05 17:30:54 +02:00
Lennart Kats 36a6e9348b Fix tests 2023-07-04 16:21:35 +02:00
Lennart Kats 35f4d3bb7d Use latest config names 2023-07-03 18:04:17 +02:00
Lennart Kats 64edf3942e Merge remote-tracking branch 'databricks/main' into add-debug-runs 2023-07-03 18:03:30 +02:00
Lennart Kats ddcd6131ca Don't support databricks bundle run --deploy for now 2023-07-03 17:58:53 +02:00
Lennart Kats 34a1698d24 Pass compute override as part of the bundle object 2023-07-03 17:56:45 +02:00
Lennart Kats 5a7b556a5a Add docstring 2023-07-03 16:51:44 +02:00
Lennart Kats 15396bce69 Implement --no-wait for pipelines 2023-07-03 16:47:21 +02:00
Lennart Kats 4762716f73 Rename "debug" to "development" 2023-07-03 16:30:42 +02:00
dependabot[bot] 335475095e
Bump github.com/hashicorp/terraform-json from 0.17.0 to 0.17.1 (#541) 2023-07-03 12:03:40 +00:00
Andrew Nester 17ed7a317b
Fixed ignoring required positional parameters when --json flag is provided (#535)
## Changes
When there are positional required parameters in the command which can't
be unmarshalled from JSON, we should require them despite the fact
`--json` flag is provided.

The reason is that for some of the command, for example, `databricks
groups patch ID` these arguments are actually path arguments in API and
can't be set as part of `--json` body provided.

Original change which introduced this ignore logic is here:
https://github.com/databricks/cli/pull/405

Fixes https://github.com/databricks/cli/issues/533,
https://github.com/databricks/cli/issues/537

Note: Code generation is based on the change in this PR:
https://github.com/databricks/databricks-sdk-go/pull/536

## Tests
1. Running `cli groups patch 123 --json {...}` works correctly

Backward compatibility tests with previous changes from
https://github.com/databricks/cli/pull/405
1. `cli clusters events --json '{"cluster_id": "1029-xxxx"}'` - works,
returns list of events
2. `cli clusters events 1029-xxxx` - works, returns list of events
3. `cli clusters events` - works, first prompts for Cluster ID and then
returns the list of events
2023-07-03 13:20:30 +02:00
Pieter Noordhuis ad8183d7a9
Bump Go SDK to v0.12.0 (#540)
## Changes

* Regenerate CLI commands
* Ignore `account-access-control-proxy` (see #505)

## Tests

Unit and integration tests pass.
2023-07-03 11:46:45 +02:00
Pieter Noordhuis f42279fe47
Release v0.200.1 (#532)
## Changes

CLI:
* Add --absolute flag for ls command
([#508](https://github.com/databricks/cli/pull/508)).
* Add dbfs scheme prefix to paths in cp command output
([#516](https://github.com/databricks/cli/pull/516)).
* Add provider detection to the repos create command
([#528](https://github.com/databricks/cli/pull/528)).
* Added configure-cluster flag for auth login
([#500](https://github.com/databricks/cli/pull/500)).
* Added prompts for Databricks profile for auth login command
([#502](https://github.com/databricks/cli/pull/502)).
* Allow specifying repo by path for repos commands
([#526](https://github.com/databricks/cli/pull/526)).
* Decode contents by default in workspace export command
([#531](https://github.com/databricks/cli/pull/531)).
* Fixed jobs create command to only accept JSON payload
([#498](https://github.com/databricks/cli/pull/498)).
* Make local files default for fs commands
([#506](https://github.com/databricks/cli/pull/506)).
* Remove \r from new line print statments
([#509](https://github.com/databricks/cli/pull/509)).
* Remove extra call to filer.Stat in dbfs filer.Read
([#515](https://github.com/databricks/cli/pull/515)).
* Update alerts command integration test
([#512](https://github.com/databricks/cli/pull/512)).
* Update variable regex to support hyphens
([#503](https://github.com/databricks/cli/pull/503)).

Bundles:
* Add DATABRICKS_BUNDLE_TMP env variable
([#462](https://github.com/databricks/cli/pull/462)).
* Update Terraform provider schema structs
([#504](https://github.com/databricks/cli/pull/504)).

Dependencies:
* Bump github.com/databricks/databricks-sdk-go from
0.9.1-0.20230614092458-b5bbc1c8dabb to 0.10.0
([#497](https://github.com/databricks/cli/pull/497)).

Internal:
* Use direct download for workspace filer read
([#514](https://github.com/databricks/cli/pull/514)).
2023-06-28 14:23:55 +00:00
Pieter Noordhuis f64c44285f
Decode contents by default in workspace export command (#531)
## Changes

Also see #525.

The direct download flag has been removed in newer versions because of
the content type issue.

Instead, we can make the command decode the base64 output when the
output mode is text.

```
$ databricks workspace export /some/path/script.sh
#!/bin/bash
echo "this is a script"
```

## Tests

New integration test.
2023-06-27 20:42:29 +02:00
shreyas-goenka 54148ffedf
Add --absolute flag for ls command (#508)
tested manually

---------

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
2023-06-27 16:06:56 +02:00
shreyas-goenka 1f5cdfda29
Add dbfs scheme prefix to paths in cp command output (#516)
## Changes
Adds the dbfs:/ prefix to paths output by the cp command so they can be
used with the CLI

## Tests
Manually

Currently there are no integration tests for command output, I'll add
them in separately

---------

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
2023-06-27 14:42:27 +02:00
Pieter Noordhuis c64a3336c5
Add provider detection to the repos create command (#528)
## Changes

Closes #527.

## Tests

Integration tests pass.
2023-06-27 14:17:13 +02:00
Pieter Noordhuis 64fcd3d2ee
Allow specifying repo by path for repos commands (#526)
## Changes

The repos commands take a repo ID. It is more convenient to specify
repos by their paths.

Closes #523.

## Tests

New integration tests pass.
2023-06-26 23:37:05 +00:00
Pieter Noordhuis cf92698eb3
Application -> Asset (#529) 2023-06-27 01:31:20 +02:00
shreyas-goenka 30efe91c6d
Make local files default for fs commands (#506)
## Changes
<!-- Summary of your changes that are easy to understand -->

## Tests
<!-- How is this tested? -->
2023-06-23 16:07:09 +02:00
shreyas-goenka d0e9953ad9
Use direct download for workspace filer read (#514)
## Changes
Use the download method from the SDK in the read method for the WSFS
implementation of the filer interface.

Closes #452.

## Tests
Tested by existing integration tests
2023-06-23 15:17:39 +02:00