我们目前正在使用私有托管的 git 存储库(未在 codecommit、github、bitbucket 等中连接),并且在 Sagemaker 工作室内部,我连接了 git 存储库。将某些代码推送到 git 存储库后,如何触发 sagemaker 管道?有没有一种简单的方法(或任何替代方法)来做到这一点?
我尝试使用网络钩子:接收后和更新后不起作用。我尝试在预提交 webhook 中执行此操作,并且运行良好。但是当在接收/更新后尝试时,它不起作用。
# Pipeline Trigger
# Check if the last argument is '0' (indicating a successful push)
if [ "$1" = "0" ]; then
log_message "Push to Git repository detected. Triggering SageMaker Studio pipeline..."
# Trigger SageMaker Studio pipeline
pipeline_execution_output=$(aws sagemaker start-pipeline-execution \
--pipeline-name "$SAGEMAKER_PIPELINE_NAME" \
2>&1)
# Check if the pipeline execution was successful
if [ $? -eq 0 ]; then
log_message "SageMaker Studio pipeline execution triggered successfully."
else
log_message "Failed to trigger SageMaker Studio pipeline execution. Error: $pipeline_execution_output"
fi
else
# Log unsuccessful push
log_message "Failed to push changes to the repository."
fi
根据 git 文档,接收后和更新后挂钩在远程服务器上执行。
您需要验证远程服务器是否能够运行 AWS CLI 命令。
或者,您可以考虑将存储库移至 CodeCommit 并使用 EventBridge 触发 SageMaker 管道:https://docs.aws.amazon.com/codecommit/latest/userguide/monitoring-events.html