reporting
frequenz.client.reporting ¤
Client to connect to the Reporting API.
This package provides a low-level interface for interacting with the reporting API.
Classes¤
frequenz.client.reporting.ReportingApiClient ¤
Bases: BaseApiClient[ReportingStub]
A client for the Reporting service.
Source code in frequenz/client/reporting/_client.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
|
Attributes¤
channel
property
¤
The underlying gRPC channel used to communicate with the server.
Warning
This channel is provided as a last resort for advanced users. It is not recommended to use this property directly unless you know what you are doing and you don't care about being tied to a specific gRPC library.
RAISES | DESCRIPTION |
---|---|
ClientNotConnected
|
If the client is not connected to the server. |
channel_defaults
property
¤
The default options for the gRPC channel.
Functions¤
__aexit__
async
¤
__aexit__(
_exc_type: type[BaseException] | None,
_exc_val: BaseException | None,
_exc_tb: Any | None,
) -> bool | None
Exit a context manager.
Source code in frequenz/client/base/client.py
__init__ ¤
__init__(
server_url: str,
*,
auth_key: str | None = None,
sign_secret: str | None = None,
connect: bool = True,
channel_defaults: ChannelOptions = ChannelOptions()
) -> None
Create a new Reporting client.
PARAMETER | DESCRIPTION |
---|---|
server_url
|
The URL of the Reporting service.
TYPE:
|
auth_key
|
The API key for the authorization.
TYPE:
|
sign_secret
|
The secret to use for HMAC signing the message
TYPE:
|
connect
|
Whether to connect to the server immediately.
TYPE:
|
channel_defaults
|
The default channel options.
TYPE:
|
Source code in frequenz/client/reporting/_client.py
connect ¤
connect(
server_url: str | None = None,
*,
auth_key: str | None | EllipsisType = ...,
sign_secret: str | None | EllipsisType = ...
) -> None
Connect to the server, possibly using a new URL.
If the client is already connected and the URL is the same as the previous URL, this method does nothing. If you want to force a reconnection, you can call disconnect() first.
PARAMETER | DESCRIPTION |
---|---|
server_url
|
The URL of the server to connect to. If not provided, the previously used URL is used.
TYPE:
|
auth_key
|
The API key to use when connecting to the service. If an Ellipsis is provided, the previously used auth_key is used.
TYPE:
|
sign_secret
|
The secret to use when creating message HMAC. If an Ellipsis is provided,
TYPE:
|
Source code in frequenz/client/base/client.py
disconnect
async
¤
Disconnect from the server.
If the client is not connected, this method does nothing.
receive_aggregated_data ¤
receive_aggregated_data(
*,
microgrid_id: int,
metric: Metric,
aggregation_formula: str,
start_time: datetime | None,
end_time: datetime | None,
resampling_period: timedelta
) -> Receiver[MetricSample]
Iterate over aggregated data for a single metric using GrpcStreamBroadcaster.
For now this only supports a single metric and aggregation formula. Args: microgrid_id: The microgrid ID. metric: The metric name. aggregation_formula: The aggregation formula. start_time: start datetime, if None, the earliest available data will be used end_time: end datetime, if None starts streaming indefinitely from start_time resampling_period: The period for resampling the data.
RETURNS | DESCRIPTION |
---|---|
Receiver[MetricSample]
|
A receiver of |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the resampling_period is not provided. |
Source code in frequenz/client/reporting/_client.py
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
|
receive_microgrid_components_data ¤
receive_microgrid_components_data(
*,
microgrid_components: list[tuple[int, list[int]]],
metrics: Metric | list[Metric],
start_time: datetime | None,
end_time: datetime | None,
resampling_period: timedelta | None,
include_states: bool = False,
include_bounds: bool = False
) -> Receiver[MetricSample]
Iterate over the data for multiple microgrids and components.
PARAMETER | DESCRIPTION |
---|---|
microgrid_components
|
List of tuples where each tuple contains microgrid ID and corresponding component IDs. |
metrics
|
The metric name or list of metric names.
TYPE:
|
start_time
|
start datetime, if None, the earliest available data will be used
TYPE:
|
end_time
|
end datetime, if None starts streaming indefinitely from start_time
TYPE:
|
resampling_period
|
The period for resampling the data.
TYPE:
|
include_states
|
Whether to include the state data.
TYPE:
|
include_bounds
|
Whether to include the bound data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Receiver[MetricSample]
|
A receiver of |
Source code in frequenz/client/reporting/_client.py
receive_microgrid_sensors_data ¤
receive_microgrid_sensors_data(
*,
microgrid_sensors: list[tuple[int, list[int]]],
metrics: Metric | list[Metric],
start_time: datetime | None,
end_time: datetime | None,
resampling_period: timedelta | None,
include_states: bool = False
) -> Receiver[MetricSample]
Iterate over the data for multiple sensors in a microgrid.
PARAMETER | DESCRIPTION |
---|---|
microgrid_sensors
|
List of tuples where each tuple contains microgrid ID and corresponding sensor IDs. |
metrics
|
The metric name or list of metric names.
TYPE:
|
start_time
|
start datetime, if None, the earliest available data will be used.
TYPE:
|
end_time
|
end datetime, if None starts streaming indefinitely from start_time.
TYPE:
|
resampling_period
|
The period for resampling the data.
TYPE:
|
include_states
|
Whether to include the state data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Receiver[MetricSample]
|
A receiver of |
Source code in frequenz/client/reporting/_client.py
receive_single_component_data ¤
receive_single_component_data(
*,
microgrid_id: int,
component_id: int,
metrics: Metric | list[Metric],
start_time: datetime | None,
end_time: datetime | None,
resampling_period: timedelta | None,
include_states: bool = False,
include_bounds: bool = False
) -> Receiver[MetricSample]
Iterate over the data for a single metric.
PARAMETER | DESCRIPTION |
---|---|
microgrid_id
|
The microgrid ID.
TYPE:
|
component_id
|
The component ID.
TYPE:
|
metrics
|
The metric name or list of metric names.
TYPE:
|
start_time
|
start datetime, if None, the earliest available data will be used
TYPE:
|
end_time
|
end datetime, if None starts streaming indefinitely from start_time
TYPE:
|
resampling_period
|
The period for resampling the data.
TYPE:
|
include_states
|
Whether to include the state data.
TYPE:
|
include_bounds
|
Whether to include the bound data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Receiver[MetricSample]
|
A receiver of |
Source code in frequenz/client/reporting/_client.py
receive_single_sensor_data ¤
receive_single_sensor_data(
*,
microgrid_id: int,
sensor_id: int,
metrics: Metric | list[Metric],
start_time: datetime | None,
end_time: datetime | None,
resampling_period: timedelta | None,
include_states: bool = False
) -> Receiver[MetricSample]
Iterate over the data for a single sensor and metric.
PARAMETER | DESCRIPTION |
---|---|
microgrid_id
|
The microgrid ID.
TYPE:
|
sensor_id
|
The sensor ID.
TYPE:
|
metrics
|
The metric name or list of metric names.
TYPE:
|
start_time
|
start datetime, if None, the earliest available data will be used.
TYPE:
|
end_time
|
end datetime, if None starts streaming indefinitely from start_time.
TYPE:
|
resampling_period
|
The period for resampling the data.
TYPE:
|
include_states
|
Whether to include the state data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Receiver[MetricSample]
|
A receiver of |