Skip to content

Commit 965b0cf

Browse files
committed
Support multiple component IDs in CLI tool
So far only single components were supported, this allows requests for data from multiple components. Signed-off-by: cwasicki <[email protected]>
1 parent 49e48fc commit 965b0cf

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/frequenz/client/reporting/__main__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ def main() -> None:
2525
default="localhost:50051",
2626
)
2727
parser.add_argument("--mid", type=int, help="Microgrid ID", required=True)
28-
parser.add_argument("--cid", type=int, help="Component ID", required=True)
28+
parser.add_argument(
29+
"--cid",
30+
nargs="+",
31+
type=int,
32+
help="Component IDs",
33+
)
2934
parser.add_argument(
3035
"--metrics",
3136
type=str,
@@ -97,7 +102,7 @@ def main() -> None:
97102
async def run(
98103
*,
99104
microgrid_id: int,
100-
component_id: int,
105+
component_id: list[int],
101106
metric_names: list[str],
102107
start_dt: datetime | None,
103108
end_dt: datetime | None,
@@ -129,6 +134,7 @@ async def run(
129134
client = ReportingApiClient(service_address, key)
130135

131136
metrics = [Metric[mn] for mn in metric_names]
137+
microgrid_components = [(microgrid_id, component_id)]
132138

133139
def data_iter() -> AsyncIterator[MetricSample]:
134140
"""Iterate over single metric.
@@ -144,9 +150,8 @@ def data_iter() -> AsyncIterator[MetricSample]:
144150
else None
145151
)
146152

147-
return client.list_single_component_data(
148-
microgrid_id=microgrid_id,
149-
component_id=component_id,
153+
return client.list_microgrid_components_data(
154+
microgrid_components=microgrid_components,
150155
metrics=metrics,
151156
start_dt=start_dt,
152157
end_dt=end_dt,

0 commit comments

Comments
 (0)