From 74a2dc834ca3fa50e4f58d05adb62ad9f4293804 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Thu, 24 Nov 2022 23:16:08 +0100 Subject: [PATCH 1/3] Clean up table formatting Signed-off-by: F.N. Claessen --- flexmeasures/cli/data_show.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/flexmeasures/cli/data_show.py b/flexmeasures/cli/data_show.py index 68d3b236c..1f6df34fe 100644 --- a/flexmeasures/cli/data_show.py +++ b/flexmeasures/cli/data_show.py @@ -89,9 +89,9 @@ def show_account(account): """ Show information about an account, including users and assets. """ - click.echo(f"========{len(account.name) * '='}==========") - click.echo(f"Account {account.name} (ID:{account.id}):") - click.echo(f"========{len(account.name) * '='}==========\n") + click.echo(f"========{len(account.name) * '='}========") + click.echo(f"Account {account.name} (ID: {account.id})") + click.echo(f"========{len(account.name) * '='}========\n") if account.account_roles: click.echo( @@ -162,15 +162,15 @@ def show_generic_asset(asset): """ Show asset info and list sensors """ - click.echo(f"======{len(asset.name) * '='}==========") - click.echo(f"Asset {asset.name} (ID:{asset.id}):") - click.echo(f"======{len(asset.name) * '='}==========\n") + click.echo(f"======{len(asset.name) * '='}=========") + click.echo(f"Asset {asset.name} (ID: {asset.id})") + click.echo(f"======{len(asset.name) * '='}=========\n") asset_data = [ ( asset.generic_asset_type.name, asset.location, - "".join([f"{k}:{v}\n" for k, v in asset.attributes.items()]), + "".join([f"{k}: {v}\n" for k, v in asset.attributes.items()]), ) ] click.echo(tabulate(asset_data, headers=["Type", "Location", "Attributes"])) @@ -190,7 +190,7 @@ def show_generic_asset(asset): sensor.unit, naturaldelta(sensor.event_resolution), sensor.timezone, - ",".join([f"{k}:{v}\n" for k, v in sensor.attributes.items()]), + "".join([f"{k}: {v}\n" for k, v in sensor.attributes.items()]), ) for sensor in sensors ] From cdc4241283d96667e81b4747d6b5df7abaaef8a9 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Thu, 24 Nov 2022 23:16:53 +0100 Subject: [PATCH 2/3] Streamline how the term ID is printed out Signed-off-by: F.N. Claessen --- flexmeasures/cli/data_show.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flexmeasures/cli/data_show.py b/flexmeasures/cli/data_show.py index 1f6df34fe..8e356456f 100644 --- a/flexmeasures/cli/data_show.py +++ b/flexmeasures/cli/data_show.py @@ -48,7 +48,7 @@ def list_accounts(): ) for account in accounts ] - click.echo(tabulate(account_data, headers=["Id", "Name", "Assets"])) + click.echo(tabulate(account_data, headers=["ID", "Name", "Assets"])) @fm_show_data.command("roles") @@ -65,7 +65,7 @@ def list_roles(): click.echo( tabulate( [(r.id, r.name, r.description) for r in account_roles], - headers=["Id", "Name", "Description"], + headers=["ID", "Name", "Description"], ) ) click.echo() @@ -77,7 +77,7 @@ def list_roles(): click.echo( tabulate( [(r.id, r.name, r.description) for r in user_roles], - headers=["Id", "Name", "Description"], + headers=["ID", "Name", "Description"], ) ) @@ -117,7 +117,7 @@ def show_account(account): for user in users ] click.echo( - tabulate(user_data, headers=["Id", "Name", "Email", "Last Login", "Roles"]) + tabulate(user_data, headers=["ID", "Name", "Email", "Last Login", "Roles"]) ) click.echo() @@ -134,7 +134,7 @@ def show_account(account): (asset.id, asset.name, asset.generic_asset_type.name, asset.location) for asset in assets ] - click.echo(tabulate(asset_data, headers=["Id", "Name", "Type", "Location"])) + click.echo(tabulate(asset_data, headers=["ID", "Name", "Type", "Location"])) @fm_show_data.command("asset-types") @@ -150,7 +150,7 @@ def list_asset_types(): click.echo( tabulate( [(t.id, t.name, t.description) for t in asset_types], - headers=["Id", "Name", "Description"], + headers=["ID", "Name", "Description"], ) ) @@ -197,7 +197,7 @@ def show_generic_asset(asset): click.echo( tabulate( sensor_data, - headers=["Id", "Name", "Unit", "Resolution", "Timezone", "Attributes"], + headers=["ID", "Name", "Unit", "Resolution", "Timezone", "Attributes"], ) ) @@ -215,7 +215,7 @@ def list_data_sources(): click.echo( tabulate( [(s.id, s.name, s.type, s.user_id, s.model, s.version) for s in sources], - headers=["Id", "Name", "Type", "User Id", "Model", "Version"], + headers=["ID", "Name", "Type", "User ID", "Model", "Version"], ) ) @@ -312,7 +312,7 @@ def plot_beliefs( # only keep non-empty for s in sensors: if beliefs_by_sensor[s.name].empty: - click.echo(f"No data found for sensor '{s.name}' (Id: {s.id})") + click.echo(f"No data found for sensor '{s.name}' (ID: {s.id})") beliefs_by_sensor.pop(s.name) sensors.remove(s) if len(beliefs_by_sensor.keys()) == 0: From 1d6b86b0043a0718761080a4efdf4b11628079bf Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Thu, 24 Nov 2022 23:34:41 +0100 Subject: [PATCH 3/3] Changelog entry Signed-off-by: F.N. Claessen --- documentation/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/changelog.rst b/documentation/changelog.rst index 8c8dcbaa8..97ff988ea 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -33,6 +33,7 @@ Infrastructure / Support * Improve documentation and code w.r.t. storage flexibility modelling ― prepare for handling other schedulers & merge battery and car charging schedulers [see `PR #511 `_] * Revised strategy for removing unchanged beliefs when saving data: retain the oldest measurement (ex-post belief), too [see `PR #518 `_] * Scheduling test for maximizing self-consumption, and improved time series db queries for fixed tariffs (and other long-term constants) [see `PR #532 `_] +* Clean up table formatting for ``flexmeasures show`` CLI commands [see `PR #540 `_] v0.11.3 | November 2, 2022