Name | async-data-api JSON |
Version |
1.0.0
JSON |
| download |
home_page | |
Summary | Async Client for PSIs REST DataApi (https://data-api.psi.ch) |
upload_time | 2022-12-20 22:47:30 |
maintainer | |
docs_url | None |
author | Niklas Laufkoetter |
requires_python | >=3.8,<4.0 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# async_data_api - Async DataApi Client
[![pipeline status](https://git.psi.ch/proscan_data/async_data_api/badges/main/pipeline.svg)](https://git.psi.ch/proscan_data/async_data_api/-/commits/main)
[![coverage report](https://git.psi.ch/proscan_data/async_data_api/badges/main/coverage.svg)](https://git.psi.ch/proscan_data/async_data_api/-/commits/main)
#### Table of Contents
- [Introduction](#introduction)
- [Installation](#installation)
- [Quick-start Guid](#quick-start-guide)
- [Documentation](#documentation)
- [Dependencies](#dependencies)
- [Contribute](#contribute)
- [Project Changes and Tagged Releases](#project-changes-and-tagged-releases)
- [Developer Notes](#developer-notes)
- [Contact](#contact)
# Introduction
This project/package aims to provide a fully asynchronous client for PSIs REST DataAPI.
# Installation
Install with pip
```bash
pip install async_data_api
```
# Quick-start Guide
Here are some simple examples to get you started:
```python
import asyncio
from datetime import datetime, timedelta
from async_data_api import (
Aggregation,
Backends,
ChannelName,
DataApi,
EventFields,
RangeByDate,
)
async def search_channels_example():
"""Example of how to find a channel by it's name on any backend.
"""
async with DataApi(base_url="https://data-api.psi.ch/") as api:
channels = await api.find_channels(
regex="MMAC3:STR:2",
return_config=True,
)
print(channels)
async def get_data_example():
"""Example to get the data for a channel of the last 3 days, aggregated and binned to 500 bins, as pandas dataframe.
"""
async with DataApi(base_url="https://data-api.psi.ch/") as api:
async for result in api.get_data(
channels=ChannelName(name="MMAC3:STR:2", backend=Backends.proscan),
range=RangeByDate(
start_date=datetime.now() - timedelta(days=3),
endDate=datetime.now(),
start_expansion=False,
),
event_fields=[EventFields.global_millis, EventFields.raw_value],
aggregation=Aggregation(
aggregations=[
Aggregation.Aggregations.min,
Aggregation.Aggregations.mean,
Aggregation.Aggregations.max,
],
nr_of_bins=500,
),
):
df = api.json_to_dataframe(result)
print(df)
async def main():
"""Uncomment the example you want to run
"""
#await search_channels_example()
#await get_data_example()
pass
if __name__ == "__main__":
asyncio.run(main())
```
# Documentation
Current Features:
* Fully asynchronous
* 100% Test coverage
* Search for channels
* get data as pandas dataframe
Check out the wiki for more info!
# Dependencies
* [httpx](https://github.com/encode/httpx/)
* [isodate](https://github.com/gweis/isodate/)
* [pandas](https://pandas.pydata.org/)
# Contribute
To contribute, simply clone the project.
You can uses ``` pip -r requirements.txt ``` or the Makefile to set up the project.
After that you can make changes and create a pull request or if allowed merge your changes.
# Project Changes and Tagged Releases
* See the Changelog file for further information
* Project releases are available in pypi (NOT YET)
# Developer Notes
Currently None
# Contact
If you have any questions pleas contract 'niklas.laufkoetter@psi.ch'
Raw data
{
"_id": null,
"home_page": "",
"name": "async-data-api",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Niklas Laufkoetter",
"author_email": "niklas.laufkoetter@psi.ch",
"download_url": "https://files.pythonhosted.org/packages/c0/7c/9353cdf9564edfaac379c5b4053e7bc065349b1a9e98c4ccf1fa262fbb27/async_data_api-1.0.0.tar.gz",
"platform": null,
"description": "# async_data_api - Async DataApi Client\n\n[![pipeline status](https://git.psi.ch/proscan_data/async_data_api/badges/main/pipeline.svg)](https://git.psi.ch/proscan_data/async_data_api/-/commits/main)\n\n[![coverage report](https://git.psi.ch/proscan_data/async_data_api/badges/main/coverage.svg)](https://git.psi.ch/proscan_data/async_data_api/-/commits/main)\n\n#### Table of Contents\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Quick-start Guid](#quick-start-guide)\n- [Documentation](#documentation)\n- [Dependencies](#dependencies)\n- [Contribute](#contribute)\n- [Project Changes and Tagged Releases](#project-changes-and-tagged-releases)\n- [Developer Notes](#developer-notes)\n- [Contact](#contact)\n\n# Introduction\nThis project/package aims to provide a fully asynchronous client for PSIs REST DataAPI.\n\n# Installation\nInstall with pip\n```bash\npip install async_data_api\n```\n# Quick-start Guide\nHere are some simple examples to get you started:\n```python\nimport asyncio\nfrom datetime import datetime, timedelta\n\nfrom async_data_api import (\n Aggregation,\n Backends,\n ChannelName,\n DataApi,\n EventFields,\n RangeByDate,\n)\n\n\nasync def search_channels_example():\n \"\"\"Example of how to find a channel by it's name on any backend.\n \"\"\"\n async with DataApi(base_url=\"https://data-api.psi.ch/\") as api:\n channels = await api.find_channels(\n regex=\"MMAC3:STR:2\",\n return_config=True,\n )\n print(channels)\n\n\nasync def get_data_example():\n \"\"\"Example to get the data for a channel of the last 3 days, aggregated and binned to 500 bins, as pandas dataframe.\n \"\"\"\n async with DataApi(base_url=\"https://data-api.psi.ch/\") as api:\n async for result in api.get_data(\n channels=ChannelName(name=\"MMAC3:STR:2\", backend=Backends.proscan),\n range=RangeByDate(\n start_date=datetime.now() - timedelta(days=3),\n endDate=datetime.now(),\n start_expansion=False,\n ),\n event_fields=[EventFields.global_millis, EventFields.raw_value],\n aggregation=Aggregation(\n aggregations=[\n Aggregation.Aggregations.min,\n Aggregation.Aggregations.mean,\n Aggregation.Aggregations.max,\n ],\n nr_of_bins=500,\n ),\n ):\n df = api.json_to_dataframe(result)\n print(df)\n\n\nasync def main():\n \"\"\"Uncomment the example you want to run\n \"\"\"\n #await search_channels_example()\n #await get_data_example()\n pass\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n\n```\n\n\n# Documentation\nCurrent Features:\n* Fully asynchronous\n* 100% Test coverage\n* Search for channels\n* get data as pandas dataframe\n\n\nCheck out the wiki for more info!\n\n# Dependencies\n* [httpx](https://github.com/encode/httpx/)\n* [isodate](https://github.com/gweis/isodate/)\n* [pandas](https://pandas.pydata.org/)\n\n\n# Contribute\nTo contribute, simply clone the project.\nYou can uses ``` pip -r requirements.txt ``` or the Makefile to set up the project.\nAfter that you can make changes and create a pull request or if allowed merge your changes.\n\n\n# Project Changes and Tagged Releases\n* See the Changelog file for further information\n* Project releases are available in pypi (NOT YET)\n\n# Developer Notes\nCurrently None\n\n# Contact\nIf you have any questions pleas contract 'niklas.laufkoetter@psi.ch'\n",
"bugtrack_url": null,
"license": "",
"summary": "Async Client for PSIs REST DataApi (https://data-api.psi.ch)",
"version": "1.0.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "91bf1f83049582175349842ee39aaee1",
"sha256": "eb868de09496e86dd740d8fd5a2f00dbfcfa1f6536003c4c9b2c8f2730eb8fd0"
},
"downloads": -1,
"filename": "async_data_api-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "91bf1f83049582175349842ee39aaee1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 25320,
"upload_time": "2022-12-20T22:47:28",
"upload_time_iso_8601": "2022-12-20T22:47:28.601421Z",
"url": "https://files.pythonhosted.org/packages/c9/bb/56147b06f63068c92097b8a54a64a3c8b825287035e193d52a35e57fcf00/async_data_api-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "253aec55e2b943275f7440daf4b1c775",
"sha256": "c7b4fce2286dde0ee0e6f3055f402c822a0983ad4b0823c66f84af7b80b9352b"
},
"downloads": -1,
"filename": "async_data_api-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "253aec55e2b943275f7440daf4b1c775",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 24875,
"upload_time": "2022-12-20T22:47:30",
"upload_time_iso_8601": "2022-12-20T22:47:30.212568Z",
"url": "https://files.pythonhosted.org/packages/c0/7c/9353cdf9564edfaac379c5b4053e7bc065349b1a9e98c4ccf1fa262fbb27/async_data_api-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-20 22:47:30",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "async-data-api"
}