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
@@ -168,7 +168,7 @@ async def list_single_component_data(
168168 metrics : Metric | list [Metric ],
169169 start_dt : datetime ,
170170 end_dt : datetime ,
171- resolution : int | None ,
171+ resampling_period : timedelta | None ,
172172 include_states : bool = False ,
173173 include_bounds : bool = False ,
174174 ) -> AsyncIterator [MetricSample ]:
@@ -180,7 +180,7 @@ async def list_single_component_data(
180180 metrics: The metric name or list of metric names.
181181 start_dt: The start date and time.
182182 end_dt: The end date and time.
183- resolution : The resampling resolution for the data, represented in seconds .
183+ resampling_period : The period for resampling the data.
184184 include_states: Whether to include the state data.
185185 include_bounds: Whether to include the bound data.
186186
@@ -194,7 +194,7 @@ async def list_single_component_data(
194194 metrics = [metrics ] if isinstance (metrics , Metric ) else metrics ,
195195 start_dt = start_dt ,
196196 end_dt = end_dt ,
197- resolution = resolution ,
197+ resampling_period = resampling_period ,
198198 include_states = include_states ,
199199 include_bounds = include_bounds ,
200200 ):
@@ -209,7 +209,7 @@ async def list_microgrid_components_data(
209209 metrics : Metric | list [Metric ],
210210 start_dt : datetime ,
211211 end_dt : datetime ,
212- resolution : int | None ,
212+ resampling_period : timedelta | None ,
213213 include_states : bool = False ,
214214 include_bounds : bool = False ,
215215 ) -> AsyncIterator [MetricSample ]:
@@ -221,7 +221,7 @@ async def list_microgrid_components_data(
221221 metrics: The metric name or list of metric names.
222222 start_dt: The start date and time.
223223 end_dt: The end date and time.
224- resolution : The resampling resolution for the data, represented in seconds .
224+ resampling_period : The period for resampling the data.
225225 include_states: Whether to include the state data.
226226 include_bounds: Whether to include the bound data.
227227
@@ -238,7 +238,7 @@ async def list_microgrid_components_data(
238238 metrics = [metrics ] if isinstance (metrics , Metric ) else metrics ,
239239 start_dt = start_dt ,
240240 end_dt = end_dt ,
241- resolution = resolution ,
241+ resampling_period = resampling_period ,
242242 include_states = include_states ,
243243 include_bounds = include_bounds ,
244244 ):
@@ -254,7 +254,7 @@ async def _list_microgrid_components_data_batch(
254254 metrics : list [Metric ],
255255 start_dt : datetime ,
256256 end_dt : datetime ,
257- resolution : int | None ,
257+ resampling_period : timedelta | None ,
258258 include_states : bool = False ,
259259 include_bounds : bool = False ,
260260 ) -> AsyncIterator [ComponentsDataBatch ]:
@@ -268,7 +268,7 @@ async def _list_microgrid_components_data_batch(
268268 metrics: A list of metrics.
269269 start_dt: The start date and time.
270270 end_dt: The end date and time.
271- resolution : The resampling resolution for the data, represented in seconds .
271+ resampling_period : The period for resampling the data.
272272 include_states: Whether to include the state data.
273273 include_bounds: Whether to include the bound data.
274274
@@ -307,7 +307,13 @@ def dt2ts(dt: datetime) -> PBTimestamp:
307307
308308 stream_filter = PBReceiveMicrogridComponentsDataStreamRequest .StreamFilter (
309309 time_filter = time_filter ,
310- resampling_options = PBResamplingOptions (resolution = resolution ),
310+ resampling_options = PBResamplingOptions (
311+ resolution = (
312+ round (resampling_period .total_seconds ())
313+ if resampling_period is not None
314+ else None
315+ )
316+ ),
311317 include_options = include_options ,
312318 )
313319
0 commit comments