-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow.yaml
More file actions
328 lines (296 loc) · 11.9 KB
/
workflow.yaml
File metadata and controls
328 lines (296 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# yaml-language-server: $schema=https://activate.parallel.works/workflow.schema.json
---
# ==============================================================================
# Hello World Batch Submitter
# ==============================================================================
# A simple example workflow demonstrating how to submit batch jobs using the
# job_runner/v4.0 marketplace action. This workflow accepts a series of
# commands, packages them into a script, and submits via the reusable
# job_runner.
#
# This pattern leverages marketplace/job_runner/v4.0 for:
# - Scheduler support (SLURM/PBS)
# - Job monitoring and output streaming
# - Automatic cancellation handling
#
# Usage:
# 1. Select a compute resource
# 2. Enter commands to execute (one per line)
# 3. Choose execution mode (SSH direct or scheduler)
# 4. Run the workflow
#
# For more information, see README.md
# ==============================================================================
jobs:
# ============================================================================
# PREPROCESSING - Create the command script on the remote system
# ============================================================================
preprocessing:
working-directory: "${PW_PARENT_JOB_DIR}"
ssh:
remoteHost: ${{ inputs.resource.ip }}
steps:
- name: Create working directory
run: |
set -e
mkdir -p "${PW_PARENT_JOB_DIR}"
echo "$(date) Working directory: ${PW_PARENT_JOB_DIR}"
- name: Create command script
run: |
set -e
echo "$(date) Creating command script..."
# Create the main execution script with header
cat > commands.sh << 'HEADER_EOF'
#!/bin/bash
set -e
echo "=============================================="
echo " Hello World from Parallel Works ACTIVATE"
echo "=============================================="
echo ""
echo "System Information:"
echo " Hostname: $(hostname)"
echo " Date: $(date)"
echo " User: $(whoami)"
echo " Directory: $(pwd)"
echo " Job ID: ${PW_JOB_ID:-N/A}"
echo ""
echo "----------------------------------------------"
echo " Executing Commands"
echo "----------------------------------------------"
echo ""
HEADER_EOF
# Append user commands to the script
cat >> commands.sh << 'USER_COMMANDS_EOF'
${{ inputs.commands }}
USER_COMMANDS_EOF
# Add completion footer
cat >> commands.sh << 'FOOTER_EOF'
echo ""
echo "----------------------------------------------"
echo " All commands completed"
echo "----------------------------------------------"
echo ""
echo "Finished at: $(date)"
echo "=============================================="
FOOTER_EOF
chmod +x commands.sh
echo "$(date) Script created successfully:"
echo "--- commands.sh ---"
cat commands.sh
echo "--- end of script ---"
# ============================================================================
# JOB RUNNER - Submit via v4.0 marketplace action
# ============================================================================
job_runner:
needs: [preprocessing]
working-directory: "${PW_PARENT_JOB_DIR}"
ssh:
remoteHost: ${{ inputs.resource.ip }}
steps:
- name: Submit batch job
early-cancel: any-job-failed
uses: marketplace/job_runner/v4.0
with:
resource: ${{ inputs.resource }}
rundir: "${PW_PARENT_JOB_DIR}"
poll_interval: 10
use_existing_script: true
script_path: "${PW_PARENT_JOB_DIR}/commands.sh"
scheduler: ${{ inputs.scheduler }}
slurm:
is_disabled: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
account: ${{ inputs.slurm.account }}
partition: ${{ inputs.slurm.partition }}
qos: ${{ inputs.slurm.qos }}
time: ${{ inputs.slurm.time }}
nodes: ${{ inputs.slurm.nodes }}
pbs:
is_disabled: ${{ inputs.resource.schedulerType != 'pbs' || inputs.scheduler == false }}
account: ${{ inputs.pbs.account }}
queue: ${{ inputs.pbs.queue }}
walltime: ${{ inputs.pbs.walltime }}
- name: Show job output
run: |
echo "=============================================="
echo " Job Output"
echo "=============================================="
OUTPUT_FILE="run.${PW_JOB_ID}.out"
if [ -f "${OUTPUT_FILE}" ]; then
cat "${OUTPUT_FILE}"
else
echo "Output file not found: ${OUTPUT_FILE}"
echo "Files in directory:"
ls -la
fi
- name: Notify job ended
early-cancel: any-job-failed
run: touch job.ended
# ==============================================================================
# INPUT DEFINITIONS
# ==============================================================================
"on":
execute:
inputs:
# ========================================================================
# Core Settings
# ========================================================================
resource:
label: Compute Resource
type: compute-clusters
autoselect: true
optional: false
tooltip: Select the compute resource where the job will run
# ========================================================================
# Commands Configuration
# ========================================================================
commands:
label: Commands to Execute
type: editor
optional: false
default: |
# Enter your commands below (one per line)
# These will be packaged into a script and executed on the remote system
hostname
date
whoami
pwd
uname -a
echo "Environment variables:"
env | sort | head -20
tooltip: |
Enter the commands you want to execute on the remote system.
Each line will be executed in sequence.
Example commands:
hostname - Display the compute node name
date - Show current date/time
module avail - List available modules
nvidia-smi - Show GPU status (if available)
# ========================================================================
# Execution Mode
# ========================================================================
scheduler:
type: boolean
default: false
label: Submit via Scheduler?
hidden: ${{ inputs.resource.schedulerType == '' }}
tooltip: |
Enable to submit job through the cluster scheduler (SLURM/PBS).
Disable for direct SSH execution.
# ========================================================================
# SLURM Configuration
# ========================================================================
slurm:
type: group
label: SLURM Settings
hidden: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
items:
account:
label: Account
type: slurm-accounts
resource: ${{ inputs.resource }}
optional: true
tooltip: SLURM account for job submission (--account)
ignore: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
partition:
type: slurm-partitions
label: Partition
resource: ${{ inputs.resource }}
optional: true
tooltip: SLURM partition for job submission (--partition)
ignore: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
qos:
label: Quality of Service
type: slurm-qos
resource: ${{ inputs.resource }}
optional: true
tooltip: SLURM QoS setting (--qos)
ignore: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
time:
label: Walltime
type: string
default: "00:30:00"
tooltip: Maximum job duration, e.g., 00:30:00 (--time)
ignore: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
nodes:
label: Nodes
type: number
default: 1
min: 1
optional: true
tooltip: Number of nodes to request (--nodes)
ignore: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
cpus_per_task:
label: CPUs per Task
type: number
default: 1
min: 1
optional: true
tooltip: Number of CPUs per task (--cpus-per-task)
ignore: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
gres:
label: Generic Resources (GPUs)
type: string
placeholder: "gpu:1"
optional: true
tooltip: Generic resource specification, e.g., gpu:1, gpu:a100:2 (--gres)
ignore: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
mem:
label: Memory
type: string
placeholder: "8G"
optional: true
tooltip: Memory per node, e.g., 8G, 32000M (--mem)
ignore: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
scheduler_directives:
type: editor
label: Additional Directives
optional: true
tooltip: |
Additional SLURM directives (one per line, include #SBATCH prefix)
Example:
#SBATCH --exclusive
#SBATCH --mail-type=END
ignore: ${{ inputs.resource.schedulerType != 'slurm' || inputs.scheduler == false }}
# ========================================================================
# PBS Configuration
# ========================================================================
pbs:
type: group
label: PBS Settings
hidden: ${{ inputs.resource.schedulerType != 'pbs' || inputs.scheduler == false }}
items:
account:
label: Account
type: string
optional: true
tooltip: PBS account for job submission (-A)
ignore: ${{ inputs.resource.schedulerType != 'pbs' || inputs.scheduler == false }}
queue:
label: Queue
type: string
optional: true
tooltip: PBS queue name (-q)
ignore: ${{ inputs.resource.schedulerType != 'pbs' || inputs.scheduler == false }}
walltime:
label: Walltime
type: string
default: "00:30:00"
tooltip: Maximum job duration, e.g., 00:30:00 (-l walltime=)
ignore: ${{ inputs.resource.schedulerType != 'pbs' || inputs.scheduler == false }}
select:
label: Resource Selection
type: string
placeholder: "1:ncpus=1"
optional: true
tooltip: PBS resource selection string (-l select=)
ignore: ${{ inputs.resource.schedulerType != 'pbs' || inputs.scheduler == false }}
scheduler_directives:
label: Additional Directives
type: editor
optional: true
tooltip: |
Additional PBS directives (one per line, include #PBS prefix)
Example:
#PBS -V
#PBS -m ae
ignore: ${{ inputs.resource.schedulerType != 'pbs' || inputs.scheduler == false }}