Skip to content

Commit 3445bf5

Browse files
committed
Completes tests for the CLI
1 parent bc1f42f commit 3445bf5

File tree

15 files changed

+158
-47
lines changed

15 files changed

+158
-47
lines changed

docs/notebook/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"sleep_time": 0.5c,
2+
"sleep_time": 0.5,
33
"ram_unit": "megabytes",
44
"gpu_ram_unit": "megabytes",
55
"time_unit": "seconds"

src/gpu_tracker/__main__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,25 @@ def main():
5757
results = SubTrackingAnalyzer(tracking_file, sub_tracking_file).sub_tracking_results()
5858
_process_output(output_format, results, output)
5959
elif args['combine']:
60-
directory = None
61-
files = None
6260
files = args['-p']
6361
if len(files) == 1:
6462
[directory] = files
6563
files = [os.path.join(directory, file) for file in os.listdir(directory)]
6664
SubTrackingAnalyzer(None, args['--stf']).combine_sub_tracking_files(files)
67-
elif args['compare']:
65+
else:
6866
if args['--cconfig'] is not None:
6967
with open(args['--cconfig'], 'r') as file:
7068
config = json.load(file)
71-
file_path_map = config['file_path_map'] if 'file_path_map' in config else None
69+
file_path_map = config['file_path_map'] if 'file_path_map' in config else dict[str, str]()
7270
statistic = config['statistic'] if 'statistic' in config else None
7371
else:
7472
file_path_map = dict[str, str]()
7573
statistic = None
76-
if not file_path_map and args['-m'] is None:
77-
raise ValueError(
78-
f'A mapping of tracking session name to file path must be provided either through the -m option or a config file.'
74+
if not file_path_map and not args['-m']:
75+
log.error(
76+
'A mapping of tracking session name to file path must be provided either through the -m option or a config file.'
7977
)
78+
sys.exit(1)
8079
else:
8180
file_path_map.update({name: file for [name, file] in [option.split('=') for option in args['-m']]})
8281
if args['--stat'] is not None:
@@ -154,5 +153,5 @@ def _process_output(output_format: str, output_obj, output: str | None):
154153
file.write(output_str)
155154

156155

157-
if __name__ == '__main__':
158-
main()
156+
if __name__ == '__main__': # pragma: nocover
157+
main() # pragma: nocover

tests/data/cconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"file_path_map": {
3+
"A": "file1.pkl",
4+
"B": "file2.pkl"
5+
},
6+
"statistic": "max"
7+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11.6 KB
Binary file not shown.
11.6 KB
Binary file not shown.
8 KB
Binary file not shown.

0 commit comments

Comments
 (0)