From 0676b3b7ed361ed7f13fcba51113612ca7575395 Mon Sep 17 00:00:00 2001 From: Anish Date: Wed, 31 Jan 2024 14:06:50 -0500 Subject: [PATCH] Add helper script to execute pytest on the dev server HEDWG2-1197 --- em_workflows/test_runner/flow.py | 1 + helper_scripts/remote_pytest.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 helper_scripts/remote_pytest.sh diff --git a/em_workflows/test_runner/flow.py b/em_workflows/test_runner/flow.py index 0c696243..4618efa7 100644 --- a/em_workflows/test_runner/flow.py +++ b/em_workflows/test_runner/flow.py @@ -80,6 +80,7 @@ def run_tests(git_branch: str) -> str: @flow( name="Pytest Runner", + flow_run_name="Test-on-{git_branch}", log_prints=True, task_runner=Config.SLURM_EXECUTOR, ) diff --git a/helper_scripts/remote_pytest.sh b/helper_scripts/remote_pytest.sh new file mode 100755 index 00000000..15cf7def --- /dev/null +++ b/helper_scripts/remote_pytest.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +echo +if [[ ! $(prefect config view | grep PREFECT_API_KEY) ]]; then + echo "PREFECT_API_KEY is not set; Set using 'prefect config set PREFECT_API_KEY=*****'"; + exit 1; +fi + +branch=`git branch --show-current` +echo "Sending pytest runner for branch=$branch"; +echo "Make sure you are connected to NIAID VPN"; +echo + +if [[ ! $(git branch -r | grep $branch) ]]; then + echo "Push the branch to remote before executing this action."; + echo + exit 1; +else + echo "Make sure the branch is up to date in remote" + echo +fi + +run_id=$(curl -i -X POST \ + "https://prefect2.hedwig-workflow-api.niaiddev.net/api/deployments/d87fc0e8-5c71-408a-bcbe-f2a6320686d1/create_flow_run" \ + -H "accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $PREFECT_API_KEY" \ + -d "{\"parameters\": {\"git_branch\":\"$branch\"}}" | \ + sed -n 's/.*\([0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}\).*/\1/p') + +flow="https://prefect2.hedwig-workflow-api.niaiddev.net/flow-runs/flow-run/$run_id" +echo +echo "Flow Run can be accessed here: $flow"; +echo