# Bento Library (for Python Bento microservices)
![Test Status](https://github.com/bento-platform/bento_lib/workflows/Test/badge.svg)
![Lint Status](https://github.com/bento-platform/bento_lib/workflows/Lint/badge.svg)
[![codecov](https://codecov.io/gh/bento-platform/bento_lib/branch/master/graph/badge.svg)](https://codecov.io/gh/bento-platform/bento_lib)
[![PyPI version](https://badge.fury.io/py/bento-lib.svg)](https://badge.fury.io/py/bento-lib)
Common utilities and helpers for Bento platform services.
## Installing
`bento_lib` can be added to a new service through normal installation, with any extras
that may be needed:
```bash
# Add to a project using Poetry for dependencies
poetry add bento_lib
# Install using pip with the FastAPI extra
pip install bento_lib[fastapi]
# etc...
```
## Developing
Clone the repository and set up the Poetry environment using the following commands:
```bash
git clone git@github.com:bento-platform/bento_lib.git
poetry install --all-extras
```
### Running Tests
For tests to complete successfully, the following external servers must be running:
* A Redis server at `localhost:6379`
* A Postgres server at `localhost:5432` with `peer` access for the `postgres`
role/database
Then, tests and linting can be run with the following command:
```bash
poetry run tox
```
### Releasing
#### 1. Release Checklist
* [ ] All tests pass and test coverage has not been reduced
* [ ] Package version has been updated (following semver) in `pyproject.toml`
* [ ] The latest changes have been merged into the `master` branch
* [ ] A release has been created, tagged in the format of `v#.#.#` and named
in the format of `Version #.#.#`, listing any changes made, in the GitHub
releases page **tagged from the master branch!**
##### 1A. Note on Versioning
The `bento_lib` project uses [semantic versioning](https://semver.org/) for
releasing. If the API is broken in any way, including minor differences in the
way a function behaves given an identical set of parameters (excluding bugfixes
for unintentional behaviour), the MAJOR version must be incremented. In this
way, we guarantee that projects relying on this API do not accidentally break
upon upgrading.
#### 2. Releasing automatically
When a version is tagged on GitHub, a build + release CI pipeline is automatically triggered.
Make sure that the tagged version is a valid semantic versioning translation of the version in
`pyproject.toml`, and that the versions otherwise match.
## Modules
### `apps`
`apps` provides Python classes for setting up applications, wrapping a framework's base class with
additional code to set up error handling and basic Bento service boilerplate.
### `auth`
`auth` provides Python service middleware for dealing with the Bento authorization service.
### `db`
`db` contains common base classes for setting up database managers.
### `drs`
`drs` provides utilities for fetching data and record metadata from
GA4GH-compatible DRS services, and Bento's own implementation (which has some
non-standard extensions.)
### `events`
`events` facilitates JSON-serialized message-passing between Bento
microservices. Serialized objects can be at most 512 MB.
Events should have a lower-case type which is type-insensitively unique and
adequately describes the associated data.
All Bento channels are prefixed with `bento.`.
### `logging`
`logging` contains helper functions for standardized Bento logging configuration
and formatting.
### `responses`
`responses` contains standardized error message-generating functions
and exception handling functions for different Python web frameworks.
### `schemas`
`schemas` contains common JSON schemas which may be useful to a variety of
different Bento services.
`schemas.bento` contains Bento-specific schemas, and `schemas.ga4gh` contains
GA4GH-standardized schemas (possibly not exactly to spec.)
### `search`
`search` contains definitions, validators, and transformations for the query
syntax for Bento, as well as a transpiler to the `psycopg2` PostgreSQL IR.
The query syntax for Bento takes advantage of JSON schemas augmented with
additional properties about the field's accessibility and, in the case of
Postgres, how the field maps to a table column (or JSON column sub-field.)
`search.data_structure` contains code for evaluating a Bento query against a
Python data structure.
`search.operations` contains constants representing valid search operations one
can allow against particular fields from within an augmented JSON schema.
`search.postgres` contains a "transpiler" from the Bento query syntax to the
`psycopg2`-provided
[intermediate representation (IR)](https://www.psycopg.org/docs/sql.html) for
PostgreSQL, allowing safe queries against a Postgres database.
`search.queries` provides definitions for the Bento query AST and some helper
methods for creating and processing ASTs.
### `service_info`
`service_info` contains Python typed dictionaries, Pydantic models, and helpers
for common structures and operations related to GA4GH's `/service-info`
specification.
### `streaming`
`streaming` contains helper code for streaming bytes via HTTP from files, and
proxied HTTP resources, including exception definitions and HTTP `Range` header
parsing.
### `workflows`
`workflows` contains common code used for handling workflow metadata processing
and response generation, as well as code associated with Bento's ingestion
routines across the different data services.
Raw data
{
"_id": null,
"home_page": "https://github.com/bento-platform/bento_lib",
"name": "bento-lib",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "David Lougheed",
"author_email": "david.lougheed@mail.mcgill.ca",
"download_url": "https://files.pythonhosted.org/packages/51/1a/1b6a08bbacdd226e50927f638dfda67571e309d1a147d5dac755c50491b2/bento_lib-12.2.4.tar.gz",
"platform": null,
"description": "# Bento Library (for Python Bento microservices)\n\n![Test Status](https://github.com/bento-platform/bento_lib/workflows/Test/badge.svg)\n![Lint Status](https://github.com/bento-platform/bento_lib/workflows/Lint/badge.svg)\n[![codecov](https://codecov.io/gh/bento-platform/bento_lib/branch/master/graph/badge.svg)](https://codecov.io/gh/bento-platform/bento_lib)\n[![PyPI version](https://badge.fury.io/py/bento-lib.svg)](https://badge.fury.io/py/bento-lib)\n\nCommon utilities and helpers for Bento platform services.\n\n\n## Installing\n\n`bento_lib` can be added to a new service through normal installation, with any extras \nthat may be needed:\n\n```bash\n# Add to a project using Poetry for dependencies\npoetry add bento_lib\n\n# Install using pip with the FastAPI extra\npip install bento_lib[fastapi]\n\n# etc...\n```\n\n\n## Developing\n\nClone the repository and set up the Poetry environment using the following commands:\n\n```bash\ngit clone git@github.com:bento-platform/bento_lib.git\npoetry install --all-extras\n```\n\n\n### Running Tests\n\nFor tests to complete successfully, the following external servers must be running:\n\n* A Redis server at `localhost:6379`\n* A Postgres server at `localhost:5432` with `peer` access for the `postgres` \n role/database \n\nThen, tests and linting can be run with the following command:\n\n```bash\npoetry run tox\n```\n\n\n### Releasing\n\n\n#### 1. Release Checklist\n\n * [ ] All tests pass and test coverage has not been reduced\n\n * [ ] Package version has been updated (following semver) in `pyproject.toml`\n \n * [ ] The latest changes have been merged into the `master` branch\n \n * [ ] A release has been created, tagged in the format of `v#.#.#` and named\n in the format of `Version #.#.#`, listing any changes made, in the GitHub \n releases page **tagged from the master branch!**\n \n\n##### 1A. Note on Versioning\n\nThe `bento_lib` project uses [semantic versioning](https://semver.org/) for\nreleasing. If the API is broken in any way, including minor differences in the\nway a function behaves given an identical set of parameters (excluding bugfixes\nfor unintentional behaviour), the MAJOR version must be incremented. In this \nway, we guarantee that projects relying on this API do not accidentally break\nupon upgrading.\n\n\n#### 2. Releasing automatically\n\nWhen a version is tagged on GitHub, a build + release CI pipeline is automatically triggered.\nMake sure that the tagged version is a valid semantic versioning translation of the version in\n`pyproject.toml`, and that the versions otherwise match.\n\n\n## Modules\n\n### `apps`\n\n`apps` provides Python classes for setting up applications, wrapping a framework's base class with\nadditional code to set up error handling and basic Bento service boilerplate.\n\n### `auth`\n\n`auth` provides Python service middleware for dealing with the Bento authorization service.\n\n### `db`\n\n`db` contains common base classes for setting up database managers.\n\n### `drs`\n\n`drs` provides utilities for fetching data and record metadata from \nGA4GH-compatible DRS services, and Bento's own implementation (which has some \nnon-standard extensions.)\n\n### `events`\n\n`events` facilitates JSON-serialized message-passing between Bento\nmicroservices. Serialized objects can be at most 512 MB.\n\nEvents should have a lower-case type which is type-insensitively unique and\nadequately describes the associated data.\n\nAll Bento channels are prefixed with `bento.`.\n\n### `logging`\n\n`logging` contains helper functions for standardized Bento logging configuration\nand formatting.\n\n### `responses`\n\n`responses` contains standardized error message-generating functions \nand exception handling functions for different Python web frameworks.\n\n### `schemas`\n\n`schemas` contains common JSON schemas which may be useful to a variety of\ndifferent Bento services.\n\n`schemas.bento` contains Bento-specific schemas, and `schemas.ga4gh` contains\nGA4GH-standardized schemas (possibly not exactly to spec.)\n\n### `search`\n\n`search` contains definitions, validators, and transformations for the query\nsyntax for Bento, as well as a transpiler to the `psycopg2` PostgreSQL IR.\n\nThe query syntax for Bento takes advantage of JSON schemas augmented with\nadditional properties about the field's accessibility and, in the case of\nPostgres, how the field maps to a table column (or JSON column sub-field.)\n\n`search.data_structure` contains code for evaluating a Bento query against a\nPython data structure.\n\n`search.operations` contains constants representing valid search operations one\ncan allow against particular fields from within an augmented JSON schema.\n\n`search.postgres` contains a \"transpiler\" from the Bento query syntax to the\n`psycopg2`-provided\n[intermediate representation (IR)](https://www.psycopg.org/docs/sql.html) for\nPostgreSQL, allowing safe queries against a Postgres database.\n\n`search.queries` provides definitions for the Bento query AST and some helper\nmethods for creating and processing ASTs.\n\n### `service_info`\n\n`service_info` contains Python typed dictionaries, Pydantic models, and helpers\nfor common structures and operations related to GA4GH's `/service-info` \nspecification.\n\n### `streaming`\n\n`streaming` contains helper code for streaming bytes via HTTP from files, and \nproxied HTTP resources, including exception definitions and HTTP `Range` header \nparsing. \n\n### `workflows`\n\n`workflows` contains common code used for handling workflow metadata processing\nand response generation, as well as code associated with Bento's ingestion\nroutines across the different data services.\n",
"bugtrack_url": null,
"license": "LGPL-3.0",
"summary": "A set of common utilities and helpers for Bento platform services.",
"version": "12.2.4",
"project_urls": {
"Homepage": "https://github.com/bento-platform/bento_lib",
"Repository": "https://github.com/bento-platform/bento_lib"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7a777688ae60143ac77e117045ad38c1fd9375db211d250c3995a3850246e193",
"md5": "46eddbdb76cc1368082178444e8d1df9",
"sha256": "d6d808685f77511ffaee3a4d9991ec623f1a718a94321b0e67a6127fa6564640"
},
"downloads": -1,
"filename": "bento_lib-12.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "46eddbdb76cc1368082178444e8d1df9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 66047,
"upload_time": "2024-12-09T17:53:26",
"upload_time_iso_8601": "2024-12-09T17:53:26.989968Z",
"url": "https://files.pythonhosted.org/packages/7a/77/7688ae60143ac77e117045ad38c1fd9375db211d250c3995a3850246e193/bento_lib-12.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "511a1b6a08bbacdd226e50927f638dfda67571e309d1a147d5dac755c50491b2",
"md5": "580f52d426659262895ab74ba48b788d",
"sha256": "e7875c3f4d66e701f116360ee302b70f9eea9a8547368c63a4bfaf1fe6b688ef"
},
"downloads": -1,
"filename": "bento_lib-12.2.4.tar.gz",
"has_sig": false,
"md5_digest": "580f52d426659262895ab74ba48b788d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 51172,
"upload_time": "2024-12-09T17:53:28",
"upload_time_iso_8601": "2024-12-09T17:53:28.231976Z",
"url": "https://files.pythonhosted.org/packages/51/1a/1b6a08bbacdd226e50927f638dfda67571e309d1a147d5dac755c50491b2/bento_lib-12.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-09 17:53:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bento-platform",
"github_project": "bento_lib",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "bento-lib"
}