Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def mypy(session: nox.Session, install_deps: bool = True) -> None:
# Since we use other packages in the frequenz namespace, we need to run the
# checks for frequenz.sdk from the installed package instead of the src
# directory.
mypy_paths = [path for path in source_file_paths(session)
if not path.startswith("src")]
mypy_paths = [
path for path in source_file_paths(session) if not path.startswith("src")
]

mypy_cmd = [
"mypy",
Expand Down Expand Up @@ -115,10 +116,7 @@ def docstrings(session: nox.Session, install_deps: bool = True) -> None:
# This is needed only for the `src` dir, so we exclude the other top level
# dirs that contain code.
darglint_paths = filter(
lambda path: not (
path.startswith("tests")
or path.startswith("benchmarks")
),
lambda path: not (path.startswith("tests") or path.startswith("benchmarks")),
source_file_paths(session),
)
session.run(
Expand Down
15 changes: 15 additions & 0 deletions src/frequenz/sdk/actor/data_sourcing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
The DataSourcingActor.

Copyright
Copyright © 2021 Frequenz Energy-as-a-Service GmbH

License
MIT
"""

from .data_sourcing import DataSourcingActor

__all__ = [
"DataSourcingActor",
]
41 changes: 41 additions & 0 deletions src/frequenz/sdk/actor/data_sourcing/data_sourcing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""The DataSourcing Actor.

Copyright
Copyright © 2022 Frequenz Energy-as-a-Service GmbH

License
MIT
"""

from frequenz.channels import Receiver

from frequenz.sdk.actor import actor
from frequenz.sdk.actor.channel_registry import ChannelRegistry
from frequenz.sdk.data_pipeline import ComponentMetricRequest

from .microgrid_api_source import MicrogridApiSource


@actor
class DataSourcingActor:
"""An actor that provides data streams of metrics as time series."""

def __init__(
self,
request_receiver: Receiver[ComponentMetricRequest],
registry: ChannelRegistry,
Comment on lines +20 to +26
Copy link
Contributor

@sahas-subramanian-frequenz sahas-subramanian-frequenz Oct 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably need a global singleton registry as well, before this PR can be merged.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? I mean why it is a requirement for this to be merged?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we're passing the registry as an argument to an actor, and that's not ideal.

We can of course merge, but then we'll have to come back and fix this afterwards.

) -> None:
"""Create a `DataSourcingActor` instance.

Args:
request_receiver: A channel receiver to accept metric requests from.
registry: A channel registry. To be replaced by a singleton
instance.
"""
self._request_receiver = request_receiver
self._microgrid_api_source = MicrogridApiSource(registry)

async def run(self) -> None:
"""Run the actor."""
async for request in self._request_receiver:
await self._microgrid_api_source.add_metric(request)
Loading