Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: trigger prefect flow after models successfully transferred to s3 #1672

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions dataeng/jobs/analytics/ModelTransfers.groovy
Expand Up @@ -45,6 +45,7 @@ class ModelTransfers{
publishers common_publishers(allVars)
steps {
shell(dslFactory.readFileFromWorkspace('dataeng/resources/model-transfers.sh'))
shell(dslFactory.readFileFromWorkspace('dataeng/resources/trigger-prefect-flow.sh'))
}
}
}
Expand Down
37 changes: 37 additions & 0 deletions dataeng/resources/trigger-prefect-flow.sh
@@ -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 $ENTERPRISE_PREFECT_FLOW_ID