Skip to content

Commit 7a80943

Browse files
authored
fix: small develop bugs (#709, #711) (#714)
* fix: align canfar_monitor docstring indentation 7-space indent on the Params Default docstring opener caused IndentationError at the 8-space body, breaking canfar_monitor, canfar_submit_job, canfar_monitor_log, and canfar_run imports. Closes #709 * fix: add argparse to summary_run so -h shows help summary_run previously consumed sys.argv[1] as the 'patch' positional without parsing, so 'summary_run -h' tried to create a directory named '-h'. Switch to argparse: help/usage work, required patch is enforced, optional job_exclusive and --verbose preserved. Closes #711
1 parent 87b86df commit 7a80943

2 files changed

Lines changed: 34 additions & 16 deletions

File tree

src/shapepipe/canfar/canfar_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def set_params_from_command_line(self, args):
5252
logging.log_command(args)
5353

5454
def params_default(self):
55-
"""Params Default.
55+
"""Params Default.
5656
5757
Set default parameters.
5858

src/shapepipe/summary_run.py

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22

3+
import argparse
34
import sys
45
import os
56

@@ -8,16 +9,7 @@
89
from shapepipe.utilities import summary_params_pre_v2 as summary_params
910

1011

11-
def run(*args):
12-
13-
patch = args[0]
14-
15-
if len(args) >= 2:
16-
job_exclusive = args[1]
17-
else:
18-
job_exclusive = None
19-
20-
verbose = len(args) == 3
12+
def run(patch, job_exclusive=None, verbose=False):
2113

2214
jobs, list_tile_IDs_dot = summary_params.set_jobs_v2_pre_v2(patch, verbose)
2315

@@ -73,11 +65,37 @@ def run(*args):
7365
return 0
7466

7567

76-
def main(args=None):
77-
78-
if args is None:
79-
args = sys.argv[1:] # skip script name
80-
run(*args)
68+
def parse_args(argv=None):
69+
parser = argparse.ArgumentParser(
70+
description=(
71+
'Print summary of ShapePipe job status for a given UNIONS patch.'
72+
),
73+
)
74+
parser.add_argument(
75+
'patch',
76+
help='Patch identifier (e.g. P3, P9).',
77+
)
78+
parser.add_argument(
79+
'job_exclusive',
80+
nargs='?',
81+
default=None,
82+
help=(
83+
'Bitmask selecting which jobs to run; '
84+
+ 'if omitted, all jobs run.'
85+
),
86+
)
87+
parser.add_argument(
88+
'-v',
89+
'--verbose',
90+
action='store_true',
91+
help='Verbose output.',
92+
)
93+
return parser.parse_args(argv)
94+
95+
96+
def main(argv=None):
97+
args = parse_args(argv)
98+
run(args.patch, args.job_exclusive, args.verbose)
8199

82100

83101
if __name__ == "__main__":

0 commit comments

Comments
 (0)