Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clusterscope/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def task():
default=None,
help="Time limit for the job (format: HH:MM:SS or days-HH:MM:SS, optional)",
)
@click.option("--slurm-cmd", default=None, help="Command to run on Slurm")
def slurm(
num_gpus: int,
num_tasks_per_node: int,
Expand All @@ -221,6 +222,7 @@ def slurm(
account: str,
qos: str,
time: str,
slurm_cmd: str,
):
"""Generate job requirements for a task of a Slurm job."""
partitions = get_partition_info()
Expand All @@ -239,6 +241,7 @@ def slurm(
account=account,
qos=qos,
time=time,
slurm_cmd=slurm_cmd,
)

# Route to the correct format method based on CLI option
Expand Down
5 changes: 5 additions & 0 deletions clusterscope/cluster_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ResourceShape(NamedTuple):
tasks_per_node: int
gpus_per_node: int
slurm_partition: str
slurm_cmd: Optional[str] = None
account: Optional[str] = None
qos: Optional[str] = None
time: Optional[str] = None
Expand Down Expand Up @@ -59,6 +60,8 @@ def to_sbatch(self) -> str:
value = getattr(self, attr_name)
if value is not None:
lines.append(f"#SBATCH --{attr_name}={value}")
if self.slurm_cmd is not None:
lines.append(self.slurm_cmd)
return "\n".join(lines)

def to_srun(self) -> str:
Expand All @@ -79,6 +82,8 @@ def to_srun(self) -> str:
value = getattr(self, attr_name)
if value is not None:
cmd_parts.append(f"--{attr_name}={value}")
if self.slurm_cmd is not None:
cmd_parts.append(self.slurm_cmd)
return " ".join(cmd_parts)

def to_submitit(self) -> str:
Expand Down