Skip to main content

Bento Library (for Python Bento microservices)

Test Status Lint Status codecov PyPI version

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:

# 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:

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:

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 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.

discovery

discovery contains models and helper functions for the Bento Discovery Configuration specification, used in Katsu.

Guides

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..

i18n

i18n provides language literals and mixin model for handling pydantic models which are language specific.

logging

logging contains helper functions and types for standardized Bento logging configuration and formatting, including structured logging using structlog.

Guides

ontologies

ontologies contains models, types, and helpers for working with ontology classes, especially in the context of classes which must be eventually ingested into Katsu.

Guides

provenance

provenance contains Pydantic models for dataset provenance metadata, used for describing datasets with rich contextual information including stakeholders, funding sources, publications, licenses, and spatial coverage. The main model, DatasetModel, provides a standardized schema for dataset metadata used in Katsu.

The module also includes converters for transforming external dataset formats (e.g., PCGL) into the Bento dataset model.

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 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) 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.

Guides

streaming

streaming contains helper code for streaming bytes via HTTP from files, and proxied HTTP resources, including exception definitions and HTTP Range header parsing.

utils

Small common-use utilities for Bento services and other libraries.

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.

Metadata

Release files for bento-lib 18.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bento-lib 18.0.1
File Size Uploaded
bento_lib-18.0.1.tar.gz 78.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bento-lib 18.0.1
File Interpreter ABI Platform
bento_lib-18.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 184.3 kB

Release files / bento_lib-18.0.1.tar.gz

Download URL bento_lib-18.0.1.tar.gz
Size 78.6 kB
Tags Source
SHA-256 checksum
How to use checksums
825b9d61ffcc44457961ed73c519a9ffbf65915d375252b11aeb94f69e72aa13
BLAKE2b-256 checksum
How to use checksums
a0366a6a5f0d2d073f9a122a015383597773085d9bde25af1ca7c732ecdf048e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.12.14 Linux/6.17.0-1022-azure

Release files / bento_lib-18.0.1-py3-none-any.whl

Download URL bento_lib-18.0.1-py3-none-any.whl
Size 105.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c442c94fd31c9439567561c23079fb7684fcaf04e88b2d17424af25b3b547ca
BLAKE2b-256 checksum
How to use checksums
f1f0cbe9cf97f5bc4ed6661f57ba01be6c9f186dc8c32631bc5ee2668e5e1b70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.12.14 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

18.1.2

2 release files

18.1.0

2 release files

This release

18.0.1 This release

2 release files

18.0.0

2 release files

17.2.0

2 release files

17.1.0

2 release files

17.0.0

2 release files

16.1.2

2 release files

16.1.1

2 release files

16.1.0

2 release files

15.2.0

2 release files

15.1.1

2 release files

15.1.0

2 release files

15.0.0

2 release files

14.1.1

2 release files

14.1.0

2 release files

14.0.3

2 release files

14.0.2

2 release files

14.0.0

2 release files

13.6.0

2 release files

13.5.1

2 release files

13.5.0

2 release files

13.4.0

2 release files

13.3.0

2 release files

13.2.0

2 release files

13.1.0

2 release files

12.3.0

2 release files

12.2.3

2 release files

12.2.2

2 release files

12.2.1

2 release files

12.2.0

2 release files

12.1.1

2 release files

12.1.0

2 release files

12.0.0

2 release files

11.9.0

2 release files

11.8.0

2 release files

11.6.0

2 release files

11.5.3

2 release files

11.5.2

2 release files

11.4.0

2 release files

11.3.0

2 release files

11.1.1

2 release files

11.1.0

2 release files

10.1.1

2 release files

10.1.0

2 release files

10.0.0

2 release files

9.2.0

2 release files

9.1.0

2 release files

9.0.0

2 release files

8.1.0

2 release files

8.0.0

2 release files

7.2.2

2 release files

7.2.1

2 release files

7.2.0

2 release files

7.1.0

2 release files

7.0.0

2 release files

6.1.0

2 release files

6.0.2

2 release files

6.0.1

2 release files

6.0.0

2 release files

5.4.0

2 release files

5.3.0

2 release files

5.2.0

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page