Commit Graph

517 Commits

Author SHA1 Message Date
Shreyas Goenka 47d3e885a5
add test for direct variable reference 2024-09-10 15:44:51 +02:00
Shreyas Goenka 1ff286cb78
fix typo 2024-09-10 15:44:51 +02:00
Shreyas Goenka 54abb3ba41
move location of testdata 2024-09-10 15:44:51 +02:00
Shreyas Goenka f8b5a5c2e8
remove todos 2024-09-10 15:44:51 +02:00
Shreyas Goenka 2931d96c43
- 2024-09-10 15:44:51 +02:00
Shreyas Goenka 9443ed68fe
add tests for the fail case 2024-09-10 15:44:50 +02:00
Shreyas Goenka a724a1129d
Add end to end integration tests for bundle JSON Schema 2024-09-10 15:44:50 +02:00
Shreyas Goenka 43aad377d1
Address comments 2024-09-10 15:44:50 +02:00
Shreyas Goenka 4dbc090cf3
- 2024-09-10 15:44:48 +02:00
Shreyas Goenka 3b06a94cfc
regenerate schema with interpolation patterns 2024-09-10 15:39:46 +02:00
Shreyas Goenka c365fd424b
Address comments 2024-09-10 15:38:32 +02:00
Shreyas Goenka 9689a79f22
address comments 2024-09-10 15:38:32 +02:00
Shreyas Goenka f26027ab1c
comment 2024-09-10 15:38:32 +02:00
Shreyas Goenka 507b99dca1
- 2024-09-10 15:38:31 +02:00
Shreyas Goenka 176bb4b382
fix test 2024-09-10 15:38:31 +02:00
Shreyas Goenka 48af9d1c57
Change variables block to map of any in `Targets` struct 2024-09-10 15:38:31 +02:00
Shreyas Goenka e1a8e03cea
regenerate schema with interpolation patterns 2024-09-10 15:36:52 +02:00
Shreyas Goenka 65ed301b06
make interpolation pattern better 2024-09-10 15:27:39 +02:00
Shreyas Goenka 4c3facc0ca
Merge remote-tracking branch 'origin' into improve/json-schema 2024-09-09 13:58:01 +02:00
Pieter Noordhuis b451905b6e
Expand library globs relative to the sync root (#1756)
## Changes

Library glob expansion happens during deployment. Before that, all
entries that refer to local paths in resource definitions are made
relative to the _sync root_. Before #1694, they were made relative to
the _bundle root_. This PR didn't update the library glob expansion code
to use the sync root path.

If you were using the sync paths setting with library globs, the CLI
would fail to expand the globs because the code was using the wrong path
to anchor those globs.

This change fixes the issue.

## Tests

Manually confirmed that this fixes the issue reported in #1755.
2024-09-09 09:56:16 +00:00
Shreyas Goenka 2d62c0ceb7
Added testS 2024-09-06 16:29:55 +02:00
Shreyas Goenka 1dd399f3fe
new line for s 2024-09-06 15:18:31 +02:00
Andrew Nester 02e83877f4
Added listing cluster filtering for cluster lookups (#1754)
## Changes
We added a custom resolver for the cluster to add filtering for the
cluster source when we list all clusters.

Without the filtering listing could take a very long time (5-10 mins)
which leads to lookup timeouts.

## Tests
Existing unit tests passing
2024-09-06 11:34:57 +00:00
Shreyas Goenka e55df7b207
Merge remote-tracking branch 'origin' into improve/json-schema 2024-09-05 14:16:14 +02:00
Shreyas Goenka 4379d7f09b
allow artifacts referencing 2024-09-05 14:15:35 +02:00
Shreyas Goenka d0aa493281
- 2024-09-05 14:15:08 +02:00
Pieter Noordhuis ceefa80d72
Pass copy of `dyn.Path` to callback function (#1747)
## Changes

Some call sites hold on to the `dyn.Path` provided to them by the
callback. It must therefore never be mutated after the callback returns,
or these mutations leak out into unknown scope.

This change means it is no longer possible for this failure mode to
happen.

## Tests

Unit test.
2024-09-05 11:05:16 +00:00
Andrew Nester 72030844c5
Fixed variable override in target with full variable syntax (#1749)
## Changes
This PR makes sure that both of this override syntax for variables work
correctly
```
targets:
  dev:
    variables:
      cluster1:
        spark_version: "14.2.x-scala2.11"
        node_type_id: "Standard_DS3_v2"
        num_workers: 4
        spark_conf:
          spark.speculation: false
          spark.databricks.delta.retentionDurationCheck.enabled: false
      cluster2:
        default:
          spark_version: "14.2.x-scala2.11"
          node_type_id: "Standard_DS3_v2"
          num_workers: 4
          spark_conf:
            spark.speculation: false
            spark.databricks.delta.retentionDurationCheck.enabled: false
```
## Tests
Added regression test

---------

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
2024-09-04 17:16:40 +00:00
Shreyas Goenka 42da1c97ba
Merge remote-tracking branch 'origin' into improve/json-schema 2024-09-04 13:41:43 +02:00
Andrew Nester ca6332a5a4
Fixed complex variables are not being correctly merged from include files (#1746)
## Changes
Fixes an `Error: no value assigned to required variable <variable>.`
when the main complex variable definition is defined in one file but
target override is defined in separate file which is included in the
main one.

## Tests
Added regression test
2024-09-04 11:24:55 +00:00
shreyas-goenka a27c24a397
Add prompt when a pipeline recreation happens (#1672)
## Changes
DLT pipeline recreations are destructive. They can lead to lost history
of previous updates, outage of the tables temporarily and are
potentially computationally expensive. Thus we make a breaking change
where a prompt is shown to the user if there configuration changes will
lead to a DLT recreation.

Users can skip the prompt by specifying  the `--auto-approve` flag.

This PR also fixes an issue with our test runner where logs from the
cmdio.Logger would not get propagated to the reader returned by our
cobra test runner.

## Tests
Manually, and new unit and integration tests.

```
➜  bundle-playground-3 cli bundle deploy
Uploading bundle files to /Users/63ec021d-b0c6-49c0-93a0-5123953a1cb2/.bundle/test/development/files...
The following DLT pipelines will be recreated. Underlying tables will be unavailable for a transient period until the newly recreated pipelines are run once successfully. History of previous pipeline update runs will be lost because of recreation:
  recreate pipeline foo

Would you like to proceed? [y/n]: n
Deployment cancelled!
```
2024-09-04 11:11:47 +00:00
Shreyas Goenka a64857ed4c
- 2024-09-04 11:58:02 +02:00
Shreyas Goenka bfe9cc4d50
create generated package 2024-09-04 11:56:52 +02:00
Shreyas Goenka 446463b9eb
update schema 2024-09-04 11:33:28 +02:00
Shreyas Goenka 9d9c6120a1
Merge remote-tracking branch 'origin' into improve/json-schema 2024-09-04 11:32:49 +02:00
Shreyas Goenka ba3f004da1
schema local to generator 2024-09-04 11:32:39 +02:00
shreyas-goenka 096123674a
Fix streaming of stdout, stdin, stderr in cobra test runner (#1742)
## Changes
We were not using the readers and writers set in the test fixtures in
the progress logger. This PR fixes that. It also modifies
`TestAccAbortBind`, which was implicitly relying on the bug.

I encountered this bug while working on
https://github.com/databricks/cli/pull/1672.

## Tests
Manually. 

From non-tty:
```
Error: failed to bind the resource, err: This bind operation requires user confirmation, but the current console does not support prompting. Please specify --auto-approve if you would like to skip prompts and proceed.
```

From tty, bind works as expected.
```
Confirm import changes? Changes will be remotely applied only after running 'bundle deploy'. [y/n]: y
Updating deployment state...
Successfully bound databricks_pipeline with an id '9d2dedbb-f522-4503-96ba-4bc4d5bfa77d'. Run 'bundle deploy' to deploy changes to your workspace
```
2024-09-02 13:43:17 +00:00
Gleb Kanterov ed448815b4
PythonMutator: explain missing package error (#1736)
## Changes
Explain the error when the `databricks-pydabs` package is not installed
or the Python environment isn't correctly activated.

Example output:

```
Error: python mutator process failed: ".venv/bin/python3 -m databricks.bundles.build --phase load --input .../input.json --output .../output.json --diagnostics .../diagnostics.json: exit status 1", use --debug to enable logging

.../.venv/bin/python3: Error while finding module specification for 'databricks.bundles.build' (ModuleNotFoundError: No module named 'databricks')

Explanation: 'databricks-pydabs' library is not installed in the Python environment.

If using Python wheels, ensure that 'databricks-pydabs' is included in the dependencies, 
and that the wheel is installed in the Python environment:

  $ .venv/bin/pip install -e .

If using a virtual environment, ensure it is specified as the venv_path property in databricks.yml, 
or activate the environment before running CLI commands:

  experimental:
    pydabs:
      venv_path: .venv
```

## Tests
Unit tests
2024-09-02 09:49:30 +00:00
Andrew Nester 582558cac2
Do not suppress normalisation diagnostics for resolving variables (#1740)
## Changes

Tested on the following bundle configuration

```
bundle:
  name: clusters
  mode: development

variables:
  webhook_notifications:
    description: Webhook URL for notifications
    type: complex
    default:
      on_failure:
        id: 6a6c04c1-389c-4534-95af-b68b62a9dbe6

resources:
  jobs:
    test_job:
      name: "Andrew Nester Test Job"
      tasks:
        - task_key: test_task
          notebook_task:
            notebook_path: "./src/test.py"
          new_cluster:
            num_workers: 2
            node_type_id: "i3.xlarge"
            autoscale:
              min_workers: 2
              max_workers: 7
            spark_version: "12.2.x-scala2.12"
            spark_conf:
              "spark.executor.memory": "2g"
      webhook_notifications: ${var.webhook_notifications}

```

bundle validate output is below

```
andrew.nester@HFW9Y94129 wheel % databricks bundle validate
Warning: expected sequence, found map
  at resources.jobs.test_job.webhook_notifications.on_failure
  in bundle.yml:11:9

Name: clusters
Target: default
Workspace:
  User: andrew.nester@databricks.com
  Path: /Users/andrew.nester@databricks.com/.bundle/clusters/default
```

**Note** that error correctly points to the variable
2024-09-02 09:17:18 +00:00
shreyas-goenka 5d9910c8e0
Make lock optional in the JSON schema (#1738)
Fixes https://github.com/databricks/cli/issues/1561
2024-09-02 08:39:08 +00:00
Gleb Kanterov 70ce802518
PythonMutator: preserve normalize diagnostics (#1735)
## Changes
Preserve diagnostics if there are any errors or warnings when
PythonMutator normalizes output. If anything goes wrong during
conversion, diagnostics contain the relevant location and path.

## Tests
Unit tests
2024-08-30 13:29:00 +00:00
Pieter Noordhuis 5fac7edcdf
Pass along $AZURE_CONFIG_FILE to Terraform process (#1734)
## Changes

This ensures that the CLI and Terraform can both use an Azure CLI
session configured under a non-standard path. This is the default
behavior on Azure DevOps when using the AzureCLI@2 task.

Fixes #1722.

## Tests

Unit test.
2024-08-29 14:41:12 +00:00
Andrew Nester 43ace69bb9
Consider serverless clusters as compatible for Python wheel tasks (#1733)
## Changes
Consider serverless clusters as compatible for Python wheel tasks.

Fixes a `Python wheel tasks require compute with DBR 13.3+ to include
local libraries` warning shown for serverless clusters
2024-08-29 12:47:44 +00:00
Lennart Kats (databricks) 85459c1963
Improve error handling for /Volumes paths in mode: development (#1716)
## Changes
* Provide a more helpful error when using an artifact_path based on
/Volumes
* Allow the use of short_names in /Volumes paths

## Example cases

Example of a valid /Volumes artifact_path:
* `artifact_path:
/Volumes/catalog/schema/${workspace.current_user.short_name}/libs`

Example of an invalid /Volumes path (when using `mode: development`):
* `artifact_path: /Volumes/catalog/schema/libs`
* Resulting error: `artifact_path should contain the current username or
${workspace.current_user.short_name} to ensure uniqueness when using
'mode: development'`
2024-08-28 12:14:19 +00:00
Andrew Nester 70363836d5
Correctly mark PyPI package name specs with multiple specifiers as remote libraries (#1725)
Correctly mark pypi package name specs with multiple specifiers as
remote libraries

Fixes this https://github.com/databricks/cli/issues/1728
2024-08-28 11:39:06 +00:00
Shreyas Goenka cb8d6a9f60
self pass 1 2024-08-27 19:50:43 +02:00
Shreyas Goenka 4141f4ea34
- 2024-08-27 17:49:09 +02:00
Shreyas Goenka 40f4d35c4a
cleanup todos 2024-08-27 17:45:20 +02:00
Shreyas Goenka ad7503a176
cleanup todos 2024-08-27 17:40:36 +02:00
Shreyas Goenka f194a5b86a
skip adding patterns for string schemas 2024-08-27 17:36:12 +02:00