-
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 2 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 |
|---|---|---|
|
|
@@ -8,14 +8,52 @@ | |
|
|
||
| A highlevel interface for the dispatch API. | ||
|
|
||
| See [the documentation](https://frequenz-floss.github.io/frequenz-dispatch-python/v0.1/reference/frequenz/dispatch) for more information. | ||
| See [the documentation](https://frequenz-floss.github.io/frequenz-dispatch-python/v0.1/reference/frequenz/dispatch) | ||
| for more information. | ||
|
|
||
| ## 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 datetime import timedelta | ||
| 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 |
||
| For complete examples and advanced usage, see the [Usage](#usage) section below. | ||
|
|
||
| ## Usage | ||
|
|
||
| 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: | ||
| The [`Dispatcher` class][dispatcher-class], the main entry point for the API, | ||
| provides two channels: | ||
|
|
||
| * [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. | ||
| * [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. | ||
|
|
||
| [dispatcher-class]: https://frequenz-floss.github.io/frequenz-dispatch-python/v0.1/reference/frequenz/dispatch/#frequenz.dispatch.Dispatcher | ||
| [lifecycle-events]: https://frequenz-floss.github.io/frequenz-dispatch-python/v0.1/reference/frequenz/dispatch/#frequenz.dispatch.Dispatcher.lifecycle_events | ||
| [running-status-change]: https://frequenz-floss.github.io/frequenz-dispatch-python/v0.1/reference/frequenz/dispatch/#frequenz.dispatch.Dispatcher.running_status_change | ||
|
|
||
| ### Example using the running status change channel | ||
|
||
|
|
||
|
|
@@ -26,11 +64,15 @@ 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") | ||
| 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.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| microgrid_id = 1 | ||
|
|
@@ -58,6 +100,33 @@ The following platforms are officially supported (tested): | |
| - **Operating System:** Ubuntu Linux 20.04 | ||
| - **Architectures:** amd64, arm64 | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Using pip | ||
|
|
||
| You can install the package from PyPI: | ||
|
|
||
| ```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/). | ||
|
|
||
| ## Contributing | ||
|
|
||
| If you want to know how to build this project and contribute to it, please | ||
|
|
||
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.
This sentence is repeated, first appearing above
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.
Removed the redundant description sentence from the Quick Start section. Commit: 74e2bb1