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

Return jobid from batchq #158

Merged
merged 2 commits into from
Mar 1, 2025
Merged
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
13 changes: 8 additions & 5 deletions utilix/batchq.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import subprocess
import re
import tempfile
from typing import Any, Dict, List, Literal, Optional
from typing import Any, Dict, List, Union, Literal, Optional
from pydantic import BaseModel, Field, validator
from simple_slurm import Slurm # type: ignore
from . import logger
Expand Down Expand Up @@ -429,7 +429,7 @@ def _get_lc_nodes(self) -> List[str]:
print(f"An error occurred while executing nodestatus: {e}")
return []

def submit(self) -> None:
def submit(self) -> Union[int, None]:
"""Submit the job to the SLURM queue."""
os.makedirs(TMPDIR[self.partition], exist_ok=True)
# Initialize a dictionary with mandatory parameters
Expand Down Expand Up @@ -475,7 +475,7 @@ def submit(self) -> None:
print(f"Generated slurm script:\n{slurm.script()}")

if self.dry_run:
return
return None
# Submit the job

try:
Expand All @@ -488,6 +488,8 @@ def submit(self) -> None:
except Exception as e:
print(f"An error occurred while submitting the job: {str(e)}")

return job_id


def submit_job(
jobstring: str,
Expand All @@ -511,7 +513,7 @@ def submit_job(
dependency: Optional[str] = None,
verbose: bool = False,
bypass_validation: Optional[List[str]] = [],
) -> None:
) -> Union[int, None]:
"""Submit a job to the SLURM queue.

Args:
Expand Down Expand Up @@ -563,7 +565,8 @@ def submit_job(
verbose=verbose,
bypass_validation=bypass_validation,
)
job.submit()
job_id = job.submit()
return job_id


def count_jobs(string: str = "") -> int:
Expand Down