Skip to content

Commit

Permalink
Fix bugs in memory argument handling and make token optional
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterC-DLS committed Jan 28, 2024
1 parent 0086c5c commit 52e1b59
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ParProcCo/passthru_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_slice_jobs(
args: tuple[str, ...] = (
job_script,
"--memory",
str(job_scheduling_information.job_resources.memory),
f"{job_scheduling_information.job_resources.memory}M",
"--cores",
str(job_scheduling_information.job_resources.cpu_cores),
)
Expand Down
2 changes: 1 addition & 1 deletion ParProcCo/program_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(
self.slicer = slicer
self.aggregating_slicer = aggregating_slicer

def get_args(self, args: list[str], debug: bool = False):
def get_args(self, args: list[str], debug: bool = False) -> list[str]:
"""
Get arguments given passed-in arguments
args -- given arguments
Expand Down
2 changes: 1 addition & 1 deletion example/simple_processing_slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create_slice_job(
job_scheduling_information.job_script_arguments = (
old_args[0],
"--memory",
str(job_scheduling_information.job_resources.memory),
f"{job_scheduling_information.job_resources.memory}M",
"--cores",
str(job_scheduling_information.job_resources.cpu_cores),
"--output",
Expand Down
15 changes: 8 additions & 7 deletions scripts/ppc_cluster_submit
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ from ParProcCo.utils import get_token, set_up_wrapper

def create_parser() -> argparse.ArgumentParser:
"""
$ ppc_cluster_submit program [--partition cs05r] [--token path/to/token/file]
$ ppc_cluster_submit program [--partition hpc00] [--token path/to/token/file]
[--output cluster_output_dir] [--jobs 4] [--timeout 1h30m] --memory 4000M --cores 6
-s 0.01 ... [input files]
"""
Expand All @@ -33,7 +33,7 @@ def create_parser() -> argparse.ArgumentParser:
required=True,
)
parser.add_argument(
"--token", help="str: slurm token filepath", type=str, required=True
"--token", help="str: slurm token filepath", type=str
)
parser.add_argument("-o", "--output", help="str: cluster output file or directory")
parser.add_argument(
Expand Down Expand Up @@ -81,8 +81,8 @@ def parse_timeout(timeout: str) -> timedelta:


def parse_memory(memory: str) -> int:
l = memory[-1]
if l not in ('M', 'G'):
s = memory[-1]
if s not in ('M', 'G'):
raise ValueError('Memory specified must end with M or G')
try:
m = int(memory[:-1])
Expand All @@ -91,11 +91,12 @@ def parse_memory(memory: str) -> int:

if m <= 0:
raise ValueError('Memory specified must be greater than 0')
if l == 'M' and m < 512:
if s == 'M' and m < 512:
logging.warning('Memory specified is recommended to be over 512M')
if l == 'G'and m > 64:
if s == 'G':
if m > 64:
logging.warning('Memory specified (>64G) seems to be excessive')
m = m*1024
logging.warning('Memory specified (>64G) seems to be excessive')
return m


Expand Down

0 comments on commit 52e1b59

Please sign in to comment.