66from collections import namedtuple
77from collections .abc import AsyncIterator , Iterable , Iterator
88from dataclasses import dataclass
9- from datetime import datetime
9+ from datetime import datetime , timedelta
1010from typing import cast
1111
1212import grpc .aio as grpcaio
@@ -160,7 +160,7 @@ async def list_single_component_data(
160160 metrics : Metric | list [Metric ],
161161 start_dt : datetime ,
162162 end_dt : datetime ,
163- resolution : int | None ,
163+ resampling_period : timedelta | None ,
164164 include_states : bool = False ,
165165 include_bounds : bool = False ,
166166 ) -> AsyncIterator [MetricSample ]:
@@ -172,7 +172,7 @@ async def list_single_component_data(
172172 metrics: The metric name or list of metric names.
173173 start_dt: The start date and time.
174174 end_dt: The end date and time.
175- resolution : The resampling resolution for the data, represented in seconds .
175+ resampling_period : The period for resampling the data.
176176 include_states: Whether to include the state data.
177177 include_bounds: Whether to include the bound data.
178178
@@ -186,7 +186,7 @@ async def list_single_component_data(
186186 metrics = [metrics ] if isinstance (metrics , Metric ) else metrics ,
187187 start_dt = start_dt ,
188188 end_dt = end_dt ,
189- resolution = resolution ,
189+ resampling_period = resampling_period ,
190190 include_states = include_states ,
191191 include_bounds = include_bounds ,
192192 ):
@@ -201,7 +201,7 @@ async def list_microgrid_components_data(
201201 metrics : Metric | list [Metric ],
202202 start_dt : datetime ,
203203 end_dt : datetime ,
204- resolution : int | None ,
204+ resampling_period : timedelta | None ,
205205 include_states : bool = False ,
206206 include_bounds : bool = False ,
207207 ) -> AsyncIterator [MetricSample ]:
@@ -213,7 +213,7 @@ async def list_microgrid_components_data(
213213 metrics: The metric name or list of metric names.
214214 start_dt: The start date and time.
215215 end_dt: The end date and time.
216- resolution : The resampling resolution for the data, represented in seconds .
216+ resampling_period : The period for resampling the data.
217217 include_states: Whether to include the state data.
218218 include_bounds: Whether to include the bound data.
219219
@@ -230,7 +230,7 @@ async def list_microgrid_components_data(
230230 metrics = [metrics ] if isinstance (metrics , Metric ) else metrics ,
231231 start_dt = start_dt ,
232232 end_dt = end_dt ,
233- resolution = resolution ,
233+ resampling_period = resampling_period ,
234234 include_states = include_states ,
235235 include_bounds = include_bounds ,
236236 ):
@@ -246,7 +246,7 @@ async def _list_microgrid_components_data_batch(
246246 metrics : list [Metric ],
247247 start_dt : datetime ,
248248 end_dt : datetime ,
249- resolution : int | None ,
249+ resampling_period : timedelta | None ,
250250 include_states : bool = False ,
251251 include_bounds : bool = False ,
252252 ) -> AsyncIterator [ComponentsDataBatch ]:
@@ -260,7 +260,7 @@ async def _list_microgrid_components_data_batch(
260260 metrics: A list of metrics.
261261 start_dt: The start date and time.
262262 end_dt: The end date and time.
263- resolution : The resampling resolution for the data, represented in seconds .
263+ resampling_period : The period for resampling the data.
264264 include_states: Whether to include the state data.
265265 include_bounds: Whether to include the bound data.
266266
@@ -299,7 +299,13 @@ def dt2ts(dt: datetime) -> PBTimestamp:
299299
300300 stream_filter = PBReceiveMicrogridComponentsDataStreamRequest .StreamFilter (
301301 time_filter = time_filter ,
302- resampling_options = PBResamplingOptions (resolution = resolution ),
302+ resampling_options = PBResamplingOptions (
303+ resolution = (
304+ round (resampling_period .total_seconds ())
305+ if resampling_period is not None
306+ else None
307+ )
308+ ),
303309 include_options = include_options ,
304310 )
305311
0 commit comments