diff --git a/workflow/salloc/main_salloc_workflow.yaml b/workflow/salloc/main_salloc_workflow.yaml index 10de977..85a20c1 100644 --- a/workflow/salloc/main_salloc_workflow.yaml +++ b/workflow/salloc/main_salloc_workflow.yaml @@ -14,10 +14,12 @@ jobs: hello1: ssh: remoteHost: ${{inputs.resource}} - needs: - - allocate steps: - run: | + while [ ! -f /tmp/slurm_allocation_info.txt ]; do + echo "Waiting for file /tmp/slurm_allocation_info.txt to be created" + sleep 5 + done JOBID=$(grep '^SLURM_JOB_ID=' /tmp/slurm_allocation_info.txt | cut -d= -f2) srun --jobid=$JOBID echo "hello world 1 on $(hostname)" hello2: @@ -27,6 +29,10 @@ jobs: - allocate steps: - run: | + while [ ! -f /tmp/slurm_allocation_info.txt ]; do + echo "Waiting for file /tmp/slurm_allocation_info.txt to be created" + sleep 5 + done JOBID=$(grep '^SLURM_JOB_ID=' /tmp/slurm_allocation_info.txt | cut -d= -f2) srun --jobid=$JOBID echo "hello world 2 on $(hostname)" relinquish: @@ -36,7 +42,8 @@ jobs: - hello1 - hello2 steps: - - run: scancel $JOBID + - run: touch RELEASE_ALLOCATION + 'on': execute: inputs: diff --git a/workflow/salloc/salloc_subworkflow.yaml b/workflow/salloc/salloc_subworkflow.yaml index 2161385..b40712c 100644 --- a/workflow/salloc/salloc_subworkflow.yaml +++ b/workflow/salloc/salloc_subworkflow.yaml @@ -1,4 +1,18 @@ jobs: + release_allocation: + ssh: + remoteHost: ${{inputs.resource.ip}} + steps: + - name: Release Slurm Allocation + run: | + while [ ! -f RELEASE_ALLOCATION ]; do + echo "$(date) Waiting for RELEASE_ALLOCATION file to release the allocation" + sleep 5 + done + cleanup: | + JOBID=$(grep '^SLURM_JOB_ID=' $(pwd)/slurm_allocation_info.txt | cut -d= -f2) + scancel $JOBID + allocation: ssh: remoteHost: ${{inputs.resource.ip}}