Skip to content

Command

Command dataclass

Command(name: str, argv: Sequence[str | Path], cores: int = 1, env: Mapping[str, str] | None = None, ranks: int | None = None)

Run an executable without a shell in the task output directory.

Set ranks and matching cores for an MPI-aware executable, including Python scripts using mpi4py. MPI execution requires an allocation backend.

Parameters:

Name Type Description Default
name str

Directory-safe task name.

required
argv Sequence[str | Path]

Executable followed by individual arguments.

required
cores int

Positive reservation; must equal ranks for an MPI command.

1
env Mapping[str, str] | None

Environment overrides added to the inherited environment.

None
ranks int | None

MPI rank count, or None for a serial command.

None

Raises:

Type Description
ValueError

Name, argv, cores, or ranks is invalid or inconsistent.

TypeError

Arguments or environment values have invalid types.

Example
import sys
from femora.jobs.tasks import Command
task = Command("check", [sys.executable, "-c", "print('ready')"])
Note

Shell syntax such as pipes, redirection, and wildcard expansion is not interpreted. Use absolute paths for scripts outside the task directory. Logs and the process return code are exposed through ProcessResult.