Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from flask import Flask

app = Flask(__name__)


@app.route("/")
def home():
return "Hello!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
command:
- flask
- --app
- app
- run

env:
- name: FROM_APP_YAML
value: "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bundle:
name: start-deployment-apps-start-$UNIQUE_NAME

resources:
apps:
myapp:
name: $UNIQUE_NAME
source_code_path: ./app
config:
command: ["flask", "--app", "app", "run"]
env:
- name: FROM_BUNDLE_CONFIG
value: "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
EnvMatrix.DMS = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

=== Deploy: the app is created stopped and nothing is deployed to it

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/start-deployment-apps-start-[UNIQUE_NAME]/default/files...
Created apps.myapp
Files: 4 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

>>> [CLI] apps get [UNIQUE_NAME]
{
"active_deployment": null,
"pending_deployment": null
}

=== Start the compute outside the bundle: the bundle has not deployed anything, so the app has no deployment

>>> errcode [CLI] apps start [UNIQUE_NAME]
"ACTIVE"

>>> [CLI] apps get [UNIQUE_NAME]
{
"active_deployment": null,
"pending_deployment": null
}

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.apps.myapp

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/start-deployment-apps-start-[UNIQUE_NAME]/default

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace $CLI bundle destroy --auto-approve
}
trap cleanup EXIT

# wait_for_deployments gives a deployment that the backend starts by itself time to show up
# and to finish. Only a real workspace can start one, so there is nothing to wait for locally.
wait_for_deployments() {
if [ -z "$CLOUD_ENV" ]; then
return 0
fi
local states
for i in $(seq 60); do
sleep 10
states=$($CLI apps get "$1" | jq -r '[.active_deployment, .pending_deployment | select(. != null) | .status.state] | join(" ")')
echo "poll $i: deployment states: [$states]" >> LOG.wait_for_deployments
if [ -z "$states" ] && [ "$i" -ge 6 ]; then
return 0
fi
if [ -n "$states" ] && [[ "$states" != *IN_PROGRESS* ]]; then
return 0
fi
done
}

title "Deploy: the app is created stopped and nothing is deployed to it"
trace $CLI bundle deploy
trace $CLI apps get $UNIQUE_NAME | app_deployments

# The source folder has an app.yaml that runs, with a different env var than the bundle's
# inline config, so a deployment made from the folder alone is told apart from the bundle's.
title "Start the compute outside the bundle: the bundle has not deployed anything, so the app has no deployment"
{ trace errcode $CLI apps start $UNIQUE_NAME | jq '.compute_status.state'; } || true
wait_for_deployments $UNIQUE_NAME
$CLI apps get $UNIQUE_NAME > LOG.app_after_start
trace $CLI apps get $UNIQUE_NAME | app_deployments
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from flask import Flask

app = Flask(__name__)


@app.route("/")
def home():
return "Hello!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bundle:
name: start-deployment-bundle-run-$UNIQUE_NAME

resources:
apps:
myapp:
name: $UNIQUE_NAME
source_code_path: ./app
config:
command: ["flask", "--app", "app", "run"]
env:
- name: FROM_BUNDLE_CONFIG
value: "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
EnvMatrix.DMS = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

=== Deploy: the app is created stopped and nothing is deployed to it

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/start-deployment-bundle-run-[UNIQUE_NAME]/default/files...
Created apps.myapp
Files: 3 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

=== Run: the compute is started and the source is deployed with the inline config

>>> errcode [CLI] bundle run myapp
You can access the app at [APP_URL]

>>> [CLI] apps get [UNIQUE_NAME]
{
"active_deployment": {
"command": [
"flask",
"--app",
"app",
"run"
],
"env_vars": [
{
"name": "FROM_BUNDLE_CONFIG"
}
],
"state": "SUCCEEDED"
},
"pending_deployment": null
}

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.apps.myapp

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/start-deployment-bundle-run-[UNIQUE_NAME]/default

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace $CLI bundle destroy --auto-approve
}
trap cleanup EXIT

# The source folder has no app.yaml: the inline config is the only place that says how to
# run the app.
title "Deploy: the app is created stopped and nothing is deployed to it"
trace $CLI bundle deploy

title "Run: the compute is started and the source is deployed with the inline config"
trace errcode $CLI bundle run myapp
$CLI apps get $UNIQUE_NAME > LOG.app_after_run
trace $CLI apps get $UNIQUE_NAME | app_deployments
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from flask import Flask

app = Flask(__name__)


@app.route("/")
def home():
return "Hello!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bundle:
name: start-deployment-on-create-$UNIQUE_NAME

