Skip to content

Fix todos #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2024
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
4 changes: 2 additions & 2 deletions .cookiecutter-replay.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"license": "MIT",
"author_name": "Frequenz Energy-as-a-Service GmbH",
"author_email": "[email protected]",
"python_package": "frequenz.actor.dispatch",
"pypi_package_name": "frequenz-actor-dispatch",
"python_package": "frequenz.dispatch",
"pypi_package_name": "frequenz-dispatch",
"github_repo_name": "frequenz-dispatch-python",
"default_codeowners": "@frequenz-floss/api-dispatch-team",
"_template": "gh:frequenz-floss/frequenz-repo-config-python",
Expand Down
4 changes: 1 addition & 3 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ body:
- Documentation (part:docs)
- Unit, integration and performance tests (part:tests)
- Build script, CI, dependencies, etc. (part:tooling)
# TODO(cookiecutter): Add other parts
# Please have in mind that that the part:xxx labels need to
# be created in the GitHub repository.
- Actor (part:actor)
validations:
required: true
- type: textarea
Expand Down
4 changes: 1 addition & 3 deletions .github/keylabeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ labelMappings:
"part:tests": "part:tests"
"part:tooling": "part:tooling"
"part:❓": "part:❓"
# TODO(cookiecutter): Add other parts
# Please have in mind that that the part:xxx labels need to
# be created in the GitHub repository.
"part:actor": "part:actor"
5 changes: 5 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@
- CODEOWNERS
- MANIFEST.in
- noxfile.py

"part:actor":
- changed-files:
- any-glob-to-any-file:
- "src/frequenz/dispatch/actor/**"
22 changes: 11 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
submodules: true

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Cache container layers
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-nox-${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.python }}
Expand All @@ -158,7 +158,7 @@ jobs:

# Cache pip downloads
- name: Cache pip downloads
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/pip-cache
key: nox-${{ matrix.nox-session }}-${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.python }}-${{ hashFiles('**/pyproject.toml') }}
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
submodules: true

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
cache: 'pip'
Expand All @@ -232,7 +232,7 @@ jobs:
run: python -m build

- name: Upload distribution files
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist-packages
path: dist/
Expand All @@ -246,7 +246,7 @@ jobs:
- name: Fetch sources
uses: actions/checkout@v4
- name: Download package
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist-packages
path: dist
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:
uses: frequenz-floss/setup-git-user@v2

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
cache: 'pip'
Expand All @@ -296,7 +296,7 @@ jobs:
mike set-default $MIKE_VERSION

