Skip to content

saezlab/pkg-infra

Repository files navigation

project-banner


Tests Docs Pre-commit PyPI Python License Issues Last Commit

pkg_infra provides shared infrastructure for Saezlab Python packages. It standardizes three pieces of runtime behavior that are often reimplemented ad hoc across projects:

  • Session metadata for reproducible runs and workspace-aware execution
  • Layered YAML configuration with validation and predictable precedence
  • Centralized logging based on Python's standard logging module

What it includes

  • pkg_infra.get_session(...) as the main entrypoint for initializing runtime state
  • Config loading from ecosystem, package default, user, working directory, environment variable, and optional custom file sources
  • Pydantic-based validation for the merged settings model
  • Logging configuration generation with support for file handlers, JSON output, package groups, and async queue-based logging
  • A packaged baseline configuration in pkg_infra/data/default_settings.yaml

Installation

Install the package from PyPI:

pip install pkg_infra

Install it from a local checkout with docs or test extras when developing:

pip install -e ".[docs,tests]"

Quick Example

from pathlib import Path

from pkg_infra import get_session

session = get_session(
    workspace=Path("."),
    include_location=False,
)

print(session)
print(session.get_config_dict())

corneto_settings = session.get_conf("corneto")
print(corneto_settings)

Configuration Precedence

pkg_infra merges configuration sources in this order, where later sources override earlier ones:

  1. Ecosystem config
  2. Packaged default config
  3. User config
  4. Working-directory config
  5. Config file pointed to by PKG_INFRA_CONFIG
  6. Explicit custom config path passed by the caller

Documentation

The full documentation is published at https://saezlab.github.io/pkg_infra/.

To serve the docs locally without the current upstream Material warning banner:

source .venv/bin/activate
export NO_MKDOCS_2_WARNING=1
mkdocs serve

Recommended starting points:

  • Installation: docs/installation.md
  • Quickstart: docs/learn/tutorials/quickstart.md
  • Project context and rationale: docs/pkg_infra-project/

Contributing

Contributions are welcome. The repository includes dedicated guides for documentation and code contributions in docs/community/.

License

This project is distributed under the BSD-3-Clause License. See LICENSE for details.

About

This is session handler, configuration and logging handler for Saezlab packages and applications.

Topics

Resources

License

Stars

Watchers

Forks

Contributors