mirror of https://github.com/databricks/cli.git
Compare commits
8 Commits
a65de002df
...
f582c7962b
Author | SHA1 | Date |
---|---|---|
Gleb Kanterov | f582c7962b | |
dependabot[bot] | 85c0d2d3ee | |
dependabot[bot] | 026c5555b2 | |
Gleb Kanterov | bbcbffd7f4 | |
Gleb Kanterov | 6b4641c530 | |
Gleb Kanterov | 55c36bc2fa | |
Gleb Kanterov | 6fd701ec84 | |
Gleb Kanterov | 37d677c079 |
|
@ -38,7 +38,7 @@ jobs:
|
|||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.9'
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Set go env
|
||||
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
|
@ -5,7 +5,7 @@ go 1.23
|
|||
toolchain go1.23.2
|
||||
|
||||
require (
|
||||
github.com/Masterminds/semver/v3 v3.3.0 // MIT
|
||||
github.com/Masterminds/semver/v3 v3.3.1 // MIT
|
||||
github.com/briandowns/spinner v1.23.1 // Apache 2.0
|
||||
github.com/databricks/databricks-sdk-go v0.51.0 // Apache 2.0
|
||||
github.com/fatih/color v1.18.0 // MIT
|
||||
|
@ -22,7 +22,7 @@ require (
|
|||
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // MIT
|
||||
github.com/spf13/cobra v1.8.1 // Apache 2.0
|
||||
github.com/spf13/pflag v1.0.5 // BSD-3-Clause
|
||||
github.com/stretchr/testify v1.9.0 // MIT
|
||||
github.com/stretchr/testify v1.10.0 // MIT
|
||||
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
|
||||
golang.org/x/mod v0.22.0
|
||||
golang.org/x/oauth2 v0.24.0
|
||||
|
|
|
@ -8,8 +8,8 @@ cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1h
|
|||
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
|
||||
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
|
||||
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
|
||||
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
|
||||
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
|
||||
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=
|
||||
|
@ -156,8 +156,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
|
||||
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
|
||||
github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ=
|
||||
|
|
Loading…
Reference in New Issue