Commit Graph

526 Commits

Author SHA1 Message Date
shreyas-goenka caa8d64ffd
Merge branch 'main' into detect-convention 2024-10-02 23:58:25 +05:30
shreyas-goenka 361f59087e
Update bundle/config/loader/process_include.go
Co-authored-by: Lennart Kats (databricks) <lennart.kats@databricks.com>
2024-10-02 23:58:10 +05:30
shreyas-goenka b1d7c7bdb7
Update bundle/config/loader/process_include.go
Co-authored-by: Lennart Kats (databricks) <lennart.kats@databricks.com>
2024-10-02 23:57:26 +05:30
shreyas-goenka b288b0701d
Update bundle/config/loader/process_include.go
Co-authored-by: Lennart Kats (databricks) <lennart.kats@databricks.com>
2024-10-02 23:57:20 +05:30
shreyas-goenka d064566fc9
Update bundle/config/loader/process_include.go
Co-authored-by: Lennart Kats (databricks) <lennart.kats@databricks.com>
2024-10-02 23:57:12 +05:30
Shreyas Goenka a737977d6f
address comments 2024-10-02 20:26:42 +02:00
Andrew Nester a8cff48c0b
Always prepend bundle remote paths with /Workspace (#1724)
## Changes
Due to platform changes, all libraries, notebooks and etc. paths used in
Databricks must be started with either /Workspace or /Volumes prefix.

This PR makes sure that all bundle paths are correctly prefixed.

Note: this change is a breaking change if user previously configured and
used `/Workspace/Workspace` folder in their workspace file system or
having `/Workspace/${workspace.root_path}...` pattern configured
anywhere in their bundle config

Fixes: #1751

AI:
- [x] Scan DABs config and error out on
`/Workspace/${workspace.root_path}...` pattern usage

## Tests
Added unit tests

---------

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
2024-10-02 15:34:00 +00:00
Pieter Noordhuis 80d55f4540
Add resource path field to bundle workspace configuration (#1800)
## Changes

Default workspace path for resources with a presence in the workspace
tree.

Note: this path is **not** created automatically (yet). We need this
only for dashboards (so far), so can take care of creation if one or
more dashboards are part of a deployment. This saves an API call for
deployments where this is not necessary.

## Tests

Expanded existing tests.
2024-10-02 13:55:40 +00:00
Andrew Nester 044a00c7f9
Add an error if state files grow bigger than the export limit (#1795)
## Changes
Currently API limits on exporting files from workspaces are set at 10
MBs while uploading to is 500 MBs. We want to prevent users running into
deadlock when they won't be able to pull state file anymore so we
prevent from uploading large state files (over 10 MBs) to Databricks
workspace.
2024-10-02 13:53:24 +00:00
Andrew Nester 84fc1ed131
Upgrade to Go SDK 0.47.0 (#1799)
## Changes
Upgrade to Go SDK 0.47.0

## Tests
<!-- How is this tested? -->
2024-10-01 10:44:47 +00:00
Lennart Kats (databricks) da3b4f7c72
Fix panic in `apply_presets.go` (#1796)
## Changes

This fixes the user-reported panic in `apply_presets.go`. I'm still
unsure how to reproduce this, since the CLI just reports `ob broken_job
is not defined` when I try to use `bundle deploy` with an empty job.
That said — we may as well be defensive here and I see we have lots of
checks for empty job/cluster/etc. settings scattered throughout our code
base so at least we're somewhat consistent.
2024-09-29 14:08:10 +00:00
Shreyas Goenka 90f360b08b
- 2024-09-27 13:50:18 +02:00
Shreyas Goenka dd10eedb14
merge 2024-09-27 13:45:13 +02:00
Shreyas Goenka dd20a52743
terser recommendation message 2024-09-27 13:42:48 +02:00
Shreyas Goenka 367048bde5
account for the oxford comma 2024-09-27 13:36:22 +02:00
Shreyas Goenka e22ba75062
remove todo 2024-09-27 12:58:33 +02:00
Shreyas Goenka 14e73acb11
- 2024-09-27 12:57:49 +02:00
Shreyas Goenka dd28a56b7d
address comments 2024-09-27 12:56:53 +02:00
Shreyas Goenka b4bd47f4ba
fail -> not match 2024-09-27 12:55:54 +02:00
Shreyas Goenka 65ad2f0557
add test for multiple resources 2024-09-27 12:04:33 +02:00
Pieter Noordhuis 1d1aa0a416
Rename `RootPath` -> `BundleRootPath` (#1792)
## Changes

After introducing the `SyncRootPath` field on the bundle (#1694), the
previous `RootPath` became ambiguous. Does it mean the bundle root path
or the sync root path? This PR renames to field to `BundleRootPath` to
remove the ambiguity.

## Tests

n/a

---------

Co-authored-by: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com>
2024-09-27 10:03:05 +00:00
Pieter Noordhuis 56cd96cb93
Move trampoline code into trampoline package (#1793)
## Changes

Doing this to make room for PyDABs under `bundle/python`.

## Tests

n/a
2024-09-27 09:32:54 +00:00
Pieter Noordhuis a1dca56abf
Trim trailing whitespace (#1794)
## Changes

Trailing whitespace is trimmed per the VS Code settings for this
repository.

## Tests

n/a
2024-09-27 09:30:39 +00:00
Shreyas Goenka 4373e7b513
make unit test package separate 2024-09-26 17:57:24 +02:00
Shreyas Goenka 28917ebdab
- 2024-09-26 17:55:09 +02:00
Shreyas Goenka 3203858032
add comment 2024-09-26 17:48:15 +02:00
Shreyas Goenka fec73db111
address comments 2024-09-26 17:47:07 +02:00
Shreyas Goenka 4cc0dd1fa1
Merge remote-tracking branch 'origin' into detect-convention 2024-09-26 17:33:44 +02:00
Shreyas Goenka 6040e58262
complete info to recommendation 2024-09-26 17:23:51 +02:00
Shreyas Goenka d9cf582287
fix failing tests 2024-09-26 17:14:43 +02:00
Shreyas Goenka 4734249854
convert inline tests to files 2024-09-26 16:51:46 +02:00
Shreyas Goenka d14b1e2cca
directly pass config value 2024-09-26 16:07:32 +02:00
Shreyas Goenka 5308ad8bf3
split into summary and detail 2024-09-26 16:03:49 +02:00
Shreyas Goenka fd01824ee1
- 2024-09-26 15:39:41 +02:00
shreyas-goenka 4e8e027380
Sort tasks by `task_key` before generating the Terraform configuration (#1776)
## Changes
Sort the tasks in the resultant `bundle.tf.json`. This is important
because configuration from one task can leak into another if the tasks
are not sorted.

For more details see:
1.
https://github.com/databricks/terraform-provider-databricks/issues/3951
2.
https://github.com/databricks/terraform-provider-databricks/issues/4011

## Tests
Unit test and manually.

For manual testing I used the following configuration:
```
resources:
  jobs:
    foo:
      tasks: 
        - task_key: task-Z
          notebook_task: 
            notebook_path: nb.py
            source: GIT
          existing_cluster_id: 0715-133738-ju0ma84z

        - task_key: task-1
          notebook_task: 
            notebook_path: ${workspace.file_path}/local.py
            source: WORKSPACE
          existing_cluster_id: 0715-133738-ju0ma84z
          depends_on: 
            - task_key: task-Z


      git_source: 
        git_provider: gitHub
        git_url: https://github.com/shreyas-goenka/job-source-tmp.git
        git_branch: main
```

Steps (1):
1. Deploy this bundle.
2. Comment out "source: GIT"
3. Deploy again

Before:
Deploying this bundle twice would fail. This is because the "source:
GIT" would carry over to the next deployment.

After:
There was no error on the subsequent deployment.

Steps (2):
1. Deploy once
2. Deploy again

Before:
Works correctly but leads to a update API call every time.

After:
No diff is detected by terraform.
2024-09-26 13:22:22 +00:00
Andrew Nester 66f2ba64a8
Simplified isFullVariableOverrideDef implementation (#1791)
## Changes
Simplified isFullVariableOverrideDef implementation

Follow up on https://github.com/databricks/cli/pull/1787
2024-09-26 12:55:07 +00:00
shreyas-goenka 495040e4cd
Modify SetLocation test utility to take full locations as argument (#1788)
I plan to use this in https://github.com/databricks/cli/pull/1780, to
set the line and column numbers as well for the locations.

gopatch file used:
```
@@
var x expression
var y expression
var z expression
@@
-bundletest.SetLocation(x, y, z)
+bundletest.SetLocation(x, y, []dyn.Location{{File: z}})
```
2024-09-25 16:13:48 +00:00
Andrew Nester b3a3071086
Fixed full variable override detection (#1787)
## Changes
Fixes #1786 

## Tests
All valid override combinations are added as test cases
2024-09-25 12:35:16 +00:00
Gleb Kanterov 3d9decdda9
Add JobTaskClusterSpec validate mutator (#1784)
## Changes
Add JobTaskClusterSpec validate mutator. It catches the case when tasks
don't which cluster to use.

For example, we can get this error with minor modifications to
`default-python` template:

```yaml
      tasks:
        - task_key: python_file_task
          spark_python_task:
            python_file: ../src/my_project_10/main.py
```

```
 % databricks bundle validate
Error: Missing required cluster or environment settings
  at resources.jobs.my_project_10_job.tasks[0]
  in resources/my_project_10_job.yml:17:11

Task "print_github_stars" requires a cluster or an environment to run.
Specify one of the following fields: job_cluster_key, environment_key, existing_cluster_id, new_cluster.
```

We implicitly rely on "one of" validation, which does not exist. Many
bundle fields can't co-exist, for instance, specifying:
`JobTask.{existing_cluster_id,job_cluster_key}`, `Library.{whl,pypi}`,
`JobTask.{notebook_task,python_wheel_task}`, etc.

## Tests
Unit tests

---------

Co-authored-by: Pieter Noordhuis <pcnoordhuis@gmail.com>
2024-09-25 11:30:14 +00:00
Shreyas Goenka 894f4aab4e
fix windows test 2024-09-24 17:54:13 +02:00
Shreyas Goenka e31dcc2724
fix logic for dedup 2024-09-24 17:47:48 +02:00
Shreyas Goenka 5bf916357a
return if diags has error 2024-09-24 17:42:03 +02:00
Shreyas Goenka f3d7f09150
fix failing tests 2024-09-24 17:39:20 +02:00
Shreyas Goenka 3571410209
cleanup todos 2024-09-24 17:31:50 +02:00
Shreyas Goenka ccbd199422
add info block 2024-09-24 17:29:10 +02:00
Shreyas Goenka fa6b68c410
add unit tests 2024-09-24 16:39:02 +02:00
Gleb Kanterov 490259a14a
Refactor jobs path translation (#1782)
## Changes
Extract package for other modules to transform different kinds of paths
in job resources.

## Tests
Unit tests
2024-09-24 13:51:54 +00:00
Shreyas Goenka e9426bea8c
- 2024-09-24 14:50:38 +02:00
Shreyas Goenka 5c351d7ea3
more wip on making it work 2024-09-24 14:49:57 +02:00
Shreyas Goenka 458dbfb04d
- 2024-09-24 14:49:41 +02:00