frequenz-client-reporting


Namefrequenz-client-reporting JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryReporting API client for Python
upload_time2024-05-14 16:06:31
maintainerNone
docs_urlNone
authorNone
requires_python<4,>=3.11
licenseMIT
keywords frequenz python lib library client-reporting client reporting api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Frequenz Reporting API Client

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

## Introduction

Reporting API client for Python

## Supported Platforms

The following platforms are officially supported (tested):

- **Python:** 3.11
- **Operating System:** Ubuntu Linux 20.04
- **Architectures:** amd64, arm64

## Contributing

If you want to know how to build this project and contribute to it, please
check out the [Contributing Guide](CONTRIBUTING.md).


## Usage

Please also refer to [examples](https://github.com/frequenz-floss/frequenz-client-reporting-python/tree/HEAD/examples) for more detailed usage.

### Installation

```bash
# Choose the version to install
VERSION=0.2.0
pip install frequenz-client-reporting==$VERSION
```


### Initialize the client

```python
from datetime import datetime

from frequenz.client.common.metric import Metric
from frequenz.client.reporting import ReportingApiClient

# Change server address
SERVICE_ADDRESS = "localhost:4711"
client = ReportingApiClient(service_address=SERVICE_ADDRESS)
```

### Query metrics for a single microgrid and component:

```python
data = [
    sample async for sample in
    client.list_single_component_data(
        microgrid_id=1,
        component_id=100,
        metrics=[Metric.AC_ACTIVE_POWER, Metric.AC_REACTIVE_POWER],
        start_dt=datetime.fromisoformat("2024-05-01T00:00:00"),
        end_dt=datetime.fromisoformat("2024-05-02T00:00:00"),
        page_size=10000,
    )
]
```


### Query metrics for multiple microgrids and components

```python
# Set the microgrid ID and the component IDs that belong to the microgrid
# Multiple microgrids and components can be queried at once
microgrid_id1 = 1
component_ids1 = [100, 101, 102]
microgrid_id2 = 2
component_ids2 = [200, 201, 202]
microgrid_components = [
    (microgrid_id1, component_ids1),
    (microgrid_id2, component_ids2),
]

data = [
    sample async for sample in
    client.list_microgrid_components_data(
        microgrid_components=microgrid_components,
        metrics=[Metric.AC_ACTIVE_POWER, Metric.AC_REACTIVE_POWER],
        start_dt=datetime.fromisoformat("2024-05-01T00:00:00"),
        end_dt=datetime.fromisoformat("2024-05-02T00:00:00"),
        page_size=10000,
    )
]
```

### Optionally convert the data to a pandas DataFrame

```python
import pandas as pd
df = pd.DataFrame(data)
print(df)
```

## Command line client example

The example folder contains a simple client that can be used to query the reporting API from the command line:
```bash
python examples/client.py --url localhost:4711 --mid 42 --cid 23 --metrics AC_ACTIVE_POWER AC_REACTIVE_POWER --start 2024-05-01T00:00:00 --end 2024-05-02T00:00:00
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "frequenz-client-reporting",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.11",
    "maintainer_email": null,
    "keywords": "frequenz, python, lib, library, client-reporting, client, reporting, api",
    "author": null,
    "author_email": "Frequenz Energy-as-a-Service GmbH <floss@frequenz.com>",
    "download_url": "https://files.pythonhosted.org/packages/10/c8/2715613018bbeb1e63efbb58a291d3489334324a225449f625d1b8912c3e/frequenz-client-reporting-0.3.0.tar.gz",
    "platform": null,
    "description": "# Frequenz Reporting API Client\n\n[![Build Status](https://github.com/frequenz-floss/frequenz-client-reporting-python/actions/workflows/ci.yaml/badge.svg)](https://github.com/frequenz-floss/frequenz-client-reporting-python/actions/workflows/ci.yaml)\n[![PyPI Package](https://img.shields.io/pypi/v/frequenz-client-reporting)](https://pypi.org/project/frequenz-client-reporting/)\n[![Docs](https://img.shields.io/badge/docs-latest-informational)](https://frequenz-floss.github.io/frequenz-client-reporting-python/)\n\n## Introduction\n\nReporting API client for Python\n\n## Supported Platforms\n\nThe following platforms are officially supported (tested):\n\n- **Python:** 3.11\n- **Operating System:** Ubuntu Linux 20.04\n- **Architectures:** amd64, arm64\n\n## Contributing\n\nIf you want to know how to build this project and contribute to it, please\ncheck out the [Contributing Guide](CONTRIBUTING.md).\n\n\n## Usage\n\nPlease also refer to [examples](https://github.com/frequenz-floss/frequenz-client-reporting-python/tree/HEAD/examples) for more detailed usage.\n\n### Installation\n\n```bash\n# Choose the version to install\nVERSION=0.2.0\npip install frequenz-client-reporting==$VERSION\n```\n\n\n### Initialize the client\n\n```python\nfrom datetime import datetime\n\nfrom frequenz.client.common.metric import Metric\nfrom frequenz.client.reporting import ReportingApiClient\n\n# Change server address\nSERVICE_ADDRESS = \"localhost:4711\"\nclient = ReportingApiClient(service_address=SERVICE_ADDRESS)\n```\n\n### Query metrics for a single microgrid and component:\n\n```python\ndata = [\n    sample async for sample in\n    client.list_single_component_data(\n        microgrid_id=1,\n        component_id=100,\n        metrics=[Metric.AC_ACTIVE_POWER, Metric.AC_REACTIVE_POWER],\n        start_dt=datetime.fromisoformat(\"2024-05-01T00:00:00\"),\n        end_dt=datetime.fromisoformat(\"2024-05-02T00:00:00\"),\n        page_size=10000,\n    )\n]\n```\n\n\n### Query metrics for multiple microgrids and components\n\n```python\n# Set the microgrid ID and the component IDs that belong to the microgrid\n# Multiple microgrids and components can be queried at once\nmicrogrid_id1 = 1\ncomponent_ids1 = [100, 101, 102]\nmicrogrid_id2 = 2\ncomponent_ids2 = [200, 201, 202]\nmicrogrid_components = [\n    (microgrid_id1, component_ids1),\n    (microgrid_id2, component_ids2),\n]\n\ndata = [\n    sample async for sample in\n    client.list_microgrid_components_data(\n        microgrid_components=microgrid_components,\n        metrics=[Metric.AC_ACTIVE_POWER, Metric.AC_REACTIVE_POWER],\n        start_dt=datetime.fromisoformat(\"2024-05-01T00:00:00\"),\n        end_dt=datetime.fromisoformat(\"2024-05-02T00:00:00\"),\n        page_size=10000,\n    )\n]\n```\n\n### Optionally convert the data to a pandas DataFrame\n\n```python\nimport pandas as pd\ndf = pd.DataFrame(data)\nprint(df)\n```\n\n## Command line client example\n\nThe example folder contains a simple client that can be used to query the reporting API from the command line:\n```bash\npython examples/client.py --url localhost:4711 --mid 42 --cid 23 --metrics AC_ACTIVE_POWER AC_REACTIVE_POWER --start 2024-05-01T00:00:00 --end 2024-05-02T00:00:00\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Reporting API client for Python",
    "version": "0.3.0",
    "project_urls": {
        "Changelog": "https://github.com/frequenz-floss/frequenz-client-reporting-python/releases",
        "Documentation": "https://frequenz-floss.github.io/frequenz-client-reporting-python/",
        "Issues": "https://github.com/frequenz-floss/frequenz-client-reporting-python/issues",
        "Repository": "https://github.com/frequenz-floss/frequenz-client-reporting-python",
        "Support": "https://github.com/frequenz-floss/frequenz-client-reporting-python/discussions/categories/support"
    },
    "split_keywords": [
        "frequenz",
        " python",
        " lib",
        " library",
        " client-reporting",
        " client",
        " reporting",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd343594b46f55dd0aad413ed66445051124886049404193275b158b07259edd",
                "md5": "77b295b546befa6e0c32e555aa286ddb",
                "sha256": "4cfbf91b782248a40f50eada7ff2df5a7f43673bee1d6b3673045a1027570e5e"
            },
            "downloads": -1,
            "filename": "frequenz_client_reporting-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "77b295b546befa6e0c32e555aa286ddb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.11",
            "size": 8048,
            "upload_time": "2024-05-14T16:06:29",
            "upload_time_iso_8601": "2024-05-14T16:06:29.940765Z",
            "url": "https://files.pythonhosted.org/packages/bd/34/3594b46f55dd0aad413ed66445051124886049404193275b158b07259edd/frequenz_client_reporting-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "10c82715613018bbeb1e63efbb58a291d3489334324a225449f625d1b8912c3e",
                "md5": "0c80591d537f3c6e071ce0f74c4825cb",
                "sha256": "5f5975aa4603e4f5d3ee65bf0773796c6837e8d839af5a46c2dd9eb28645e80a"
            },
            "downloads": -1,
            "filename": "frequenz-client-reporting-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0c80591d537f3c6e071ce0f74c4825cb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.11",
            "size": 11457,
            "upload_time": "2024-05-14T16:06:31",
            "upload_time_iso_8601": "2024-05-14T16:06:31.567639Z",
            "url": "https://files.pythonhosted.org/packages/10/c8/2715613018bbeb1e63efbb58a291d3489334324a225449f625d1b8912c3e/frequenz-client-reporting-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-14 16:06:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "frequenz-floss",
    "github_project": "frequenz-client-reporting-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "frequenz-client-reporting"
}
        
Elapsed time: 0.25756s