2025-03-11 14:36:57 +00:00
title "Bind experiment test: "
title "Substitute variables in the template"
BUNDLE_NAME_SUFFIX=$(uuid)
export BUNDLE_NAME_SUFFIX
2025-03-11 16:25:57 +00:00
# double slash at the start prevents Windows to apply replacements to the path
EXPERIMENT_NAME="//Workspace/Users/${CURRENT_USER_NAME}/test-experiment$(uuid)"
2025-03-11 14:36:57 +00:00
if [ -z "$CLOUD_ENV" ]; then
2025-03-11 16:25:57 +00:00
EXPERIMENT_NAME="//Workspace/Users/${CURRENT_USER_NAME}/test-experiment6260d50f-e8ff-4905-8f28-812345678903" # use hard-coded uuid when running locally
2025-03-11 14:36:57 +00:00
fi
export EXPERIMENT_NAME
envsubst < databricks.yml > out.yml && mv out.yml databricks.yml
title "Create a pre-defined experiment"
2025-03-11 16:04:04 +00:00
EXPERIMENT_ID=$($CLI experiments create-experiment "${EXPERIMENT_NAME}" | jq -r '.experiment_id')
2025-03-11 14:36:57 +00:00
cleanupRemoveExperiment() {
title "Test cleanup: "
title "Delete the pre-defined experiment: "
$CLI experiments delete-experiment ${EXPERIMENT_ID}
echo $?
}
trap cleanupRemoveExperiment EXIT
title "Bind experiment: "
$CLI bundle deployment bind experiment1 ${EXPERIMENT_ID} --auto-approve
title "Deploy bundle: "
$CLI bundle deploy --force-lock --auto-approve
title "Read the pre-defined experiment: "
$CLI experiments get-experiment ${EXPERIMENT_ID} | jq '{name: .experiment.name, lifecycle_stage: .experiment.lifecycle_stage}'
title "Unbind the experiment: "
$CLI bundle deployment unbind experiment1
title "Destroy the bundle: "
$CLI bundle destroy --auto-approve
title "Read the pre-defined experiment again (expecting it still exists and is not deleted): "
$CLI experiments get-experiment ${EXPERIMENT_ID} | jq '{name: .experiment.name, lifecycle_stage: .experiment.lifecycle_stage}'