- name: Upload site
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: docs-site
path: site/
Expand All @@ -319,7 +319,7 @@ jobs:
uses: frequenz-floss/setup-git-user@v2

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
cache: 'pip'
Expand Down Expand Up @@ -386,7 +386,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Download distribution files
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist-packages
path: dist
Expand Down Expand Up @@ -432,7 +432,7 @@ jobs:
id-token: write
steps:
- name: Download distribution files
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist-packages
path: dist
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release-notes-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
if: github.event_name == 'pull_request'
uses: brettcannon/check-for-changed-files@4170644959a21843b31f1181f2a1761d65ef4791 # v1.2.0
with:
# TODO(cookiecutter): Uncomment the following line for private repositories, otherwise remove it and remove it
# token: ${{ secrets.github_token }}
file-pattern: "RELEASE_NOTES.md"
prereq-pattern: "src/**"
skip-label: "cmd:skip-release-notes"
Expand Down
1 change: 0 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
# Fallback owner.
# These are the default owners for everything in the repo, unless a later match
# takes precedence.
# TODO(cookiecutter): Add more specific code-owners, check if the default is correct
* @frequenz-floss/api-dispatch-team
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ These are the steps to create a new release:
a [GitHub
Release](https://github.com/frequenz-floss/frequenz-dispatch-python/releases),
and upload a new package to
[PyPI](https://pypi.org/project/frequenz-actor-dispatch/)
[PyPI](https://pypi.org/project/frequenz-dispatch/)
automatically.

6. Once this is done, reset the `RELEASE_NOTES.md` with the template:
Expand Down
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
# Dispatch Highlevel Interface

[![Build Status](https://github.com/frequenz-floss/frequenz-dispatch-python/actions/workflows/ci.yaml/badge.svg)](https://github.com/frequenz-floss/frequenz-dispatch-python/actions/workflows/ci.yaml)
[![PyPI Package](https://img.shields.io/pypi/v/frequenz-actor-dispatch)](https://pypi.org/project/frequenz-actor-dispatch/)
[![PyPI Package](https://img.shields.io/pypi/v/frequenz-dispatch)](https://pypi.org/project/frequenz-dispatch/)
[![Docs](https://img.shields.io/badge/docs-latest-informational)](https://frequenz-floss.github.io/frequenz-dispatch-python/)

## Introduction

A highlevel interface for the dispatch API

TODO(cookiecutter): Improve the README file
A highlevel interface for the dispatch API.
The interface is made of the dispatch actor which should run once per microgrid.
It provides two channels for clients:
- "new_dispatches" for newly created dispatches
- "ready_dispatches" for dispatches that are ready to be executed

## Example Usage

```python
async def run():
# dispatch helper sends out dispatches when they are due
dispatch_arrived = dispatch_helper.new_dispatches().new_receiver()
dispatch_ready = dispatch_helper.ready_dispatches().new_receiver()

async for selected in select(dispatch_ready, dispatch_arrived):
if selected_from(selected, dispatch_arrived):
dispatch = selected.value
match dispatch.type:
case DISPATCH_TYPE_BATTERY_CHARGE:
battery_pool = microgrid.battery_pool(dispatch.battery_set, task_id)
battery_pool.set_charge(dispatch.power)
...
if selected_from(selected, dispatch_ready):
dispatch = selected.value
log.info("New dispatch arrived %s", dispatch)
```

## Supported Platforms

Expand Down
2 changes: 0 additions & 2 deletions docs/_scripts/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,5 @@ def define_env(env: macros.MacrosPlugin) -> None:
# https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#adding-annotations
env.variables["code_annotation_marker"] = _CODE_ANNOTATION_MARKER

# TODO(cookiecutter): Add any other macros, variables and filters here.

# This hook needs to be done at the end of the `define_env` function.
_hook_macros_plugin(env)
8 changes: 2 additions & 6 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ site_author: "Frequenz Energy-as-a-Service GmbH"
copyright: "Copyright © 2024 Frequenz Energy-as-a-Service GmbH"
repo_name: "frequenz-dispatch-python"
repo_url: "https://github.com/frequenz-floss/frequenz-dispatch-python"
# TODO(cookiecutter): "main" is the GitHub repo default branch, you might want to update it
# if the project uses a different default branch.
edit_uri: "edit/main/docs/"
edit_uri: "edit/v0.x.x/docs/"
strict: true # Treat warnings as errors

# Build directories
theme:
name: "material"
# TODO(cookiecutter): You might want to change the logo, the file is located in "docs/"
logo: _img/logo.png
favicon: _img/logo.png
language: en
Expand Down Expand Up @@ -51,7 +48,6 @@ theme:
name: Switch to light mode

extra:
# TODO(cookiecutter): You probably want to update the social links
social:
- icon: fontawesome/brands/github
link: https://github.com/frequenz-floss
Expand Down Expand Up @@ -116,12 +112,12 @@ plugins:
show_source: true
signature_crossrefs: true
import:
# TODO(cookiecutter): You might want to add other external references here
# See https://mkdocstrings.github.io/python/usage/#import for details
- https://docs.python.org/3/objects.inv
- https://frequenz-floss.github.io/frequenz-channels-python/v0.16/objects.inv
- https://frequenz-floss.github.io/frequenz-sdk-python/v0.25/objects.inv
Copy link
Contributor

Choose a reason for hiding this comment

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

Side note: Oh, dammit, we need to depend on the SDK for the actor, but the SDK will depend on the actor too eventually, we need to address frequenz-floss/frequenz-sdk-python#851 sooner than I expected.

- https://typing-extensions.readthedocs.io/en/stable/objects.inv
- https://frequenz-floss.github.io/frequenz-client-dispatch-python/v0.1/objects.inv
# Note this plugin must be loaded after mkdocstrings to be able to use macros
# inside docstrings. See the comment in `docs/_scripts/macros.py` for more
# details
Expand Down
24 changes: 12 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
requires = [
"setuptools == 68.1.0",
"setuptools_scm[toml] == 7.1.0",
"frequenz-repo-config[actor] == 0.8.0",
"frequenz-repo-config[lib] == 0.9.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

You could bump directly to v0.9.1 here, but dependabot will take care of it if you don't.

]
build-backend = "setuptools.build_meta"

[project]
name = "frequenz-actor-dispatch"
name = "frequenz-dispatch"
description = "A highlevel interface for the dispatch API"
readme = "README.md"
license = { text = "MIT" }
Expand Down Expand Up @@ -43,48 +43,48 @@ email = "[email protected]"
# TODO(cookiecutter): Remove and add more optional dependencies if appropriate
[project.optional-dependencies]
dev-flake8 = [
"flake8 == 6.1.0",
"flake8 == 7.0.0",
"flake8-docstrings == 1.7.0",
"flake8-pyproject == 1.2.3", # For reading the flake8 config from pyproject.toml
"pydoclint == 0.3.2",
"pydocstyle == 6.3.0",
]
dev-formatting = ["black == 23.9.1", "isort == 5.12.0"]
dev-formatting = ["black == 24.2.0", "isort == 5.12.0"]
dev-mkdocs = [
"black == 23.9.1",
"black == 24.2.0",
"Markdown==3.4.4",
"mike == 2.0.0",
"mkdocs-gen-files == 0.5.0",
"mkdocs-literate-nav == 0.6.1",
"mkdocs-macros-plugin == 1.0.4",
"mkdocs-material == 9.3.1",
"mkdocstrings[python] == 0.23.0",
"frequenz-repo-config[actor] == 0.8.0",
"frequenz-repo-config[lib] == 0.9.0",
]
dev-mypy = [
"mypy == 1.5.1",
"types-Markdown == 3.4.2.10",
# For checking the noxfile, docs/ script, and tests
"frequenz-actor-dispatch[dev-mkdocs,dev-noxfile,dev-pytest]",
"frequenz-dispatch[dev-mkdocs,dev-noxfile,dev-pytest]",
]
dev-noxfile = [
"nox == 2023.4.22",
"frequenz-repo-config[actor] == 0.8.0",
"frequenz-repo-config[lib] == 0.9.0",
]
dev-pylint = [
"pylint == 3.0.2",
# For checking the noxfile, docs/ script, and tests
"frequenz-actor-dispatch[dev-mkdocs,dev-noxfile,dev-pytest]",
"frequenz-dispatch[dev-mkdocs,dev-noxfile,dev-pytest]",
]
dev-pytest = [
"pytest == 8.0.0",
"frequenz-repo-config[extra-lint-examples] == 0.8.0",
"frequenz-repo-config[extra-lint-examples] == 0.9.0",
"pytest-mock == 3.11.1",
"pytest-asyncio == 0.21.1",
"async-solipsism == 0.5",
]
dev = [
"frequenz-actor-dispatch[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
"frequenz-dispatch[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
]

[project.urls]
Expand Down Expand Up @@ -163,7 +163,7 @@ packages = ["frequenz.actor.dispatch"]
strict = true

[[tool.mypy.overrides]]
module = ["mkdocs_macros.*", "sybil", "sybil.*"]
module = ["mkdocs_macros.*"]
ignore_missing_imports = true

[tool.setuptools_scm]
Expand Down