Skip to main content

华策 AIGC OSS Proxy Client - 统一 RustFS / 阿里云 OSS / 七牛云,支持下载降级与上传路由

Project description

AIGC OSS Proxy Python SDK

Python Version

面向华策 AIGC 插件的统一对象存储 SDK:内网 RustFS(S3 兼容)、阿里云 OSS七牛云,支持下载自动降级与上传内外网路由。

详细设计见 DESIGN.md

安装

# 全量后端
pip install huace-aigc-oss-proxy-client[all]

# 仅阿里云
pip install huace-aigc-oss-proxy-client[aliyun]

本地 RustFS 开发环境

docker compose -f docker-compose/rustfs/docker-compose.yml up -d

控制台:http://127.0.0.1:9001minioadmin / minioadmin
API:http://127.0.0.1:9000,默认桶 aigc-intranet

环境变量

# RustFS 内网
OSS_RUSTFS_ENABLED=true
OSS_RUSTFS_ENDPOINT=http://127.0.0.1:9000
OSS_RUSTFS_ACCESS_KEY=minioadmin
OSS_RUSTFS_SECRET_KEY=minioadmin
OSS_RUSTFS_BUCKET=aigc-intranet

# 阿里云(兼容旧变量 OSS_ACCESS_KEY_ID 等)
OSS_ALIYUN_ENABLED=true
OSS_ALIYUN_ENDPOINT=https://oss-cn-hangzhou.aliyuncs.com
OSS_ALIYUN_ACCESS_KEY_ID=***
OSS_ALIYUN_ACCESS_KEY_SECRET=***
OSS_ALIYUN_BUCKET=huace-shortmovie

# 策略
OSS_DOWNLOAD_PRIORITY=rustfs,aliyun
OSS_UPLOAD_INTRANET_BACKEND=rustfs
OSS_UPLOAD_EXTRANET_BACKEND=aliyun
OSS_KEY_PREFIX=plugin-tts-indextts
OSS_STICKY_SESSION_ENABLED=true
OSS_FALLBACK_ENABLED=true

快速开始

from huace_aigc_oss import OssClient, UploadMode

client = OssClient.from_env()

# 下载:RustFS 优先,失败自动切阿里云;同进程会记住成功的后端
local = client.download("task-1/output.wav", "/tmp/output.wav")

# 上传:默认内网 RustFS,无自动降级
client.upload("task-1/output.wav", "/tmp/output.wav")

# 上传:强制外网阿里云
client.upload("task-1/output.wav", "/tmp/output.wav", mode=UploadMode.EXTRANET)

client.exists("task-1/output.wav")

插件集成示例

from huace_aigc_oss import OssClient, UploadMode

_client = None

def get_client() -> OssClient:
    global _client
    if _client is None:
        _client = OssClient.from_env()
    return _client

def upload_local_file(local_path: str, oss_key: str, extranet: bool = False) -> str:
    mode = UploadMode.EXTRANET if extranet else UploadMode.INTRANET
    result = get_client().upload(oss_key, local_path, mode=mode)
    return result.url or oss_key

发布

PUBLISH.md。复制 .pypirc.example.pypirc 并填入 PyPI Token。

python build_and_publish.py

核心行为

操作 行为
download 按优先级尝试,失败降级;进程内 sticky 记住成功后端
upload 确定性单后端,失败不降级
exists 与 download 相同优先级链

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

huace_aigc_oss_proxy_client-0.1.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

huace_aigc_oss_proxy_client-0.1.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file huace_aigc_oss_proxy_client-0.1.0.tar.gz.

File metadata

File hashes

Hashes for huace_aigc_oss_proxy_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 803b66b446372ef1d3550dde69475de21f188eacf725c6acdfee1d343fc79c77
MD5 d90d51d97e90d9fcf12d80cb64201af1
BLAKE2b-256 546fd8cc3ff499e01df14d75f35ddfeede7d4134d20196756e804cc9a0ad4d72

See more details on using hashes here.

File details

Details for the file huace_aigc_oss_proxy_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for huace_aigc_oss_proxy_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f5e0a13210b3fea298c53df6dcc2f61997da27235e5a392985d6032e4ae32bc
MD5 8085e8f27c0594fe586ab7815e7cba0e
BLAKE2b-256 e032dca0857d997fdb44fe3adcb8041f59b2521c05e590a7fd9cd7df3e5591fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page