Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e53e91b
Group dependabot updates and make them weekly
llucax Aug 29, 2023
c3aa3a3
ci: Add debug info and run `nox` sessions in parallel
llucax Aug 29, 2023
f61a546
Remove `darglint` configuration
llucax Aug 29, 2023
b1131f8
Remove transitive dependencies
llucax Aug 29, 2023
18bf79b
Change docstrings dependencies to `flake8`
llucax Aug 29, 2023
5cf27c0
Ignore pylint errors that overlap with flake8
llucax Aug 30, 2023
d5a43a6
Add `mypy` configuration to `pyproject.toml`
llucax Aug 29, 2023
0467495
Document *args and **kwargs properly
llucax Aug 24, 2023
86151ef
Remove documented exceptions that are not really raised
llucax Aug 24, 2023
de86e5f
Add missing returns documentation
llucax Aug 24, 2023
7aec399
Fix wrong order in documented arguments
llucax Aug 24, 2023
573669f
Make exception documentation more generic
llucax Aug 24, 2023
fb8b074
Add missing indirectly raised exceptions
llucax Aug 24, 2023
3a163a4
Fix wrong raises documentation
llucax Aug 24, 2023
fda7a76
Improve overloads for quantity scaling by Percentage
llucax Aug 24, 2023
2f17593
Add ignore rules and document indirectly raised exceptions
llucax Aug 24, 2023
05ab761
Fix typing of Self
llucax Aug 30, 2023
a28d0c4
Replace `not x in y` with `x not in y`
llucax Aug 30, 2023
939e5d0
Import (Async)Iterator directly
llucax Aug 30, 2023
75e1a28
Add missing `Self` import
llucax Aug 30, 2023
7626774
Remove type specifications from docstrings
llucax Aug 30, 2023
232ebe2
Remove inexistent arguments from docstrings
llucax Aug 30, 2023
4eb29c3
Add missing arguments to docstrings
llucax Aug 30, 2023
3a1ea06
Fix wrong arguments in docstrings
llucax Aug 30, 2023
9bb63b3
Add missing Returns and Raises to docstrings
llucax Aug 30, 2023
b1aa010
Ignore indirect raises in Raises specification
llucax Aug 30, 2023
b57b2ac
Add missing ending full stop to docstrings.
llucax Aug 30, 2023
d16d434
Don't leave an empty line between docstrings and code
llucax Aug 30, 2023
ccc1bee
Fit one-line docstrings in one line.
llucax Aug 30, 2023
110a3a1
Add missing docstrings
llucax Aug 30, 2023
6aa39e5
Use imperative for function docstring
llucax Aug 30, 2023
902446a
Remove empty file
llucax Aug 30, 2023
a67ad55
Rephrase comment to make the summary fit in one line
llucax Aug 30, 2023
a792ba5
Use `_` symbol for unused variable
llucax Aug 30, 2023
8ee926d
Shorten long lines
llucax Aug 30, 2023
66f05e8
Use only one `#` for comments
llucax Aug 30, 2023
40a6ed6
Remove unused import
llucax Aug 30, 2023
a2c85ad
Convert lamda to a function
llucax Aug 30, 2023
1f996a1
Remove unused variable
llucax Aug 30, 2023
3792906
Ignore unused import error
llucax Aug 30, 2023
a6aae23
Make sure that the returned grid is not None
llucax Aug 30, 2023
0aa3c8a
Bump dependency for repo-config to v0.6.1
llucax Aug 29, 2023
5e879be
Use a consistent format for comments for `noqa: DOC502`
llucax Sep 4, 2023
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
21 changes: 19 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
time: "07:00"
labels:
- "part:tooling"
Expand All @@ -13,11 +13,28 @@ updates:
versioning-strategy: auto
# Allow up to 10 open pull requests for updates to dependency versions
open-pull-requests-limit: 10
# We group production and development ("optional" in the context of
# pyproject.toml) dependency updates when they are patch and minor updates,
# so we end up with less PRs being generated.
# Major updates are still managed, but they'll create one PR per
# dependency, as major updates are expected to be breaking, it is better to
# manage them individually.
groups:
required:
dependency-type: "production"
update-types:
- "minor"
- "patch"
optional:
dependency-type: "development"
update-types:
- "minor"
- "patch"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
time: "06:00"
labels:
- "part:tooling"
Expand Down
31 changes: 28 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@ jobs:
- ubuntu-20.04
python:
- "3.11"
nox-session:
# To speed things up a bit we use the special ci_checks_max session
# that uses the same venv to run multiple linting sessions
- "ci_checks_max"
- "pytest_min"
runs-on: ${{ matrix.os }}

