Skip to content

Commit 3000f87

Browse files
Change timestamp naming
Signed-off-by: Flora <[email protected]>
1 parent 9d59b37 commit 3000f87

File tree

4 files changed

+62
-62
lines changed

4 files changed

+62
-62
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Please also refer to [examples](https://github.com/frequenz-floss/frequenz-clien
3030

3131
```bash
3232
# Choose the version you want to install
33-
VERSION=0.16.0
33+
VERSION=0.17.0
3434
pip install frequenz-client-reporting==$VERSION
3535
```
3636

@@ -63,8 +63,8 @@ data = [
6363
microgrid_id=1,
6464
component_id=100,
6565
metrics=[Metric.AC_ACTIVE_POWER, Metric.AC_REACTIVE_POWER],
66-
start_dt=datetime.fromisoformat("2024-05-01T00:00:00"),
67-
end_dt=datetime.fromisoformat("2024-05-02T00:00:00"),
66+
start_time=datetime.fromisoformat("2024-05-01T00:00:00"),
67+
end_time=datetime.fromisoformat("2024-05-02T00:00:00"),
6868
resampling_period=timedelta(seconds=1),
6969
)
7070
]
@@ -79,8 +79,8 @@ data = [
7979
microgrid_id=1,
8080
sensor_id=100,
8181
metrics=[Metric.SENSOR_IRRADIANCE],
82-
start_dt=datetime.fromisoformat("2024-05-01T00:00:00"),
83-
end_dt=datetime.fromisoformat("2024-05-02T00:00:00"),
82+
start_time=datetime.fromisoformat("2024-05-01T00:00:00"),
83+
end_time=datetime.fromisoformat("2024-05-02T00:00:00"),
8484
resampling_period=timedelta(seconds=1),
8585
)
8686
]
@@ -106,8 +106,8 @@ data = [
106106
client.list_microgrid_components_data(
107107
microgrid_components=microgrid_components,
108108
metrics=[Metric.AC_ACTIVE_POWER, Metric.AC_REACTIVE_POWER],
109-
start_dt=datetime.fromisoformat("2024-05-01T00:00:00"),
110-
end_dt=datetime.fromisoformat("2024-05-02T00:00:00"),
109+
start_time=datetime.fromisoformat("2024-05-01T00:00:00"),
110+
end_time=datetime.fromisoformat("2024-05-02T00:00:00"),
111111
resampling_period=timedelta(seconds=1),
112112
include_states=False, # Set to True to include state data
113113
include_bounds=False, # Set to True to include metric bounds data
@@ -134,8 +134,8 @@ data = [
134134
client.receive_microgrid_sensors_data(
135135
microgrid_sensors=microgrid_sensors,
136136
metrics=[Metric.SENSOR_IRRADIANCE],
137-
start_dt=datetime.fromisoformat("2024-05-01T00:00:00"),
138-
end_dt=datetime.fromisoformat("2024-05-02T00:00:00"),
137+
start_time=datetime.fromisoformat("2024-05-01T00:00:00"),
138+
end_time=datetime.fromisoformat("2024-05-02T00:00:00"),
139139
resampling_period=timedelta(seconds=1),
140140
include_states=False, # Set to True to include state data
141141
)

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## Upgrading
88

9-
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
9+
* Change 'start_dt' and 'end_dt' to 'start_time' and 'end_time' respectively.
1010

1111
## New Features
1212

src/frequenz/client/reporting/_client.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ async def list_single_component_data(
240240
microgrid_id: int,
241241
component_id: int,
242242
metrics: Metric | list[Metric],
243-
start_dt: datetime | None,
244-
end_dt: datetime | None,
243+
start_time: datetime | None,
244+
end_time: datetime | None,
245245
resampling_period: timedelta | None,
246246
include_states: bool = False,
247247
include_bounds: bool = False,
@@ -252,8 +252,8 @@ async def list_single_component_data(
252252
microgrid_id: The microgrid ID.
253253
component_id: The component ID.
254254
metrics: The metric name or list of metric names.
255-
start_dt: start datetime, if None, the earliest available data will be used
256-
end_dt: end datetime, if None starts streaming indefinitely from start_dt
255+
start_time: start datetime, if None, the earliest available data will be used
256+
end_time: end datetime, if None starts streaming indefinitely from start_time
257257
resampling_period: The period for resampling the data.
258258
include_states: Whether to include the state data.
259259
include_bounds: Whether to include the bound data.
@@ -266,8 +266,8 @@ async def list_single_component_data(
266266
async for batch in self._list_microgrid_components_data_batch(
267267
microgrid_components=[(microgrid_id, [component_id])],
268268
metrics=[metrics] if isinstance(metrics, Metric) else metrics,
269-
start_dt=start_dt,
270-
end_dt=end_dt,
269+
start_time=start_time,
270+
end_time=end_time,
271271
resampling_period=resampling_period,
272272
include_states=include_states,
273273
include_bounds=include_bounds,
@@ -281,8 +281,8 @@ async def list_microgrid_components_data(
281281
*,
282282
microgrid_components: list[tuple[int, list[int]]],
283283
metrics: Metric | list[Metric],
284-
start_dt: datetime | None,
285-
end_dt: datetime | None,
284+
start_time: datetime | None,
285+
end_time: datetime | None,
286286
resampling_period: timedelta | None,
287287
include_states: bool = False,
288288
include_bounds: bool = False,
@@ -293,8 +293,8 @@ async def list_microgrid_components_data(
293293
microgrid_components: List of tuples where each tuple contains
294294
microgrid ID and corresponding component IDs.
295295
metrics: The metric name or list of metric names.
296-
start_dt: start datetime, if None, the earliest available data will be used
297-
end_dt: end datetime, if None starts streaming indefinitely from start_dt
296+
start_time: start datetime, if None, the earliest available data will be used
297+
end_time: end datetime, if None starts streaming indefinitely from start_time
298298
resampling_period: The period for resampling the data.
299299
include_states: Whether to include the state data.
300300
include_bounds: Whether to include the bound data.
@@ -310,8 +310,8 @@ async def list_microgrid_components_data(
310310
async for batch in self._list_microgrid_components_data_batch(
311311
microgrid_components=microgrid_components,
312312
metrics=[metrics] if isinstance(metrics, Metric) else metrics,
313-
start_dt=start_dt,
314-
end_dt=end_dt,
313+
start_time=start_time,
314+
end_time=end_time,
315315
resampling_period=resampling_period,
316316
include_states=include_states,
317317
include_bounds=include_bounds,
@@ -326,8 +326,8 @@ async def _list_microgrid_components_data_batch(
326326
*,
327327
microgrid_components: list[tuple[int, list[int]]],
328328
metrics: list[Metric],
329-
start_dt: datetime | None,
330-
end_dt: datetime | None,
329+
start_time: datetime | None,
330+
end_time: datetime | None,
331331
resampling_period: timedelta | None,
332332
include_states: bool = False,
333333
include_bounds: bool = False,
@@ -337,8 +337,8 @@ async def _list_microgrid_components_data_batch(
337337
Args:
338338
microgrid_components: A list of tuples of microgrid IDs and component IDs.
339339
metrics: A list of metrics.
340-
start_dt: start datetime, if None, the earliest available data will be used
341-
end_dt: end datetime, if None starts streaming indefinitely from start_dt
340+
start_time: start datetime, if None, the earliest available data will be used
341+
end_time: end datetime, if None starts streaming indefinitely from start_time
342342
resampling_period: The period for resampling the data.
343343
include_states: Whether to include the state data.
344344
include_bounds: Whether to include the bound data.
@@ -357,8 +357,8 @@ def dt2ts(dt: datetime) -> PBTimestamp:
357357
return ts
358358

359359
time_filter = PBTimeFilter(
360-
start=dt2ts(start_dt) if start_dt else None,
361-
end=dt2ts(end_dt) if end_dt else None,
360+
start=dt2ts(start_time) if start_time else None,
361+
end=dt2ts(end_time) if end_time else None,
362362
)
363363

364364
incl_states = (
@@ -437,8 +437,8 @@ async def receive_single_sensor_data(
437437
microgrid_id: int,
438438
sensor_id: int,
439439
metrics: Metric | list[Metric],
440-
start_dt: datetime | None,
441-
end_dt: datetime | None,
440+
start_time: datetime | None,
441+
end_time: datetime | None,
442442
resampling_period: timedelta | None,
443443
include_states: bool = False,
444444
) -> AsyncIterator[MetricSample]:
@@ -448,8 +448,8 @@ async def receive_single_sensor_data(
448448
microgrid_id: The microgrid ID.
449449
sensor_id: The sensor ID.
450450
metrics: The metric name or list of metric names.
451-
start_dt: start datetime, if None, the earliest available data will be used.
452-
end_dt: end datetime, if None starts streaming indefinitely from start_dt.
451+
start_time: start datetime, if None, the earliest available data will be used.
452+
end_time: end datetime, if None starts streaming indefinitely from start_time.
453453
resampling_period: The period for resampling the data.
454454
include_states: Whether to include the state data.
455455
@@ -461,8 +461,8 @@ async def receive_single_sensor_data(
461461
receiver = await self._receive_microgrid_sensors_data_batch(
462462
microgrid_sensors=[(microgrid_id, [sensor_id])],
463463
metrics=[metrics] if isinstance(metrics, Metric) else metrics,
464-
start_dt=start_dt,
465-
end_dt=end_dt,
464+
start_time=start_time,
465+
end_time=end_time,
466466
resampling_period=resampling_period,
467467
include_states=include_states,
468468
)
@@ -476,8 +476,8 @@ async def receive_microgrid_sensors_data(
476476
*,
477477
microgrid_sensors: list[tuple[int, list[int]]],
478478
metrics: Metric | list[Metric],
479-
start_dt: datetime | None,
480-
end_dt: datetime | None,
479+
start_time: datetime | None,
480+
end_time: datetime | None,
481481
resampling_period: timedelta | None,
482482
include_states: bool = False,
483483
) -> AsyncIterator[MetricSample]:
@@ -487,8 +487,8 @@ async def receive_microgrid_sensors_data(
487487
microgrid_sensors: List of tuples where each tuple contains
488488
microgrid ID and corresponding sensor IDs.
489489
metrics: The metric name or list of metric names.
490-
start_dt: start datetime, if None, the earliest available data will be used.
491-
end_dt: end datetime, if None starts streaming indefinitely from start_dt.
490+
start_time: start datetime, if None, the earliest available data will be used.
491+
end_time: end datetime, if None starts streaming indefinitely from start_time.
492492
resampling_period: The period for resampling the data.
493493
include_states: Whether to include the state data.
494494
@@ -503,8 +503,8 @@ async def receive_microgrid_sensors_data(
503503
receiver = await self._receive_microgrid_sensors_data_batch(
504504
microgrid_sensors=microgrid_sensors,
505505
metrics=[metrics] if isinstance(metrics, Metric) else metrics,
506-
start_dt=start_dt,
507-
end_dt=end_dt,
506+
start_time=start_time,
507+
end_time=end_time,
508508
resampling_period=resampling_period,
509509
include_states=include_states,
510510
)
@@ -519,8 +519,8 @@ async def _receive_microgrid_sensors_data_batch(
519519
*,
520520
microgrid_sensors: list[tuple[int, list[int]]],
521521
metrics: list[Metric],
522-
start_dt: datetime | None,
523-
end_dt: datetime | None,
522+
start_time: datetime | None,
523+
end_time: datetime | None,
524524
resampling_period: timedelta | None,
525525
include_states: bool = False,
526526
) -> AsyncIterator[SensorsDataBatch]:
@@ -529,8 +529,8 @@ async def _receive_microgrid_sensors_data_batch(
529529
Args:
530530
microgrid_sensors: A list of tuples of microgrid IDs and sensor IDs.
531531
metrics: A list of metrics.
532-
start_dt: start datetime, if None, the earliest available data will be used.
533-
end_dt: end datetime, if None starts streaming indefinitely from start_dt.
532+
start_time: start datetime, if None, the earliest available data will be used.
533+
end_time: end datetime, if None starts streaming indefinitely from start_time.
534534
resampling_period: The period for resampling the data.
535535
include_states: Whether to include the state data.
536536
@@ -548,8 +548,8 @@ def dt2ts(dt: datetime) -> PBTimestamp:
548548
return ts
549549

550550
time_filter = PBTimeFilter(
551-
start=dt2ts(start_dt) if start_dt else None,
552-
end=dt2ts(end_dt) if end_dt else None,
551+
start=dt2ts(start_time) if start_time else None,
552+
end=dt2ts(end_time) if end_time else None,
553553
)
554554

555555
incl_states = (
@@ -619,8 +619,8 @@ async def receive_aggregated_data(
619619
microgrid_id: int,
620620
metric: Metric,
621621
aggregation_formula: str,
622-
start: datetime | None,
623-
end: datetime | None,
622+
start_time: datetime | None,
623+
end_time: datetime | None,
624624
resampling_period: timedelta,
625625
) -> AsyncIterator[MetricSample]:
626626
"""Iterate over aggregated data for a single metric using GrpcStreamBroadcaster.
@@ -630,8 +630,8 @@ async def receive_aggregated_data(
630630
microgrid_id: The microgrid ID.
631631
metric: The metric name.
632632
aggregation_formula: The aggregation formula.
633-
start: start datetime, if None, the earliest available data will be used
634-
end: end datetime, if None starts streaming indefinitely from start
633+
start_time: start datetime, if None, the earliest available data will be used
634+
end_time: end datetime, if None starts streaming indefinitely from start_time
635635
resampling_period: The period for resampling the data.
636636
637637
Yields:
@@ -655,8 +655,8 @@ def dt2ts(dt: datetime) -> PBTimestamp:
655655
return ts
656656

657657
time_filter = PBTimeFilter(
658-
start=dt2ts(start) if start else None,
659-
end=dt2ts(end) if end else None,
658+
start=dt2ts(start_time) if start_time else None,
659+
end=dt2ts(end_time) if end_time else None,
660660
)
661661

662662
stream_filter = PBAggregatedStreamRequest.AggregationStreamFilter(

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def main() -> None:
9191
microgrid_id=args.mid,
9292
component_id=args.cid,
9393
metric_names=args.metrics,
94-
start_dt=args.start,
95-
end_dt=args.end,
94+
start_time=args.start,
95+
end_time=args.end,
9696
resampling_period_s=args.resampling_period_s,
9797
states=args.states,
9898
bounds=args.bounds,
@@ -109,8 +109,8 @@ async def run( # noqa: DOC502
109109
microgrid_id: int,
110110
component_id: list[str],
111111
metric_names: list[str],
112-
start_dt: datetime | None,
113-
end_dt: datetime | None,
112+
start_time: datetime | None,
113+
end_time: datetime | None,
114114
resampling_period_s: int | None,
115115
states: bool,
116116
bounds: bool,
@@ -124,8 +124,8 @@ async def run( # noqa: DOC502
124124
microgrid_id: microgrid ID
125125
component_id: component ID
126126
metric_names: list of metric names
127-
start_dt: start datetime, if None, the earliest available data will be used
128-
end_dt: end datetime, if None starts streaming indefinitely from start_dt
127+
start_time: start datetime, if None, the earliest available data will be used
128+
end_time: end datetime, if None starts streaming indefinitely from start_time
129129
resampling_period_s: The period for resampling the data.
130130
states: include states in the output
131131
bounds: include bounds in the output
@@ -161,8 +161,8 @@ async def data_iter() -> AsyncIterator[MetricSample]:
161161
async for sample in client.list_microgrid_components_data(
162162
microgrid_components=microgrid_components,
163163
metrics=metrics,
164-
start_dt=start_dt,
165-
end_dt=end_dt,
164+
start_time=start_time,
165+
end_time=end_time,
166166
resampling_period=resampling_period,
167167
include_states=states,
168168
include_bounds=bounds,
@@ -176,8 +176,8 @@ async def data_iter() -> AsyncIterator[MetricSample]:
176176
microgrid_id=microgrid_id,
177177
metric=metric,
178178
aggregation_formula=formula,
179-
start=start_dt,
180-
end=end_dt,
179+
start_time=start_time,
180+
end_time=end_time,
181181
resampling_period=resampling_period,
182182
):
183183
yield sample

0 commit comments

Comments
 (0)