Skip to content

Commit

Permalink
Add a SUBMITTED ramble status
Browse files Browse the repository at this point in the history
Also generate the bash associative array declaration from the python
status_map.
  • Loading branch information
linsword13 committed Jan 10, 2025
1 parent d3bb3c9 commit 8703fe5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/ramble/ramble/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

experiment_status = Enum(
"experiment_status",
["UNKNOWN", "SETUP", "RUNNING", "COMPLETE", "SUCCESS", "FAILED", "CANCELLED"],
["UNKNOWN", "SETUP", "SUBMITTED", "RUNNING", "COMPLETE", "SUCCESS", "FAILED", "CANCELLED"],
)

_NULL_CONTEXT = "null"
Expand Down
12 changes: 4 additions & 8 deletions var/ramble/repos/builtin/workflow_managers/slurm/batch_query.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ if [ -z "${job_id:-}" ]; then
exit 1
fi

# Set up the status_map mapping between
# sacct/squeue status to ramble counterpart
{declare_status_map}

status=$(squeue -h -o "%t" -j "${job_id}" 2>/dev/null)
if [ -z "$status" ]; then
status=$(sacct -j "${job_id}" -o state -X -n | xargs)
fi
if [ ! -z "$status" ]; then
# Define a mapping between sacct/squeue status to ramble counterpart
declare -A status_map
status_map["PD"]="SETUP"
status_map["R"]="RUNNING"
status_map["CF"]="SETUP"
status_map["CG"]="COMPLETE"
status_map["COMPLETED"]="COMPLETE"
status_map["CANCELLED+"]="CANCELLED"
if [ -v status_map["$status"] ]; then
status=${status_map["$status"]}
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# Mapping from squeue/sacct status to Ramble status
_STATUS_MAP = {
"PD": "SETUP",
"PD": "SUBMITTED",
"R": "RUNNING",
"CF": "SETUP",
"CG": "COMPLETE",
Expand All @@ -26,6 +26,14 @@
}


def _declare_status_map():
"""A utility to convert the `_STATUS_MAP` into a bash array"""
entries = ["declare -A status_map"]
for k, v in _STATUS_MAP.items():
entries.append(f'status_map["{k}"]="{v}"')
return "\n".join(entries)


class Slurm(WorkflowManagerBase):
"""Slurm workflow manager"""

Expand Down Expand Up @@ -77,7 +85,10 @@ def __init__(self, file_path):
)

register_template(
name="batch_query", src_name="batch_query.tpl", dest_name="batch_query"
name="batch_query",
src_name="batch_query.tpl",
dest_name="batch_query",
extra_vars={"declare_status_map": _declare_status_map()},
)

register_template(
Expand Down

0 comments on commit 8703fe5

Please sign in to comment.