Skip to content

Commit

Permalink
Fix bug in memory argument parsing of G 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 4e17462
Showing 1 changed file with 8 additions and 7 deletions.
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 4e17462

Please sign in to comment.