-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: trigger prefect flow after models successfully transferred to s3
- Loading branch information
1 parent
be646a2
commit c8de3bc
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
# Creating python3.8 virtual env | ||
PYTHON_VENV="python_venv" | ||
virtualenv --python=python3.8 --clear "${PYTHON_VENV}" | ||
source "${PYTHON_VENV}/bin/activate" | ||
|
||
# Install prefect python pkg | ||
cd $WORKSPACE/prefect-flows | ||
pip install -r requirements.txt | ||
|
||
# Do not print commands in this function since they may contain secrets. | ||
set +x | ||
|
||
# Retrieve a vault token corresponding to the jenkins AppRole. The token is then stored in the VAULT_TOKEN variable | ||
# which is implicitly used by subsequent vault commands within this script. | ||
# Instructions followed: https://learn.hashicorp.com/tutorials/vault/approle#step-4-login-with-roleid-secretid | ||
export VAULT_TOKEN=$(vault write -field=token auth/approle/login \ | ||
role_id=${ANALYTICS_VAULT_ROLE_ID} \ | ||
secret_id=${ANALYTICS_VAULT_SECRET_ID} | ||
) | ||
|
||
PREFECT_CLOUD_AGENT_TOKEN=$( | ||
vault kv get \ | ||
-version=${PREFECT_VAULT_KV_VERSION} \ | ||
-field=PREFECT_CLOUD_AGENT_TOKEN \ | ||
${PREFECT_VAULT_KV_PATH} \ | ||
) | ||
|
||
# Get Authenticated with Prefect Cloud | ||
prefect auth login --key $PREFECT_CLOUD_AGENT_TOKEN | ||
|
||
set -x | ||
|
||
# Trigger prefect flow | ||
prefect run --id $FLOW_ID |