From 3365a4ff1157255ca4b648a1381f2528db15a122 Mon Sep 17 00:00:00 2001 From: Karl Kosack Date: Wed, 3 Aug 2022 11:34:00 +0200 Subject: [PATCH] add --datamodel option to ctapipe-info --- ctapipe/tools/info.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/ctapipe/tools/info.py b/ctapipe/tools/info.py index c81dfe2916f..66b927da1e1 100644 --- a/ctapipe/tools/info.py +++ b/ctapipe/tools/info.py @@ -4,12 +4,12 @@ import os import sys -from .utils import get_parser +from pkg_resources import resource_filename + from ..core import Provenance, get_module_version from ..core.plugins import detect_and_import_io_plugins from ..utils import datasets - -from pkg_resources import resource_filename +from .utils import get_parser __all__ = ["info"] @@ -56,6 +56,9 @@ def main(args=None): "--all", dest="show_all", action="store_true", help="show all info" ) parser.add_argument("--plugins", action="store_true", help="Print plugin info") + parser.add_argument( + "--datamodel", action="store_true", help="Print data model info" + ) args = parser.parse_args(args) if len(sys.argv) <= 1: @@ -73,15 +76,19 @@ def info( system=False, plugins=False, show_all=False, + datamodel=False, ): """ Display information about the current ctapipe installation. """ - logging.basicConfig(level=logging.INFO, format="%(levelname)s - %(message)s") + logging.basicConfig(level=logging.CRITICAL, format="%(levelname)s - %(message)s") if version or show_all: _info_version() + if datamodel or show_all: + _info_datamodel() + if tools or show_all: _info_tools() @@ -119,9 +126,10 @@ def _info_tools(): # full help text from the docstring or ArgumentParser? # This is the function names, we want the command-line names # that are defined in setup.py !??? - from ctapipe.tools.utils import get_all_descriptions from textwrap import TextWrapper + from ctapipe.tools.utils import get_all_descriptions + wrapper = TextWrapper(width=80, subsequent_indent=" " * 35) scripts = get_all_descriptions() @@ -148,7 +156,7 @@ def _info_dependencies(): def _info_resources(): - """ display all known resources """ + """display all known resources""" print("\n*** ctapipe resources ***\n") print("CTAPIPE_SVC_PATH: (directories where resources are searched)") @@ -209,5 +217,16 @@ def _info_plugins(): print(f"{name:>20s} -- {version}") +def _info_datamodel(): + from ctapipe.io.datawriter import DATA_MODEL_CHANGE_HISTORY, DATA_MODEL_VERSION + from ctapipe.io.hdf5eventsource import COMPATIBLE_DATA_MODEL_VERSIONS + + print("\n*** ctapipe data model ***\n") + print(f"output version: {DATA_MODEL_VERSION}") + print(f"compatible input versions: {', '.join(COMPATIBLE_DATA_MODEL_VERSIONS)}") + print("change history:") + print(DATA_MODEL_CHANGE_HISTORY) + + if __name__ == "__main__": main()