Skip to content

Commit 0dec700

Browse files
committed
Remove dict format outputs in the CLI
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 2464c3e commit 0dec700

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

src/frequenz/client/reporting/cli/__main__.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import argparse
77
import asyncio
88
from datetime import datetime, timedelta
9-
from pprint import pprint
109
from typing import AsyncIterator
1110

1211
from frequenz.client.common.metric import Metric
@@ -187,11 +186,6 @@ async def data_iter() -> AsyncIterator[MetricSample]:
187186
async for sample in data_iter():
188187
print(sample)
189188

190-
elif fmt == "dict":
191-
# Dumping all data as a single dict
192-
dct = await iter_to_dict(data_iter())
193-
pprint(dct)
194-
195189
elif fmt == "csv":
196190
# Print header
197191
print(",".join(MetricSample._fields))
@@ -205,42 +199,5 @@ async def data_iter() -> AsyncIterator[MetricSample]:
205199
return
206200

207201

208-
async def iter_to_dict(
209-
components_data_iter: AsyncIterator[MetricSample],
210-
) -> dict[int, dict[int, dict[datetime, dict[Metric, float]]]]:
211-
"""Convert components data iterator into a single dict.
212-
213-
The nesting structure is:
214-
{
215-
microgrid_id: {
216-
component_id: {
217-
timestamp: {
218-
metric: value
219-
}
220-
}
221-
}
222-
}
223-
224-
Args:
225-
components_data_iter: async generator
226-
227-
Returns:
228-
Single dict with with all components data
229-
"""
230-
ret: dict[int, dict[int, dict[datetime, dict[Metric, float]]]] = {}
231-
232-
async for ts, mid, cid, met, value in components_data_iter:
233-
if mid not in ret:
234-
ret[mid] = {}
235-
if cid not in ret[mid]:
236-
ret[mid][cid] = {}
237-
if ts not in ret[mid][cid]:
238-
ret[mid][cid][ts] = {}
239-
240-
ret[mid][cid][ts][met] = value
241-
242-
return ret
243-
244-
245202
if __name__ == "__main__":
246203
main()

0 commit comments

Comments
 (0)