resources:
apps:
myapp:
name: $UNIQUE_NAME
source_code_path: ./app
config:
command: ["flask", "--app", "app", "run"]
env:
- name: FROM_BUNDLE_CONFIG
value: "1"
lifecycle:
started: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
EnvMatrix.DMS = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

=== Deploy with lifecycle.started=true: the app is created with compute and the source is deployed with the inline config

>>> errcode [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/start-deployment-on-create-[UNIQUE_NAME]/default/files...
Created apps.myapp
Files: 3 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

>>> [CLI] apps get [UNIQUE_NAME]
{
"active_deployment": {
"command": [
"flask",
"--app",
"app",
"run"
],
"env_vars": [
{
"name": "FROM_BUNDLE_CONFIG"
}
],
"state": "SUCCEEDED"
},
"pending_deployment": null
}

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.apps.myapp

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/start-deployment-on-create-[UNIQUE_NAME]/default

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace $CLI bundle destroy --auto-approve
}
trap cleanup EXIT

# The source folder has no app.yaml: the inline config is the only place that says how to
# run the app.
title "Deploy with lifecycle.started=true: the app is created with compute and the source is deployed with the inline config"
trace errcode $CLI bundle deploy
$CLI apps get $UNIQUE_NAME > LOG.app_after_deploy
trace $CLI apps get $UNIQUE_NAME | app_deployments
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from flask import Flask

app = Flask(__name__)


@app.route("/")
def home():
return "Hello!"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bundle:
name: start-deployment-on-update-$UNIQUE_NAME

resources:
apps:
myapp:
name: $UNIQUE_NAME
source_code_path: ./app
config:
command: ["flask", "--app", "app", "run"]
env:
- name: FROM_BUNDLE_CONFIG
value: "1"
lifecycle:
started: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
EnvMatrix.DMS = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

=== Deploy with lifecycle.started=false: the app is created stopped and nothing is deployed to it

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/start-deployment-on-update-[UNIQUE_NAME]/default/files...
Created apps.myapp
Files: 3 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

=== Deploy with lifecycle.started=true: the compute is started and the source is deployed with the inline config

>>> update_file.py databricks.yml started: false started: true

>>> errcode [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/start-deployment-on-update-[UNIQUE_NAME]/default/files...
Updated apps.myapp
Files: 1 uploaded, 0 deleted
Resources: 0 created, 1 changed, 0 deleted, 0 unchanged

>>> [CLI] apps get [UNIQUE_NAME]
{
"active_deployment": {
"command": [
"flask",
"--app",
"app",
"run"
],
"env_vars": [
{
"name": "FROM_BUNDLE_CONFIG"
}
],
"state": "SUCCEEDED"
},
"pending_deployment": null
}

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.apps.myapp

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/start-deployment-on-update-[UNIQUE_NAME]/default

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace $CLI bundle destroy --auto-approve
}
trap cleanup EXIT

# The source folder has no app.yaml: the inline config is the only place that says how to
# run the app.
title "Deploy with lifecycle.started=false: the app is created stopped and nothing is deployed to it"
trace $CLI bundle deploy

title "Deploy with lifecycle.started=true: the compute is started and the source is deployed with the inline config"
trace update_file.py databricks.yml "started: false" "started: true"
trace errcode $CLI bundle deploy
$CLI apps get $UNIQUE_NAME > LOG.app_after_deploy
trace $CLI apps get $UNIQUE_NAME | app_deployments
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# app_deployments projects `apps get` to the deployments on the app. source_code_path is left
# out because a real workspace reports a per-deployment snapshot path there.
app_deployments() {
jq '{active_deployment, pending_deployment} | map_values(if . == null then null else {command, env_vars, state: .status.state} | with_entries(select(.value != null)) end)'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# These tests show what starting the compute of a bundle-created app does to its deployments.
# Create records source_code_path on the app (#6399). The goldens hold what the bundle asks
# for: the only deployment an app gets is the one the CLI makes, carrying the inline config.
Cloud = true
RecordRequests = false

# The DMS variant adds nothing here, and each variant starts app compute on every cloud.
EnvMatrix.DMS = []

Ignore = [".databricks", "databricks.yml"]

# App deployment progress messages are non-deterministic on cloud (different status messages
# per poll), so filter them out entirely.
[[Repls]]
Old = '(?m)^✓ [^\n]*\n'
New = ""

[[Repls]]
Old = 'You can access the app at \S+'
New = 'You can access the app at [APP_URL]'
Loading