sais-prism-sdk


Namesais-prism-sdk JSON
Version 0.1.0b0 PyPI version JSON
download
home_pagehttp://gitlab-paas.internal.sais.com.cn/data_intelligence_platform/sais-prism
SummarySAIS Prism: A unified interface for ML data access and lifecycle management
upload_time2025-02-22 16:37:22
maintainerNone
docs_urlNone
authorShepard
requires_python>=3.10
licenseThe Unlicense
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SAIS Prism SDK

[![PyPI version](https://img.shields.io/pypi/v/sais-prism-sdk)](https://pypi.org/project/sais-prism-sdk/)
[![License: Unlicense](https://img.shields.io/badge/license-Unlicense-blue.svg)](http://unlicense.org/)

## Unified Interface for ML Lifecycle Management

### Features

- 🚀 Centralized Configuration Management
- 🔄 Auto MLflow Integration
- 📦 Extensible Data Access Layer
- 🧩 Declarative Experiment Tracking
- 📚 Hierarchical Dependency Management

### Installation

```bash
pip install sais-prism-sdk
```

### Configuration
Create `sais_foundation.yaml`:

```yaml
ml:
  model_repo:
    name: "production"
    version: "1.0.0"
    tags:
      framework: "pytorch"

data_access:
  enabled: true
  token: ${ENV_TOKEN}
```

### User Manual

#### Experiment Tracking
```python
@sais_foundation(auto_log=True)
def train(data):
    # Auto-log params/metrics
    accuracy = model.fit()
    return {"accuracy": accuracy}
```

#### Model Deployment
```bash
sais-prism deploy --model-uri models:/prod/1 --env kubernetes
```

#### Data Access
```python
client = DataClient()
data = client.load("mysql.sales_data")
```

### API Reference

| Class | Description |
|-------|-------------|
| `ConfigManager` | Central config access |
| `MLflowService` | Model registry & tracking |
| `DataClient` | Unified data interface |

### Contributing

1. Install dev deps:
```bash
pip install -r requirements/dev.txt
```
2. Run checks:
```bash
black . && flake8
```

## License
[The Unlicense](https://unlicense.org)

## Architecture Design

![Architecture Diagram](https://via.placeholder.com/800x400.png?text=SAIS+Prism+Architecture)

### Core Components

- `ConfigManager`: Centralized configuration management
- `MLflowService`: Model registry and tracking
- `DataClient`: Unified data access interface

### Service Locator

```python
class ServiceLocator:
    _ml_instance: Optional[MLflowManager] = None
    _data_client_instance: Optional[DataAccessClient] = None

    @classmethod
    def get_ml_manager(cls) -> MLflowManager:
        if not cls._ml_instance:
            cls._ml_instance = MLflowManager(config.ml)
        return cls._ml_instance
```

### MLflow Configuration

```yaml
ml:
  enabled: true  # Global switch
  auto_log: true  # Auto-log params/metrics
  model_repo:
    name: "production_models"
    version: "1.0.0"  # Semver required
    tags:  # Custom metadata
      framework: "pytorch"
      task_type: "classification"
  metrics:  # Metric collection config
    training: ["accuracy", "f1_score"]
    validation: ["auc_roc"]
```

### Data Access Configuration

```yaml
data_access:
  enabled: true
  cached: true  # Enable local caching
  token: ${ENV_API_TOKEN}  # Env var injection
  data_access:
    mysql:
      - "sensor_data"
      - "user_behavior"
    mongodb:
      - "log_records"
```

### Advanced Usage

#### Custom Model Tags

```python
# Extend ModelRepoConfig to add custom tags
class CustomModelConfig(ModelRepoConfig):
    deployment_env: str = "staging"
    business_unit: str = "recommendation"

# Specify custom class in config
ml:
  model_repo:
    __class__: "module.path.CustomModelConfig"
    deployment_env: "production"
```

#### Extending Data Clients

1. Implement base client interface:
```python
class CustomDataClient(DataAccessClient):
    def connect(self, config):
        # Init logic

    @retry_policy(max_retries=3)
    def fetch_data(self, source):
        # Data fetch implementation
```
2. Register with service locator:
```python
ServiceLocator.set_data_client(CustomDataClient())
```

### Troubleshooting

#### Config Load Failure
**Symptoms**: `ConfigurationError: sais_foundation.yaml not found`

✅ Solution:
```bash
# Generate default config file
python -m sais_prism.config generate > sais_foundation.yaml
```

#### MLflow Connection Issues
**Symptoms**: `MLFlowIntegrationError: Failed to connect tracking server`

✅ Check steps:
1. Verify MLflow server address
2. Check network connectivity
3. Verify server certificate (if HTTPS enabled)

```python
# Manual connection test
from mlflow.tracking import MlflowClient
client = MlflowClient(config.ml.tracking_uri)
print(client.search_experiments())

            

Raw data

            {
    "_id": null,
    "home_page": "http://gitlab-paas.internal.sais.com.cn/data_intelligence_platform/sais-prism",
    "name": "sais-prism-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Shepard",
    "author_email": "Shepard <zhaoxun@sais.com.cn>",
    "download_url": "https://files.pythonhosted.org/packages/88/b9/8ce8e81534cbeb5264c5114fa511868e42e97c36ecf9f8433812ab5a93fd/sais_prism_sdk-0.1.0b0.tar.gz",
    "platform": null,
    "description": "# SAIS Prism SDK\n\n[![PyPI version](https://img.shields.io/pypi/v/sais-prism-sdk)](https://pypi.org/project/sais-prism-sdk/)\n[![License: Unlicense](https://img.shields.io/badge/license-Unlicense-blue.svg)](http://unlicense.org/)\n\n## Unified Interface for ML Lifecycle Management\n\n### Features\n\n- \ud83d\ude80 Centralized Configuration Management\n- \ud83d\udd04 Auto MLflow Integration\n- \ud83d\udce6 Extensible Data Access Layer\n- \ud83e\udde9 Declarative Experiment Tracking\n- \ud83d\udcda Hierarchical Dependency Management\n\n### Installation\n\n```bash\npip install sais-prism-sdk\n```\n\n### Configuration\nCreate `sais_foundation.yaml`:\n\n```yaml\nml:\n  model_repo:\n    name: \"production\"\n    version: \"1.0.0\"\n    tags:\n      framework: \"pytorch\"\n\ndata_access:\n  enabled: true\n  token: ${ENV_TOKEN}\n```\n\n### User Manual\n\n#### Experiment Tracking\n```python\n@sais_foundation(auto_log=True)\ndef train(data):\n    # Auto-log params/metrics\n    accuracy = model.fit()\n    return {\"accuracy\": accuracy}\n```\n\n#### Model Deployment\n```bash\nsais-prism deploy --model-uri models:/prod/1 --env kubernetes\n```\n\n#### Data Access\n```python\nclient = DataClient()\ndata = client.load(\"mysql.sales_data\")\n```\n\n### API Reference\n\n| Class | Description |\n|-------|-------------|\n| `ConfigManager` | Central config access |\n| `MLflowService` | Model registry & tracking |\n| `DataClient` | Unified data interface |\n\n### Contributing\n\n1. Install dev deps:\n```bash\npip install -r requirements/dev.txt\n```\n2. Run checks:\n```bash\nblack . && flake8\n```\n\n## License\n[The Unlicense](https://unlicense.org)\n\n## Architecture Design\n\n![Architecture Diagram](https://via.placeholder.com/800x400.png?text=SAIS+Prism+Architecture)\n\n### Core Components\n\n- `ConfigManager`: Centralized configuration management\n- `MLflowService`: Model registry and tracking\n- `DataClient`: Unified data access interface\n\n### Service Locator\n\n```python\nclass ServiceLocator:\n    _ml_instance: Optional[MLflowManager] = None\n    _data_client_instance: Optional[DataAccessClient] = None\n\n    @classmethod\n    def get_ml_manager(cls) -> MLflowManager:\n        if not cls._ml_instance:\n            cls._ml_instance = MLflowManager(config.ml)\n        return cls._ml_instance\n```\n\n### MLflow Configuration\n\n```yaml\nml:\n  enabled: true  # Global switch\n  auto_log: true  # Auto-log params/metrics\n  model_repo:\n    name: \"production_models\"\n    version: \"1.0.0\"  # Semver required\n    tags:  # Custom metadata\n      framework: \"pytorch\"\n      task_type: \"classification\"\n  metrics:  # Metric collection config\n    training: [\"accuracy\", \"f1_score\"]\n    validation: [\"auc_roc\"]\n```\n\n### Data Access Configuration\n\n```yaml\ndata_access:\n  enabled: true\n  cached: true  # Enable local caching\n  token: ${ENV_API_TOKEN}  # Env var injection\n  data_access:\n    mysql:\n      - \"sensor_data\"\n      - \"user_behavior\"\n    mongodb:\n      - \"log_records\"\n```\n\n### Advanced Usage\n\n#### Custom Model Tags\n\n```python\n# Extend ModelRepoConfig to add custom tags\nclass CustomModelConfig(ModelRepoConfig):\n    deployment_env: str = \"staging\"\n    business_unit: str = \"recommendation\"\n\n# Specify custom class in config\nml:\n  model_repo:\n    __class__: \"module.path.CustomModelConfig\"\n    deployment_env: \"production\"\n```\n\n#### Extending Data Clients\n\n1. Implement base client interface:\n```python\nclass CustomDataClient(DataAccessClient):\n    def connect(self, config):\n        # Init logic\n\n    @retry_policy(max_retries=3)\n    def fetch_data(self, source):\n        # Data fetch implementation\n```\n2. Register with service locator:\n```python\nServiceLocator.set_data_client(CustomDataClient())\n```\n\n### Troubleshooting\n\n#### Config Load Failure\n**Symptoms**: `ConfigurationError: sais_foundation.yaml not found`\n\n\u2705 Solution:\n```bash\n# Generate default config file\npython -m sais_prism.config generate > sais_foundation.yaml\n```\n\n#### MLflow Connection Issues\n**Symptoms**: `MLFlowIntegrationError: Failed to connect tracking server`\n\n\u2705 Check steps:\n1. Verify MLflow server address\n2. Check network connectivity\n3. Verify server certificate (if HTTPS enabled)\n\n```python\n# Manual connection test\nfrom mlflow.tracking import MlflowClient\nclient = MlflowClient(config.ml.tracking_uri)\nprint(client.search_experiments())\n",
    "bugtrack_url": null,
    "license": "The Unlicense",
    "summary": "SAIS Prism: A unified interface for ML data access and lifecycle management",
    "version": "0.1.0b0",
    "project_urls": {
        "Homepage": "http://gitlab-paas.internal.sais.com.cn/data_intelligence_platform/sais-prism"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4e6c4eb492b1708d553bf51cffc53014ffb551d23e628b9a3bee14b236d540e",
                "md5": "40fb20ff84005bade8726723a7f31fcf",
                "sha256": "88805fefb3ee6b729342ab4cee3073aa8612ab149733bfc45a60f1e007f0dcdb"
            },
            "downloads": -1,
            "filename": "sais_prism_sdk-0.1.0b0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "40fb20ff84005bade8726723a7f31fcf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 21445,
            "upload_time": "2025-02-22T16:37:20",
            "upload_time_iso_8601": "2025-02-22T16:37:20.312921Z",
            "url": "https://files.pythonhosted.org/packages/e4/e6/c4eb492b1708d553bf51cffc53014ffb551d23e628b9a3bee14b236d540e/sais_prism_sdk-0.1.0b0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "88b98ce8e81534cbeb5264c5114fa511868e42e97c36ecf9f8433812ab5a93fd",
                "md5": "84d868adc50d132d87e6b6bbf20b7346",
                "sha256": "60b6e163e3ad4410f75e1787881b90fd338944cdd164d703d6f449f67b728701"
            },
            "downloads": -1,
            "filename": "sais_prism_sdk-0.1.0b0.tar.gz",
            "has_sig": false,
            "md5_digest": "84d868adc50d132d87e6b6bbf20b7346",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 336128,
            "upload_time": "2025-02-22T16:37:22",
            "upload_time_iso_8601": "2025-02-22T16:37:22.915553Z",
            "url": "https://files.pythonhosted.org/packages/88/b9/8ce8e81534cbeb5264c5114fa511868e42e97c36ecf9f8433812ab5a93fd/sais_prism_sdk-0.1.0b0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-22 16:37:22",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "sais-prism-sdk"
}
        
Elapsed time: 1.32453s