Skip to content
Merged
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
28 changes: 5 additions & 23 deletions src/cloudai/util/command_shell.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright (c) 2024, 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -27,32 +27,14 @@ class CommandShell:
"""

def __init__(self, executable: Path = Path("/bin/bash")):
"""
Initialize the CommandShell with a shell executable.

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

Raises:
FileNotFoundError: If the specified executable does not exist.
"""
if not executable.exists():
raise FileNotFoundError(f"Executable '{executable}' not found.")
"""Initialize the CommandShell with a shell executable."""
self.executable = executable

def execute(self, command: str) -> subprocess.Popen:
"""
Execute a shell command and return its process.

Args:
command (str): The command to be executed.

Returns:
subprocess.Popen: The process object for the executed command.
"""Execute a shell command and return its process."""
if not self.executable.exists():
raise FileNotFoundError(f"Executable '{self.executable}' not found.")

Raises:
subprocess.CalledProcessError: If command execution fails.
"""
process = subprocess.Popen(
command,
shell=True,
Expand Down
Loading