-
Notifications
You must be signed in to change notification settings - Fork 5
Initial client #7
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
Closed
flora-hofmann-frequenz
wants to merge
1
commit into
frequenz-floss:v0.x.x
from
flora-hofmann-frequenz:initial_client
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# License: MIT | ||
# Copyright © 2025 Frequenz Energy-as-a-Service GmbH | ||
|
||
"""Examples usage of PlatformAssets API.""" | ||
|
||
import argparse | ||
import asyncio | ||
from pprint import pprint | ||
|
||
from frequenz.client.assets._client import AssetsApiClient | ||
|
||
|
||
async def main( | ||
microgrid_id: int, | ||
component_ids: list[int], | ||
categories: list[int] | None, | ||
source_component_ids: list[int] | None, | ||
destination_component_ids: list[int] | None, | ||
) -> None: | ||
"""Test the AssetsApiClient. | ||
|
||
Args: | ||
microgrid_id: The ID of the microgrid to query. | ||
component_ids: List of component IDs to filter. | ||
categories: List of component categories to filter. | ||
source_component_ids: List of source component IDs to filter. | ||
destination_component_ids: List of destination component IDs to filter. | ||
""" | ||
server_url = "localhost:50052" | ||
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. Should be a command line argument. |
||
client = AssetsApiClient(server_url) | ||
|
||
print("########################################################") | ||
print("Fetching microgrid details") | ||
|
||
microgrid_details = await client.get_microgrid_details(microgrid_id) | ||
pprint(microgrid_details) | ||
|
||
print("########################################################") | ||
print("Listing microgrid components") | ||
|
||
components = await client.list_microgrid_component_connections( | ||
microgrid_id, component_ids, categories | ||
) | ||
pprint(components) | ||
|
||
print("########################################################") | ||
print("Listing microgrid component connections") | ||
|
||
connections = await client.list_microgrid_component_connections( | ||
microgrid_id, source_component_ids, destination_component_ids | ||
) | ||
pprint(connections) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("microgrid_id", type=int, help="Microgrid ID") | ||
parser.add_argument( | ||
"component_ids", nargs="*", type=int, help="List of component IDs to filter" | ||
) | ||
parser.add_argument( | ||
"categories", nargs="*", type=str, help="List of component categories to filter" | ||
) | ||
parser.add_argument( | ||
"source_component_ids", | ||
nargs="*", | ||
type=int, | ||
help="List of source component IDs to filter", | ||
) | ||
parser.add_argument( | ||
"destination_component_ids", | ||
nargs="*", | ||
type=int, | ||
help="List of destination component IDs to filter", | ||
) | ||
|
||
args = parser.parse_args() | ||
asyncio.run( | ||
main( | ||
args.microgrid_id, | ||
args.component_ids, | ||
args.categories, | ||
args.source_component_ids, | ||
args.destination_component_ids, | ||
) | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,9 @@ classifiers = [ | |
requires-python = ">= 3.11, < 4" | ||
dependencies = [ | ||
"typing-extensions >= 4.12.2, < 5", | ||
"frequenz-api-assets @ git+https://github.com/frequenz-floss/[email protected]", | ||
"frequenz-client-common >= 0.3.0, < 1", | ||
"frequenz-client-base >= 0.11.0, < 1", | ||
] | ||
dynamic = ["version"] | ||
|
||
|
@@ -82,6 +85,10 @@ dev = [ | |
"frequenz-client-assets[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]", | ||
] | ||
|
||
examples = [ | ||
"grpcio >= 1.51.1, < 2", | ||
] | ||
|
||
[project.urls] | ||
Documentation = "https://frequenz-floss.github.io/frequenz-client-assets-python/" | ||
Changelog = "https://github.com/frequenz-floss/frequenz-client-assets-python/releases" | ||
|
@@ -146,7 +153,15 @@ disable = [ | |
] | ||
|
||
[tool.pytest.ini_options] | ||
addopts = "-W=all -Werror -Wdefault::DeprecationWarning -Wdefault::PendingDeprecationWarning -vv" | ||
addopts = "-vv" | ||
filterwarnings = [ | ||
"error", | ||
"once::DeprecationWarning", | ||
"once::PendingDeprecationWarning", | ||
# We use a raw string (single quote) to avoid the need to escape special | ||
# chars as this is a regex | ||
'ignore:Protobuf gencode version .*exactly one major version older.*:UserWarning', | ||
] | ||
testpaths = ["tests", "src"] | ||
asyncio_mode = "auto" | ||
asyncio_default_fixture_loop_scope = "function" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would be better implemented as a CLI tool similar to the reporting client.
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.
Actually more like the CLI tool in trading, which provides an example for different endpoints.