GHGA Service Chassis Library

raw JSON →
0.17.8 verified Sat May 09 auth: no python

A library providing the base chassis functionality for microservices at GHGA (German Human Genome-Phenome Archive). It includes common patterns for API configuration, logging, error handling, and HTTP client utilities. Current version: 0.17.8. Release cadence: irregular, roughly monthly.

pip install ghga-service-chassis-lib
error ModuleNotFoundError: No module named 'ghga_service_chassis_lib'
cause The library is installed with hyphens, but the import uses underscores.
fix
Run: pip install ghga-service-chassis-lib; then import as 'ghga_service_chassis_lib' (with underscores).
error ImportError: cannot import name 'ApiConfigBase' from 'ghga_service_chassis_lib'
cause Attempting to import from the top-level package instead of the api submodule.
fix
Use: from ghga_service_chassis_lib.api import ApiConfigBase
error pydantic.errors.PydanticUserError: A custom validator may not have the same name as a field.
cause Using pydantic v1 style validators with pydantic v2 (chassis v0.17+).
fix
Use pydantic v2 validators: @field_validator('fieldname') or @model_validator.
breaking Breaking change: In v0.17.0, the dependency pydantic was updated to v2. Config classes must now use pydantic v2 syntax.
fix Update config models: replace 'class Config' with 'model_config = ConfigDict()' and use 'Field()' for validators if needed.
breaking Breaking change: In v0.16.0, the httpyexpect library was updated, changing the exception hierarchy.
fix Catch 'HttpyExpectError' instead of older exception types.
gotcha The library uses a namespace package structure. Installing multiple 'ghga-' packages may cause issues if not installed via pip.
fix Always install via pip; avoid manually copying packages into site-packages.
deprecated The 'api' submodule's 'configure_app' function is deprecated in favor of direct usage of FastAPI lifespan.
fix Use FastAPI's lifespan context manager instead of 'configure_app'.

Quickstart demonstrates creating a config class and setting up logging.

from ghga_service_chassis_lib.api import ApiConfigBase
from ghga_service_chassis_lib.logging import configure_logging

class MyConfig(ApiConfigBase):
    service_name: str = "my-service"
    service_instance_id: str = "001"

config = MyConfig()
configure_logging(config)
print(f"Service {config.service_name} ready.")