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
2 changes: 1 addition & 1 deletion src/cloudai/systems/slurm/slurm_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class SlurmSystem(System):
cache_docker_images_locally: bool = False
scheduler: str = "slurm"
monitor_interval: int = 60
cmd_shell: CommandShell = Field(default=CommandShell(), exclude=True)
cmd_shell: CommandShell = Field(default_factory=CommandShell, exclude=True)
extra_srun_args: Optional[str] = None
extra_sbatch_args: list[str] = Field(default_factory=list)
supports_gpu_directives_cache: Optional[bool] = Field(default=None, exclude=True)
Expand Down
9 changes: 4 additions & 5 deletions src/cloudai/util/command_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ def __init__(self, executable: Path = Path("/bin/bash")):

Args:
executable (Path): The shell executable path. Defaults to Path("/bin/bash").

Raises:
FileNotFoundError: If the specified executable does not exist.
Existence is checked when execute() is called, not at init.
"""
if not executable.exists():
raise FileNotFoundError(f"Executable '{executable}' not found.")
self.executable = executable

def execute(self, command: str) -> subprocess.Popen:
Expand All @@ -51,8 +47,11 @@ def execute(self, command: str) -> subprocess.Popen:
subprocess.Popen: The process object for the executed command.

Raises:
FileNotFoundError: If the shell executable does not exist.
subprocess.CalledProcessError: If command execution fails.
"""
if not self.executable.exists():
raise FileNotFoundError(f"Executable '{self.executable}' not found.")
process = subprocess.Popen(
command,
shell=True,
Expand Down