steps:
- name: Print environment (debug)
run: env

- name: Fetch sources
uses: actions/checkout@v3
with:
Expand All @@ -50,11 +58,25 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev-noxfile]
pip freeze

- name: Create nox venv
env:
NOX_SESSION: ${{ matrix.nox-session }}
run: nox --install-only -e "$NOX_SESSION"

- name: Print pip freeze for nox venv (debug)
env:
NOX_SESSION: ${{ matrix.nox-session }}
run: |
. ".nox/$NOX_SESSION/bin/activate"
pip freeze
deactivate

- name: Run nox
# To speed things up a bit we use the special ci_checks_max session
# that uses the same venv to run multiple linting sessions
run: nox -e ci_checks_max pytest_min
env:
NOX_SESSION: ${{ matrix.nox-session }}
run: nox -R -e "$NOX_SESSION"
timeout-minutes: 10

build:
Expand All @@ -76,6 +98,7 @@ jobs:
run: |
python -m pip install -U pip
python -m pip install -U build
pip freeze

- name: Build the source and binary distribution
run: python -m build
Expand Down Expand Up @@ -135,6 +158,7 @@ jobs:
run: |
python -m pip install -U pip
python -m pip install .[dev-mkdocs]
pip freeze

- name: Generate the documentation
env:
Expand Down Expand Up @@ -217,6 +241,7 @@ jobs:
run: |
python -m pip install -U pip
python -m pip install .[dev-mkdocs]
pip freeze

