Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update slurm commands to include partition configurations #45

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions src/mzn_bench/mzn_slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def schedule(
timeout: timedelta,
configurations: Iterable[Configuration],
nodelist: Optional[Iterable[str]] = None,
partition: Optional[Iterable[str]] = None,
output_dir: Path = Path.cwd() / "results",
job_name: str = "MiniZinc Benchmark",
cpus_per_task: int = 1,
Expand Down Expand Up @@ -141,7 +142,7 @@ def schedule(
instances = str(instances.resolve())
output_dir = str(output_dir.resolve())

if nodelist is None:
if nodelist is None and partition is None:
os.environ.update(env)
for i in range(n_tasks): # simulate environment like SLURM
os.environ["SLURM_ARRAY_TASK_ID"] = str(i + 1)
Expand All @@ -153,10 +154,17 @@ def schedule(
f'--job-name="{job_name}"',
f"--cpus-per-task={cpus_per_task}",
f"--mem={memory}",
f"--nodelist={','.join(nodelist)}",
f"--array=1-{n_tasks}",
f"--time={timeout + timedelta(minutes=1)}", # Set hard timeout as failsafe
]
if nodelist is not None:
cmd += [
f"--nodelist={','.join(nodelist)}",
]
if partition is not None:
cmd += [
f"--partition={','.join(partition)}",
]
if nice is not None:
cmd.append(f"--nice={nice}")
if wait:
Expand Down