Repository navigation
Expand file tree
/
Copy pathmake.ps1
More file actions
84 lines (76 loc) · 2.9 KB
/
Copy pathmake.ps1
File metadata and controls
84 lines (76 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
param(
[Parameter(Position = 0)]
[string]$Task,
[string]$Profile,
[string]$Target,
[switch]$Release,
[string]$AppName = 'dqx-studio',
[switch]$Force,
[string[]]$BundleVars = @()
)
$ErrorActionPreference = 'Stop'
if ($Task -ne 'app-deploy') {
throw 'Supported target: app-deploy'
}
if ($Release) {
if ($Target -and $Target -ne 'release') {
throw '-Release cannot be combined with a different -Target.'
}
$Target = 'release'
}
if ([string]::IsNullOrWhiteSpace($Profile) -or [string]::IsNullOrWhiteSpace($Target)) {
throw 'Usage: ./make.ps1 app-deploy -Profile <databricks-profile> (-Target <bundle-target> | -Release) [-Force] [-BundleVars name=value,...]'
}
if (-not (Get-Command databricks -ErrorAction SilentlyContinue)) {
throw "Databricks CLI not found on PATH. Install it from https://docs.databricks.com/dev-tools/cli/install.html"
}
$cliVersionOutput = (& databricks --version) -join "`n"
if ($LASTEXITCODE -ne 0 -or $cliVersionOutput -notmatch '(\d+\.\d+\.\d+)') {
throw 'Could not read the Databricks CLI version.'
}
$cliVersion = [version]$Matches[1]
if ($cliVersion -lt [version]'1.4.0') {
throw "Databricks CLI v$cliVersion is too old; v1.4.0 or later is required for DQX Studio deployment."
}
if ($Target -ne 'release' -and -not (Get-Command uv -ErrorAction SilentlyContinue)) {
throw 'uv not found on PATH. Install uv before building DQX Studio from source.'
}
$bundleArgs = @('-p', $Profile, '-t', $Target)
$variableArgs = @()
foreach ($variable in $BundleVars) {
$variableArgs += @('--var', $variable)
}
if ($PSBoundParameters.ContainsKey('AppName')) {
$variableArgs += @('--var', "app_name=$AppName")
}
$previousFrozen = $env:UV_FROZEN
$previousBuildConstraint = $env:UV_BUILD_CONSTRAINT
$locationPushed = $false
try {
Push-Location (Join-Path $PSScriptRoot 'app')
$locationPushed = $true
if ($Target -ne 'release') {
$env:UV_FROZEN = '1'
$env:UV_BUILD_CONSTRAINT = '.build-constraints.txt'
& uv run --exact --all-extras python scripts/build_app.py
if ($LASTEXITCODE -ne 0) { throw 'DQX Studio build failed.' }
}
$deployArgs = @('bundle', 'deploy') + $bundleArgs
if ($Force) { $deployArgs += '--force' }
$deployArgs += $variableArgs
& databricks @deployArgs
if ($LASTEXITCODE -ne 0) { throw 'DQX Studio bundle deploy failed.' }
& databricks bundle run dqx-studio @bundleArgs @variableArgs
if ($LASTEXITCODE -ne 0) { throw 'DQX Studio bundle run failed.' }
}
finally {
try {
if ($locationPushed) { Pop-Location }
}
finally {
if ($null -eq $previousFrozen) { Remove-Item Env:UV_FROZEN -ErrorAction SilentlyContinue }
else { $env:UV_FROZEN = $previousFrozen }
if ($null -eq $previousBuildConstraint) { Remove-Item Env:UV_BUILD_CONSTRAINT -ErrorAction SilentlyContinue }
else { $env:UV_BUILD_CONSTRAINT = $previousBuildConstraint }
}
}