From 213e24e71c09237ff905ac31fd8c11f937efafc0 Mon Sep 17 00:00:00 2001 From: Victor Garcia Reolid Date: Thu, 18 May 2023 16:37:39 +0200 Subject: [PATCH 1/3] feat: create show reporter command Signed-off-by: Victor Garcia Reolid --- flexmeasures/cli/data_show.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/flexmeasures/cli/data_show.py b/flexmeasures/cli/data_show.py index 9c28d038c..59b8fe2cf 100644 --- a/flexmeasures/cli/data_show.py +++ b/flexmeasures/cli/data_show.py @@ -376,4 +376,27 @@ def plot_beliefs( click.secho("Data saved to file.", **MsgStyle.SUCCESS) +@fm_show_data.command("reporters") +@with_appcontext +def list_reporters(): + """ + Show available reporters. + """ + + click.echo("Reporters:\n") + click.echo( + tabulate( + [ + ( + reporter_name, + reporter_class.__version__, + str(reporter_class.__author__), + ) + for reporter_name, reporter_class in app.reporters.items() + ], + headers=["name", "version", "author"], + ) + ) + + app.cli.add_command(fm_show_data) From 1d1ed7213fa6be91d795f231dae9bfe686dc9649 Mon Sep 17 00:00:00 2001 From: Victor Garcia Reolid Date: Thu, 18 May 2023 16:46:15 +0200 Subject: [PATCH 2/3] style: add hint to list reporters Signed-off-by: Victor Garcia Reolid --- flexmeasures/cli/data_add.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flexmeasures/cli/data_add.py b/flexmeasures/cli/data_add.py index a9b39141d..d761d8d53 100755 --- a/flexmeasures/cli/data_add.py +++ b/flexmeasures/cli/data_add.py @@ -1133,7 +1133,8 @@ def add_schedule_for_storage( default="PandasReporter", required=True, type=click.STRING, - help="Reporter class registered in flexmeasures.data.models.reporting or in an available flexmeasures plugin.", + help="Reporter class registered in flexmeasures.data.models.reporting or in an available flexmeasures plugin." + " Use the command `flexmeasures show reporters` to list all the available reporters.", ) @click.option( "--sensor-id", From 304b96c858e4b8b11bd0cb16aeb37a4a0a0d8b88 Mon Sep 17 00:00:00 2001 From: Victor Garcia Reolid Date: Fri, 19 May 2023 11:38:30 +0200 Subject: [PATCH 3/3] style: add module name style: print empty string when the author is missing Signed-off-by: Victor Garcia Reolid --- flexmeasures/cli/data_show.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flexmeasures/cli/data_show.py b/flexmeasures/cli/data_show.py index 59b8fe2cf..91ad142d8 100644 --- a/flexmeasures/cli/data_show.py +++ b/flexmeasures/cli/data_show.py @@ -388,13 +388,14 @@ def list_reporters(): tabulate( [ ( + reporter_class.__module__, reporter_name, reporter_class.__version__, - str(reporter_class.__author__), + reporter_class.__author__, ) for reporter_name, reporter_class in app.reporters.items() ], - headers=["name", "version", "author"], + headers=["module", "name", "version", "author"], ) )