From 5060e28b539ab7de6e7747256aaea960f8b67a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20N=C3=B6the?= Date: Tue, 11 May 2021 15:15:24 +0200 Subject: [PATCH 1/2] Add some useful short form alias to Tool and Stage1 --- ctapipe/core/tool.py | 8 ++++++-- ctapipe/tools/stage1.py | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ctapipe/core/tool.py b/ctapipe/core/tool.py index bbfb9293aa1..af4a70cd9f6 100644 --- a/ctapipe/core/tool.py +++ b/ctapipe/core/tool.py @@ -152,14 +152,18 @@ def __init__(self, **kwargs): # make sure there are some default aliases in all Tools: super().__init__(**kwargs) aliases = { - "config": "Tool.config_file", + ("c", "config"): "Tool.config_file", "log-level": "Tool.log_level", ("l", "log-file"): "Tool.log_file", "log-file-level": "Tool.log_file_level", } self.aliases.update(aliases) flags = { - ("q", "quiet"): ({"Tool": {"quiet": True}}, "Disable console logging.") + ("q", "quiet"): ({"Tool": {"quiet": True}}, "Disable console logging."), + ("v", "verbose"): ( + {"Tool": {"log_level": "DEBUG"}}, + "Set log level to DEBUG", + ), } self.flags.update(flags) diff --git a/ctapipe/tools/stage1.py b/ctapipe/tools/stage1.py index 3002b3c1372..4ea908b50b8 100644 --- a/ctapipe/tools/stage1.py +++ b/ctapipe/tools/stage1.py @@ -36,10 +36,10 @@ class Stage1Tool(Tool): progress_bar = Bool(help="show progress bar during processing").tag(config=True) aliases = { - "input": "EventSource.input_url", - "output": "DL1Writer.output_path", - "allowed-tels": "EventSource.allowed_tels", - "max-events": "EventSource.max_events", + ("i", "input"): "EventSource.input_url", + ("o", "output"): "DL1Writer.output_path", + ("t", "allowed-tels"): "EventSource.allowed_tels", + ("m", "max-events"): "EventSource.max_events", "image-cleaner-type": "ImageProcessor.image_cleaner_type", } @@ -56,7 +56,7 @@ class Stage1Tool(Tool): {"DL1Writer": {"write_index_tables": True}}, "generate PyTables index tables for the parameter and image datasets", ), - "overwrite": ( + ("f", "overwrite"): ( {"DL1Writer": {"overwrite": True}}, "Overwrite output file if it exists", ), From 82c4abeb39edf016a4f5d1fa67d173bcf6f52d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20N=C3=B6the?= Date: Tue, 11 May 2021 15:15:39 +0200 Subject: [PATCH 2/2] Do not override aliases with defaults in Tool --- ctapipe/core/tool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ctapipe/core/tool.py b/ctapipe/core/tool.py index af4a70cd9f6..f2b7c093a41 100644 --- a/ctapipe/core/tool.py +++ b/ctapipe/core/tool.py @@ -157,7 +157,9 @@ def __init__(self, **kwargs): ("l", "log-file"): "Tool.log_file", "log-file-level": "Tool.log_file_level", } - self.aliases.update(aliases) + # makes sure user defined aliases override default aliases + self.aliases = {**aliases, **self.aliases} + flags = { ("q", "quiet"): ({"Tool": {"quiet": True}}, "Disable console logging."), ("v", "verbose"): (