Skip to content

Commit 3c2768f

Browse files
committed
Make _data_pipeline.initialize() async
We'll need to start actors in this function in the future, so we need it to be async to be able to `await actor.start()`. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent ab6a421 commit 3c2768f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/frequenz/sdk/microgrid/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async def initialize(host: str, port: int, resampler_config: ResamplerConfig) ->
2222
resampler_config: Configuration for the resampling actor.
2323
"""
2424
await connection_manager.initialize(host, port)
25-
_data_pipeline.initialize(resampler_config)
25+
await _data_pipeline.initialize(resampler_config)
2626

2727

2828
__all__ = [

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,14 @@ async def _stop(self) -> None:
270270
if self._data_sourcing_actor:
271271
await self._data_sourcing_actor.actor._stop() # type: ignore
272272
if self._resampling_actor:
273-
await self._resampling_actor.actor._stop() # type: ignore
273+
await self._resampling_actor.actor.stop()
274274
# pylint: enable=protected-access
275275

276276

277277
_DATA_PIPELINE: _DataPipeline | None = None
278278

279279

280-
def initialize(resampler_config: ResamplerConfig) -> None:
280+
async def initialize(resampler_config: ResamplerConfig) -> None:
281281
"""Initialize a `DataPipeline` instance.
282282
283283
Args:

tests/timeseries/_battery_pool/test_battery_pool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async def setup_all_batteries(mocker: MockerFixture) -> AsyncIterator[SetupArgs]
136136
min_update_interval: float = 0.2
137137
# pylint: disable=protected-access
138138
microgrid._data_pipeline._DATA_PIPELINE = None
139-
microgrid._data_pipeline.initialize(
139+
await microgrid._data_pipeline.initialize(
140140
ResamplerConfig(resampling_period=timedelta(seconds=min_update_interval))
141141
)
142142
streamer = MockComponentDataStreamer(mock_microgrid)
@@ -188,7 +188,7 @@ async def setup_batteries_pool(mocker: MockerFixture) -> AsyncIterator[SetupArgs
188188
min_update_interval: float = 0.2
189189
# pylint: disable=protected-access
190190
microgrid._data_pipeline._DATA_PIPELINE = None
191-
microgrid._data_pipeline.initialize(
191+
await microgrid._data_pipeline.initialize(
192192
ResamplerConfig(resampling_period=timedelta(seconds=min_update_interval))
193193
)
194194

0 commit comments

Comments
 (0)