-
Notifications
You must be signed in to change notification settings - Fork 6
Improve README.md for Better Project Discoverability #176
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
base: v0.x.x
Are you sure you want to change the base?
Changes from 5 commits
12a5d3d
aa6f5a2
523d951
c873fce
a34762c
ae4ff45
0bcd222
3c82cbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,85 @@ | |
|
||
## Introduction | ||
|
||
A highlevel interface for the dispatch API. | ||
The `frequenz-dispatch` library provides a high-level Python interface for | ||
interacting with the Frequenz Dispatch API. This library enables you to | ||
manage and monitor dispatch operations in microgrids, including lifecycle | ||
events and running status changes of dispatch operations. | ||
|
||
See [the documentation](https://frequenz-floss.github.io/frequenz-dispatch-python/v0.1/reference/frequenz/dispatch) for more information. | ||
The main entry point is the [`Dispatcher`][dispatcher-class] class, which | ||
provides channels for receiving dispatch lifecycle events and running status | ||
updates, allowing you to build reactive applications that respond to dispatch | ||
state changes. | ||
|
||
## Usage | ||
## Supported Platforms | ||
|
||
The following platforms are officially supported (tested): | ||
|
||
- **Python:** 3.11 | ||
- **Operating System:** Ubuntu Linux 20.04 | ||
- **Architectures:** amd64, arm64 | ||
|
||
## Installation | ||
|
||
### Using pip | ||
|
||
The [`Dispatcher` class](https://frequenz-floss.github.io/frequenz-dispatch-python/v0.1/reference/frequenz/dispatch/#frequenz.dispatch.Dispatcher), the main entry point for the API, provides two channels: | ||
You can install the package from PyPI: | ||
|
||
* [Lifecycle events](https://frequenz-floss.github.io/frequenz-dispatch-python/v0.1/reference/frequenz/dispatch/#frequenz.dispatch.Dispatcher.lifecycle_events): A channel that sends a message whenever a [Dispatch][frequenz.dispatch.Dispatch] is created, updated or deleted. | ||
* [Running status change](https://frequenz-floss.github.io/frequenz-dispatch-python/v0.1/reference/frequenz/dispatch/#frequenz.dispatch.Dispatcher.running_status_change): Sends a dispatch message whenever a dispatch is ready to be executed according to the schedule or the running status of the dispatch changed in a way that could potentially require the actor to start, stop or reconfigure itself. | ||
```bash | ||
python3 -m pip install frequenz-dispatch | ||
``` | ||
|
||
### Using pyproject.toml | ||
|
||
Add the dependency to your `pyproject.toml` file: | ||
|
||
```toml | ||
[project] | ||
dependencies = [ | ||
"frequenz-dispatch >= 0.10.1, < 0.11", | ||
] | ||
``` | ||
|
||
> [!NOTE] | ||
> We recommend pinning the dependency to the latest version for programs, | ||
> like `"frequenz-dispatch == 0.10.1"`, and specifying a version range | ||
> spanning one major version for libraries, like | ||
> `"frequenz-dispatch >= 0.10.1, < 0.11"`. We follow [semver](https://semver.org/). | ||
|
||
## Quick Start | ||
|
||
The `frequenz-dispatch` library provides a high-level interface to interact | ||
|
||
with the dispatch API. Here's a minimal example to get you started: | ||
|
||
```python | ||
import os | ||
from frequenz.dispatch import Dispatcher | ||
|
||
async def main(): | ||
# Configure connection to dispatch API | ||
url = os.getenv("DISPATCH_API_URL", "grpc://your-dispatch-url.com") | ||
key = os.getenv("DISPATCH_API_KEY", "your-api-key") | ||
microgrid_id = 1 | ||
|
||
# Create and use the dispatcher | ||
async with Dispatcher( | ||
microgrid_id=microgrid_id, | ||
server_url=url, | ||
key=key, | ||
) as dispatcher: | ||
# Your dispatch logic here | ||
print("Dispatcher ready!") | ||
``` | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also repeated.. though I am not sure if that is a problem or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (the main entry part) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the redundant "main entry point" reference from line 78. Commit: 0bcd222 |
||
The [`Dispatcher` class][dispatcher-class], the main entry point for the API, | ||
provides two channels: | ||
|
||
* [Lifecycle events][lifecycle-events]: A channel that sends a message whenever | ||
a [Dispatch][frequenz.dispatch.Dispatch] is created, updated or deleted. | ||
* [Running status change][running-status-change]: Sends a dispatch message | ||
whenever a dispatch is ready to be executed according to the schedule or the | ||
running status of the dispatch changed in a way that could potentially | ||
require the actor to start, stop or reconfigure itself. | ||
|
||
### Example using the running status change channel | ||
|
||
|
||
|
@@ -26,12 +95,16 @@ from datetime import timedelta | |
|
||
from frequenz.dispatch import Dispatcher, DispatchInfo, MergeByType | ||
|
||
async def create_actor(dispatch: DispatchInfo, receiver: Receiver[DispatchInfo]) -> Actor: | ||
async def create_actor( | ||
dispatch: DispatchInfo, receiver: Receiver[DispatchInfo] | ||
) -> Actor: | ||
return MagicMock(dispatch=dispatch, receiver=receiver) | ||
|
||
async def run(): | ||
url = os.getenv("DISPATCH_API_URL", "grpc://dispatch.url.goes.here.example.com") | ||
key = os.getenv("DISPATCH_API_KEY", "some-key") | ||
url = os.getenv( | ||
"DISPATCH_API_URL", "grpc://dispatch.url.goes.here.example.com" | ||
) | ||
key = os.getenv("DISPATCH_API_KEY", "some-key") | ||
llucax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
microgrid_id = 1 | ||
|
||
|
@@ -50,13 +123,14 @@ async def run(): | |
await dispatcher | ||
``` | ||
|
||
## Supported Platforms | ||
[dispatcher-class]: https://frequenz-floss.github.io/frequenz-dispatch-python/latest/reference/frequenz/dispatch/#frequenz.dispatch.Dispatcher | ||
[lifecycle-events]: https://frequenz-floss.github.io/frequenz-dispatch-python/latest/reference/frequenz/dispatch/#frequenz.dispatch.Dispatcher.lifecycle_events | ||
[running-status-change]: https://frequenz-floss.github.io/frequenz-dispatch-python/latest/reference/frequenz/dispatch/#frequenz.dispatch.Dispatcher.running_status_change | ||
|
||
The following platforms are officially supported (tested): | ||
## Documentation | ||
|
||
- **Python:** 3.11 | ||
- **Operating System:** Ubuntu Linux 20.04 | ||
- **Architectures:** amd64, arm64 | ||
For complete API documentation, examples, and advanced usage patterns, see | ||
llucax marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
[the documentation](https://frequenz-floss.github.io/frequenz-dispatch-python/latest/reference/frequenz/dispatch). | ||
|
||
## Contributing | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're testjing against 24.04 now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to Ubuntu Linux 24.04. Commit: 74e2bb1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I saw this one, but all projects are the same so I thought maybe we leave it for another mass update, but maybe we can also just add it to the issue as something to do 👍
Interesting that your review also triggers a copilot session, even if you didn't assign copilot to the PR yourself. It is a bit annoying, maybe if we unassign copilot it stops doing that.