- name: Fetch the gh-pages branch
if: steps.mike-metadata.outputs.version
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
exclude .cookiecutter-replay.json
exclude .darglint
exclude .editorconfig
exclude .gitignore
exclude CODEOWNERS
Expand Down
1 change: 0 additions & 1 deletion benchmarks/power_distribution/power_distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ async def send_requests(batteries: Set[int], request_num: int) -> List[Result]:
"""Send requests to the PowerDistributingActor and wait for the response.

Args:
user: user that should send request
batteries: set of batteries where the power should be set
request_num: number of requests that should be send

Expand Down
3 changes: 1 addition & 2 deletions benchmarks/timeseries/benchmark_ringbuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def test_days(days: int, buffer: OrderedRingBuffer[Any]) -> None:
basetime = datetime(2022, 1, 1, tzinfo=timezone.utc)

for day in range(days):
# pylint: disable=unused-variable
minutes = buffer.window(
_ = buffer.window(
basetime + timedelta(days=day), basetime + timedelta(days=day + 1)
)

Expand Down
6 changes: 3 additions & 3 deletions benchmarks/timeseries/periodic_feature_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def _calculate_avg_window(
feature_extractor: The instance of the PeriodicFeatureExtractor to use.
window: The window to calculate the average over.
window_size: The size of the window to calculate the average over.
weights: The weights to use for the average calculation.

Returns:
The averaged window.
Expand Down Expand Up @@ -113,6 +112,7 @@ def _num_windows(
Args:
window: The buffer that is used for the average calculation.
window_size: The size of the window in samples.
period: The distance between two succeeding intervals in samples.

Returns:
The number of windows that are fully contained in the MovingWindow.
Expand Down Expand Up @@ -168,7 +168,7 @@ def run_avg_np(
The return value is discarded such that it can be used by timit.

Args:
a: The array containing all data.
array: The array containing all data.
window_size: The size of the window.
feature_extractor: An instance of the PeriodicFeatureExtractor.
"""
Expand All @@ -185,7 +185,7 @@ def run_avg_py(
The return value is discarded such that it can be used by timit.

Args:
a: The array containing all data.
array: The array containing all data.
window_size: The size of the window.
feature_extractor: An instance of the PeriodicFeatureExtractor.
"""
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/timeseries/ringbuffer_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def benchmark_serialization(
Args:
ringbuffer: Ringbuffer to benchmark to serialize.
iterations: amount of iterations to run.

Returns:
Average time to dump and load the ringbuffer.
"""
total = 0.0
for _ in range(iterations):
Expand Down
50 changes: 39 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
requires = [
"setuptools == 68.1.0",
"setuptools_scm[toml] == 7.1.0",
"frequenz-repo-config[lib] == 0.5.2",
"frequenz-repo-config[lib] == 0.6.1",
]
build-backend = "setuptools.build_meta"

Expand Down Expand Up @@ -49,10 +49,12 @@ name = "Frequenz Energy-as-a-Service GmbH"
email = "[email protected]"

[project.optional-dependencies]
dev-docstrings = [
dev-flake8 = [
"flake8 == 6.1.0",
"flake8-docstrings == 1.7.0",
"flake8-pyproject == 1.2.3", # For reading the flake8 config from pyproject.toml
"pydoclint == 0.3.1",
"pydocstyle == 6.3.0",
"darglint == 1.8.1",
"tomli == 2.0.1", # Needed by pydocstyle to read pyproject.toml
]
dev-examples = ["polars == 0.18.15"]
dev-formatting = ["black == 23.7.0", "isort == 5.12.0"]
Expand All @@ -63,35 +65,40 @@ dev-mkdocs = [
"mkdocs-material == 9.2.5",
"mkdocs-section-index == 0.3.5",
"mkdocstrings[python] == 0.22.0",
"frequenz-repo-config[lib] == 0.5.2",
"frequenz-repo-config[lib] == 0.6.1",
]
dev-mypy = [
"mypy == 1.5.1",
"grpc-stubs == 1.24.12", # This dependency introduces breaking changes in patch releases
"grpc-stubs == 1.24.12", # This dependency introduces breaking changes in patch releases
"types-Markdown == 3.4.2.10",
"types-PyYAML == 6.0.12.11",
"types-Pygments == 2.16.0.0",
"types-colorama == 0.4.15.12",
"types-protobuf == 4.24.0.1",
"types-python-dateutil == 2.8.19.14",
"types-pytz == 2023.3.0.1",
"types-setuptools == 68.1.0.0",
# For checking the noxfile, docs/ script, and tests
"frequenz-sdk[dev-mkdocs,dev-noxfile,dev-pytest]",
]
dev-noxfile = ["nox == 2023.4.22", "frequenz-repo-config[lib] == 0.5.2"]
dev-noxfile = ["nox == 2023.4.22", "frequenz-repo-config[lib] == 0.6.1"]
dev-pylint = [
"pylint == 2.17.5",
# For checking the noxfile, docs/ script, and tests
"frequenz-sdk[dev-mkdocs,dev-noxfile,dev-pytest]",
]
dev-pytest = [
"pytest == 7.4.0",
"frequenz-repo-config[extra-lint-examples] == 0.5.2",
"frequenz-repo-config[extra-lint-examples] == 0.6.1",
"pytest-mock == 3.11.1",
"pytest-asyncio == 0.21.1",
"time-machine == 2.12.0",
"async-solipsism == 0.5",
# For checking docstring code examples
"sybil == 5.0.3",
"pylint == 2.17.5",
"frequenz-sdk[dev-examples]",
]
dev = [
"frequenz-sdk[dev-mkdocs,dev-docstrings,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
"frequenz-sdk[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
]

[project.urls]
Expand All @@ -110,6 +117,23 @@ profile = "black"
line_length = 88
src_paths = ["benchmarks", "examples", "src", "tests"]

[tool.flake8]
# We give some flexibility to go over 88, there are cases like long URLs or
# code in documenation that have extra indentation. Black will still take care
# of making everything that can be 88 wide, 88 wide.
max-line-length = 100
extend-ignore = [
"E203", # Whitespace before ':' (conflicts with black)
"W503", # Line break before binary operator (conflicts with black)
]
# pydoclint options
style = "google"
allow-init-docstring = true
arg-type-hints-in-docstring = false
arg-type-hints-in-signature = true
check-return-types = false
check-yield-types = false

[tool.pylint.similarities]
ignore-comments = ['yes']
ignore-docstrings = ['yes']
Expand All @@ -125,6 +149,10 @@ disable = [
# pylint's unsubscriptable check is buggy and is not needed because
# it is a type-check, for which we already have mypy.
"unsubscriptable-object",
# Checked by flake8
"line-too-long",
"unused-variable",
"unnecessary-lambda-assignment",
]

[tool.pylint.design]
Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/sdk/actor/_run_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def run(*actors: Actor) -> None:
"""Await the completion of all actors.

Args:
actors: the actors to be awaited.
*actors: the actors to be awaited.
"""
_logger.info("Starting %s actor(s)...", len(actors))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class BatteryPoolStatus:
Send set of working and uncertain batteries, when the any battery change status.
"""

def __init__(
def __init__( # noqa: DOC502 (RuntimeError is raised indirectly by BatteryStatus)
self,
battery_ids: Set[int],
battery_status_sender: Sender[BatteryStatus],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ async def _send_result(self, namespace: str, result: Result) -> None:
namespace: namespace of the sender, to identify the result channel with.
result: Result to send out.
"""
if not namespace in self._result_senders:
if namespace not in self._result_senders:
self._result_senders[namespace] = self._channel_registry.new_sender(
namespace
)
Expand Down
2 changes: 1 addition & 1 deletion src/frequenz/sdk/microgrid/_data_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
DataSourcingActor,
ResamplerConfig,
)
from ..actor.power_distributing import (
from ..actor.power_distributing import ( # noqa: F401 (imports used by string type hints)
BatteryStatus,
PowerDistributingActor,
Request,
Expand Down
17 changes: 8 additions & 9 deletions src/frequenz/sdk/microgrid/client/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,6 @@ async def _component_data_task(
transform: A method for transforming raw component data into the
desired output type.
sender: A channel sender, to send the component data to.

Raises:
AioRpcError: if connection to Microgrid API cannot be established
"""
retry_spec: RetryStrategy = self._retry_spec.copy()
while True:
Expand Down Expand Up @@ -446,7 +443,7 @@ async def _expect_category(
f", not a {expected_category}."
)

async def meter_data(
async def meter_data( # noqa: DOC502 (ValueError is raised indirectly by _expect_category)
self,
component_id: int,
maxsize: int = RECEIVER_MAX_SIZE,
Expand Down Expand Up @@ -476,7 +473,7 @@ async def meter_data(
MeterData.from_proto,
).new_receiver(maxsize=maxsize)

async def battery_data(
async def battery_data( # noqa: DOC502 (ValueError is raised indirectly by _expect_category)
self,
component_id: int,
maxsize: int = RECEIVER_MAX_SIZE,
Expand Down Expand Up @@ -506,7 +503,7 @@ async def battery_data(
BatteryData.from_proto,
).new_receiver(maxsize=maxsize)

async def inverter_data(
async def inverter_data( # noqa: DOC502 (ValueError is raised indirectly by _expect_category)
self,
component_id: int,
maxsize: int = RECEIVER_MAX_SIZE,
Expand Down Expand Up @@ -536,7 +533,7 @@ async def inverter_data(
InverterData.from_proto,
).new_receiver(maxsize=maxsize)

async def ev_charger_data(
async def ev_charger_data( # noqa: DOC502 (ValueError is raised indirectly by _expect_category)
self,
component_id: int,
maxsize: int = RECEIVER_MAX_SIZE,
Expand Down Expand Up @@ -624,12 +621,14 @@ async def set_bounds(
if lower > 0:
raise ValueError(f"Lower bound {upper} must be less than or equal to 0.")

target_metric = (
microgrid_pb.SetBoundsParam.TargetMetric.TARGET_METRIC_POWER_ACTIVE
)
try:
self.api.AddInclusionBounds(
microgrid_pb.SetBoundsParam(
component_id=component_id,
# pylint: disable=no-member,line-too-long
target_metric=microgrid_pb.SetBoundsParam.TargetMetric.TARGET_METRIC_POWER_ACTIVE,
target_metric=target_metric,
bounds=metrics_pb.Bounds(lower=lower, upper=upper),
),
)
Expand Down
3 changes: 3 additions & 0 deletions src/frequenz/sdk/microgrid/component/_component_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> ComponentData:

Args:
raw: raw component data as decoded from the wire.

Returns:
The instance created from the protobuf message.
"""


Expand Down
Loading