mirror of https://github.com/databricks/cli.git
Compare commits
7 Commits
1378da8086
...
a65de002df
Author | SHA1 | Date |
---|---|---|
Gleb Kanterov | a65de002df | |
dependabot[bot] | 4b069bb6e1 | |
Gleb Kanterov | bbcbffd7f4 | |
Gleb Kanterov | 6b4641c530 | |
Gleb Kanterov | 55c36bc2fa | |
Gleb Kanterov | 6fd701ec84 | |
Gleb Kanterov | 37d677c079 |
|
@ -38,7 +38,7 @@ jobs:
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.9'
|
python-version: '3.10'
|
||||||
|
|
||||||
- name: Set go env
|
- name: Set go env
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
bundle:
|
||||||
|
name: python-import-dataclass-no-wheel
|
||||||
|
|
||||||
|
experimental:
|
||||||
|
pydabs:
|
||||||
|
enabled: true
|
||||||
|
import:
|
||||||
|
- "my_job"
|
||||||
|
|
||||||
|
variables:
|
||||||
|
default_cluster_spec:
|
||||||
|
type: complex
|
||||||
|
value:
|
||||||
|
num_workers: 1
|
||||||
|
spark_version: "15.4.x-scala2.12"
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Databricks Notebook Source
|
||||||
|
1+1
|
|
@ -0,0 +1,22 @@
|
||||||
|
from databricks.bundles.jobs import Job, Task, NotebookTask, JobCluster
|
||||||
|
from databricks.bundles.variables import Bundle
|
||||||
|
|
||||||
|
my_job = Job(
|
||||||
|
name="Test Job",
|
||||||
|
resource_name="my_job",
|
||||||
|
job_clusters=[
|
||||||
|
JobCluster(
|
||||||
|
job_cluster_key="my_cluster",
|
||||||
|
new_cluster=Bundle.variables.default_cluster_spec,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
tasks=[
|
||||||
|
Task(
|
||||||
|
task_key="my_notebook_task",
|
||||||
|
job_cluster_key="my_cluster",
|
||||||
|
notebook_task=NotebookTask(
|
||||||
|
notebook_path="notebooks/my_notebook.py",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
|
@ -0,0 +1,95 @@
|
||||||
|
package config_tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
pathlib "path"
|
||||||
|
"runtime"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
|
"github.com/databricks/cli/libs/dyn"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPythonImport_dataclass_no_wheel(t *testing.T) {
|
||||||
|
activateVEnv(t)
|
||||||
|
setPythonPath(t, "python_import/dataclass_no_wheel/src")
|
||||||
|
|
||||||
|
expected := &resources.Job{
|
||||||
|
JobSettings: &jobs.JobSettings{
|
||||||
|
Name: "Test Job",
|
||||||
|
JobClusters: []jobs.JobCluster{
|
||||||
|
{
|
||||||
|
JobClusterKey: "my_cluster",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Tasks: []jobs.Task{
|
||||||
|
{
|
||||||
|
NotebookTask: &jobs.NotebookTask{
|
||||||
|
NotebookPath: "notebooks/my_notebook.py",
|
||||||
|
},
|
||||||
|
JobClusterKey: "my_cluster",
|
||||||
|
TaskKey: "my_notebook_task",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
b := load(t, "./python_import/dataclass_no_wheel")
|
||||||
|
|
||||||
|
assert.Equal(t, []string{"my_job"}, maps.Keys(b.Config.Resources.Jobs))
|
||||||
|
|
||||||
|
myJob := b.Config.Resources.Jobs["my_job"]
|
||||||
|
assert.Equal(t, expected, myJob)
|
||||||
|
|
||||||
|
// NewCluster is reference to a variable and needs to be checked separately
|
||||||
|
err := b.Config.Mutate(func(value dyn.Value) (dyn.Value, error) {
|
||||||
|
path := dyn.MustPathFromString("resources.jobs.my_job.job_clusters[0].new_cluster")
|
||||||
|
value, err := dyn.GetByPath(value, path)
|
||||||
|
if err != nil {
|
||||||
|
return dyn.InvalidValue, err
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, "${var.default_cluster_spec}", value.AsAny())
|
||||||
|
|
||||||
|
return value, nil
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func setPythonPath(t *testing.T, path string) {
|
||||||
|
wd, err := os.Getwd()
|
||||||
|
require.NoError(t, err)
|
||||||
|
t.Setenv("PYTHONPATH", pathlib.Join(wd, path))
|
||||||
|
}
|
||||||
|
|
||||||
|
func activateVEnv(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
venvDir := pathlib.Join(dir, "venv")
|
||||||
|
|
||||||
|
err := exec.Command("python3", "-m", "venv", venvDir).Run()
|
||||||
|
require.NoError(t, err, "failed to create venv")
|
||||||
|
|
||||||
|
// we don't have shell to activate venv, updating PATH is enough
|
||||||
|
|
||||||
|
var venvBinDir string
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
venvBinDir = pathlib.Join(venvDir, "Scripts")
|
||||||
|
t.Setenv("PATH", venvBinDir+";"+os.Getenv("PATH"))
|
||||||
|
} else {
|
||||||
|
venvBinDir = pathlib.Join(venvDir, "bin")
|
||||||
|
t.Setenv("PATH", venvBinDir+":"+os.Getenv("PATH"))
|
||||||
|
}
|
||||||
|
|
||||||
|
err = exec.Command(
|
||||||
|
pathlib.Join(venvBinDir, "pip"),
|
||||||
|
"install",
|
||||||
|
"databricks-pydabs==0.5.1",
|
||||||
|
).Run()
|
||||||
|
require.NoError(t, err, "failed to install databricks-pydabs")
|
||||||
|
}
|
4
go.mod
4
go.mod
|
@ -27,7 +27,7 @@ require (
|
||||||
golang.org/x/mod v0.22.0
|
golang.org/x/mod v0.22.0
|
||||||
golang.org/x/oauth2 v0.24.0
|
golang.org/x/oauth2 v0.24.0
|
||||||
golang.org/x/sync v0.9.0
|
golang.org/x/sync v0.9.0
|
||||||
golang.org/x/term v0.25.0
|
golang.org/x/term v0.26.0
|
||||||
golang.org/x/text v0.20.0
|
golang.org/x/text v0.20.0
|
||||||
gopkg.in/ini.v1 v1.67.0 // Apache 2.0
|
gopkg.in/ini.v1 v1.67.0 // Apache 2.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
|
@ -64,7 +64,7 @@ require (
|
||||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||||
golang.org/x/crypto v0.24.0 // indirect
|
golang.org/x/crypto v0.24.0 // indirect
|
||||||
golang.org/x/net v0.26.0 // indirect
|
golang.org/x/net v0.26.0 // indirect
|
||||||
golang.org/x/sys v0.26.0 // indirect
|
golang.org/x/sys v0.27.0 // indirect
|
||||||
golang.org/x/time v0.5.0 // indirect
|
golang.org/x/time v0.5.0 // indirect
|
||||||
google.golang.org/api v0.182.0 // indirect
|
google.golang.org/api v0.182.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect
|
||||||
|
|
|
@ -212,10 +212,10 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
|
||||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
|
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
|
||||||
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
|
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
|
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
|
||||||
|
|
Loading…
Reference in New Issue