Skip to content

Volopay/vp-python-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VP Core

Core utilities and helpers for VP projects.

Features

  • Structured Logging: JSON-formatted logging with support for Pydantic models and context tracking.
  • FastAPI Middleware: Out-of-the-box middleware for request/response logging, request ID generation, and performance tracking.
  • Helpers: Common utility functions for case conversion, JSON parsing, and more.

Installation

You can install this package directly from GitHub:

pip install git+https://github.com/Volopay/vp-python-core.git

Or add it to your pyproject.toml:

dependencies = [
    "vp-core @ git+https://github.com/Volopay/vp-python-core.git"
]

Usage

Logging

from vp_core import setup_logging, get_logger

# Initialize logging at the start of your application
setup_logging()

logger = get_logger(__name__)
logger.info("Application started", extra={"version": "1.0.0"})

Helpers

from vp_core.helpers.case_converter import to_camel

camel_case = to_camel("snake_case_string")
# Output: "snakeCaseString"

FastAPI Middleware

To use the logging middleware in a FastAPI application:

from fastapi import FastAPI
from vp_core.logging.middleware import logging_middleware

app = FastAPI()
app.middleware("http")(logging_middleware)

Updating the Package

To update to the latest version from the git repository, run:

pip install --upgrade git+https://github.com/Volopay/vp-python-core.git

If you are using a requirements.txt or pyproject.toml file, pip install will usually respect the version unless you force an update or change the commit/branch.

Using as a Local Dependency in Poetry

If you are developing another project locally and want to use this package without publishing it, you can add it to your pyproject.toml using Poetry:

poetry add /path/to/vp-core

Or manually add it to your pyproject.toml in the other project:

[tool.poetry.dependencies]
vp-core = { path = "../vp-core", develop = true }

Note: Setting develop = true ensures that any changes you make in the vp-core project are immediately reflected in your other project without needing to reinstall.

Development

Running Tests and Benchmarks

This package uses pytest for testing, pytest-cov for coverage, and pytest-benchmark for benchmarking.

First, install the test dependencies:

pip install -e ".[test]"

To run tests:

pytest

To run benchmarks:

pytest --benchmark-only

Running Checks

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages