root/meisheng/: ms-common-1.3.7 metadata and description

Homepage Simple index Newer version available

Shared utilities for Mei Sheng Textiles applications

author Mei Sheng Textiles Development Team
author_email dev@meisheng.group
classifiers
  • Development Status :: 5 - Production/Stable
  • Intended Audience :: Developers
  • License :: Other/Proprietary License
  • Operating System :: OS Independent
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.11
  • Programming Language :: Python :: 3.12
description_content_type text/markdown
platform
  • UNKNOWN
requires_dist
  • fastapi (>=0.100.0)
  • httpx (>=0.24.0)
  • sqlalchemy (>=2.0.0)
  • pydantic (>=2.0.0)
  • python-multipart (>=0.0.6)
  • python-consul (>=1.1.0) ; extra == 'consul'
  • pytest (>=7.0.0) ; extra == 'dev'
  • pytest-cov (>=4.0.0) ; extra == 'dev'
  • pytest-asyncio (>=0.21.0) ; extra == 'dev'
  • pytest-mock (>=3.10.0) ; extra == 'dev'
  • black (>=23.0.0) ; extra == 'dev'
  • isort (>=5.12.0) ; extra == 'dev'
  • flake8 (>=6.0.0) ; extra == 'dev'
  • mypy (>=1.0.0) ; extra == 'dev'
  • faststream[kafka] (>=0.5.30) ; extra == 'messaging'
  • httpx (>=0.24.0) ; extra == 'notifications'
  • psycopg2-binary (>=2.9.0) ; extra == 'postgres'
  • asyncpg (>=0.28.0) ; extra == 'postgres'
requires_python >=3.11

Because this project isn't in the mirror_whitelist, no releases from root/pypi are included.

File Tox results History
ms-common-1.3.7.tar.gz
Size
118 KB
Type
Source
ms_common-1.3.7-py3-none-any.whl
Size
149 KB
Type
Python Wheel
Python
3

MS Common Python Package

Shared utilities and services for Mei Sheng Textiles applications.

Overview

This package provides common functionality for the dye house application ecosystem:

Features

Installation

From Git Repository (Recommended)

pip install git+ssh://git@gitea.dev.meisheng.group:2222/Mei_Sheng_Textiles/ms_common_python.git@v1.0.0

In Docker Base Image

FROM python:3.11-slim
RUN pip install git+ssh://git@gitea.dev.meisheng.group:2222/Mei_Sheng_Textiles/ms_common_python.git@v1.0.0

Quick Start

API Key Service

from ms_common import create_api_key_service

# PostgreSQL implementation (DH_Production_Manager)
api_key_service = create_api_key_service(
    'postgres',
    session_factory=get_async_session,
    user_model=User,
    api_key_model=ApiKey
)

# SQLite implementation (MS_QC_DB)
api_key_service = create_api_key_service(
    'sqlite',
    db_path='/app/data/api_keys.db'
)

# Config implementation (dye_process_manager)
api_key_service = create_api_key_service(
    'config',
    config_keys={'admin': 'your-api-key'}
)

# Use the service
key_info = await api_key_service.validate_api_key(api_key)

Service Discovery

from ms_common.service_client import create_service_client

# Create enhanced service client with field mapping
client = create_service_client("dh-production-manager")

# Make requests with automatic field transformation
response = await client.post("ms-qc-db", "/api/v1/lots", json={
    "lot": "25D4567",  # Automatically mapped to target service format
    "contract": "MS2024001"
})

Monitoring Endpoints

from fastapi import FastAPI
from ms_common.monitoring.endpoints import create_monitoring_router

app = FastAPI()

# Add health checks and monitoring
monitoring_router = create_monitoring_router("my-service")
app.include_router(monitoring_router, prefix="/api/v1/monitoring")

Architecture

Database Independence

Each application can use its existing database schema:

# DH_Production_Manager - Uses existing PostgreSQL models
from app.models.postgres_models import User, ApiKey

# MS_QC_DB - Uses SQLite
# No model dependency, creates tables automatically

# dye_process_manager - Uses environment config
# No database required

Service Communication

# Automatic field mapping between services
# lot <-> lot_id <-> lotid transformations happen automatically

client = create_service_client("source-service")
response = await client.get("target-service", "/api/data")
# Field names automatically transformed for compatibility

Development

Setting up for Development

git clone ssh://git@gitea.dev.meisheng.group:2222/Mei_Sheng_Textiles/ms_common_python.git
cd ms_common_python
pip install -e .
pip install -r requirements-dev.txt

Running Tests

pytest tests/
pytest --cov=ms_common tests/

Building Package

python setup.py sdist bdist_wheel

Version History

License

Internal use only - Mei Sheng Textiles Ltd.