Shared Python libraries for Penguin Tech applications
Project description
Penguin Tech Python Libraries
Shared Python libraries for Penguin Tech applications.
Installation
pip install penguin-libs
# With all extras
pip install penguin-libs[all]
# With specific extras
pip install penguin-libs[flask]
pip install penguin-libs[grpc]
pip install penguin-libs[http]
Features
Validation
PyDAL-style input validators with Pydantic integration:
from penguin_libs.validation import IsEmail, IsLength, chain
from penguin_libs.pydantic import EmailStr, StrongPassword
# Direct validation
validator = IsEmail()
result = validator("user@example.com")
# Chained validators
validators = chain(IsNotEmpty(), IsLength(3, 255), IsEmail())
result = validators("user@example.com")
# Pydantic models
from pydantic import BaseModel
class User(BaseModel):
email: EmailStr
password: StrongPassword
gRPC
Server helpers, client utilities, and security interceptors:
from penguin_libs.grpc import create_server, GrpcClient, AuthInterceptor
# Server
interceptors = [AuthInterceptor(secret_key="your-secret")]
server = create_server(interceptors=interceptors)
# Client
client = GrpcClient('localhost:50051')
with client.channel() as channel:
stub = MyServiceStub(channel)
response = client.call_with_retry(stub.MyMethod, request)
HTTP
Resilient HTTP client with retry logic and circuit breaker:
from penguin_libs.http import HTTPClient, HTTPClientConfig, RetryConfig
config = HTTPClientConfig(
timeout=30.0,
retry=RetryConfig(max_retries=3, base_delay=1.0)
)
client = HTTPClient(config)
response = client.get("https://api.example.com/users")
Pydantic Integration
Base models and Flask integration:
from penguin_libs.pydantic import (
RequestModel,
validated_request,
model_response,
)
class CreateUserRequest(RequestModel):
name: str
email: EmailStr
@app.route('/users', methods=['POST'])
@validated_request(body_model=CreateUserRequest)
def create_user(body: CreateUserRequest):
return model_response(UserResponse(...))
Modules
- validation: PyDAL-style validators (string, numeric, network, datetime, password)
- grpc: gRPC server/client helpers and security interceptors
- http: HTTP client with retries, circuit breaker, correlation ID
- pydantic: Base models, Flask integration, custom Annotated types
- crypto: Cryptographic utilities (placeholder)
- security: Security utilities (placeholder)
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src tests
ruff check src tests
# Type check
mypy src
License
AGPL-3.0 - See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file penguin_libs-0.1.0.tar.gz.
File metadata
- Download URL: penguin_libs-0.1.0.tar.gz
- Upload date:
- Size: 42.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b094006e50a468bef926b280f64ff42f3a718972a2d819dc553c368d4c2cefc
|
|
| MD5 |
52981a6bea8bd313a5bac8d08a819512
|
|
| BLAKE2b-256 |
97ebdf9411ffe97f0bd240ab74fa1ee861cbcc593060efa05b1d71ad1af8c661
|
Provenance
The following attestation bundles were made for penguin_libs-0.1.0.tar.gz:
Publisher:
publish.yml on penguintechinc/penguin-libs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
penguin_libs-0.1.0.tar.gz -
Subject digest:
5b094006e50a468bef926b280f64ff42f3a718972a2d819dc553c368d4c2cefc - Sigstore transparency entry: 942194276
- Sigstore integration time:
-
Permalink:
penguintechinc/penguin-libs@bb026664e29401b3a3976e3379e82e559604eb8f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/penguintechinc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bb026664e29401b3a3976e3379e82e559604eb8f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file penguin_libs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: penguin_libs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 47.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ebcf4c646cd7fafabe67eef4400d7ff536fd85ecded45bd23756c368e35b366
|
|
| MD5 |
30a557be79df0de6877448dc577cd787
|
|
| BLAKE2b-256 |
bc0e2deae32c1588c6087ab18704f21c55f09b00d5e4090394743770d2708cbe
|
Provenance
The following attestation bundles were made for penguin_libs-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on penguintechinc/penguin-libs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
penguin_libs-0.1.0-py3-none-any.whl -
Subject digest:
3ebcf4c646cd7fafabe67eef4400d7ff536fd85ecded45bd23756c368e35b366 - Sigstore transparency entry: 942194296
- Sigstore integration time:
-
Permalink:
penguintechinc/penguin-libs@bb026664e29401b3a3976e3379e82e559604eb8f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/penguintechinc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bb026664e29401b3a3976e3379e82e559604eb8f -
Trigger Event:
workflow_dispatch
-
Statement type: