Skip to content

Commit afdbdea

Browse files
committed
enable submit with auto renaming when submitting cartisian product jobs
1 parent bb29975 commit afdbdea

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

submit.sh

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ if [[ "$mode" == "submit" ]]; then
229229
declare -a hydra_dels=()
230230
pool_explicit=""
231231
platform_explicit=""
232+
user_run_name=""
232233

233234
for arg in "${args[@]}"; do
234235
# keep special bool flags normalized
@@ -246,6 +247,12 @@ if [[ "$mode" == "submit" ]]; then
246247
# parse key=val (this now also catches --key=val like --task=...)
247248
if [[ $arg == *=* ]]; then
248249
key=${arg%%=*}; val=${arg#*=}
250+
# capture a base run name without passing it through directly
251+
key_nodash="${key#--}"
252+
if [[ "$key_nodash" == "run_name" ]]; then
253+
user_run_name="$val"
254+
continue
255+
fi
249256
if [[ "$key" == "pool" ]]; then
250257
pool_explicit="$val"; continue
251258
elif [[ "$key" == "platform" ]]; then
@@ -311,9 +318,41 @@ if [[ "$mode" == "submit" ]]; then
311318

312319
# submit each combo
313320
for combo in "${combos[@]}"; do
314-
all_set="args=$fixed_str $combo ${hydra_dels[*]} ${cli_flags[*]}"
321+
# Derive a base name and append sweep values for clarity
322+
# If user didn't provide a base, don't default to script name to avoid noise.
323+
base_name="$user_run_name"
324+
suffix=""
325+
if [[ -n "$combo" ]]; then
326+
# extract only values from k=v pairs and join with '+'
327+
read -r -a combo_parts <<< "$combo"
328+
vals=()
329+
for kv in "${combo_parts[@]}"; do
330+
v="${kv#*=}"
331+
vals+=("$v")
332+
done
333+
if (( ${#vals[@]} > 0 )); then
334+
# join values with '|' to avoid confusion with negatives
335+
suffix=$( IFS=','; echo "${vals[*]}" )
336+
fi
337+
fi
338+
# Build final run_name
339+
run_name=""
340+
if [[ -n "$base_name" && -n "$suffix" ]]; then
341+
run_name="$base_name|$suffix"
342+
elif [[ -n "$base_name" ]]; then
343+
run_name="$base_name"
344+
else
345+
run_name="$suffix"
346+
fi
347+
348+
# Append --run_name only when non-empty
349+
if [[ -n "$run_name" ]]; then
350+
all_set="args=$fixed_str $combo --run_name=$run_name ${hydra_dels[*]} ${cli_flags[*]}"
351+
else
352+
all_set="args=$fixed_str $combo ${hydra_dels[*]} ${cli_flags[*]}"
353+
fi
315354
cmd=( osmo workflow submit "$spec" --pool "$resolved_pool" --set script="$script" $cluster_str "$all_set" )
316-
echo "+ ${cmd[@]}"
355+
echo "LAUNCHING: ${cmd[@]}"
317356
"${cmd[@]}"
318357
done
319358
exit

0 commit comments

Comments
 (0)