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.2.tar.gz (21.7 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.2-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.2.tar.gz.

File metadata

File hashes

Hashes for huace_aigc_oss_proxy_client-0.1.2.tar.gz
Algorithm Hash digest
SHA256 25aa975e9950288cdc62c55da12d67599201930efd3dc41fd015e4f6625e6ab4
MD5 93274ba062157eb572d2388049901b75
BLAKE2b-256 3b6280cdc2a11b909e2cb3c93f00516ea18a85de62c4f7040248b0c33979280b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for huace_aigc_oss_proxy_client-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 144f1071ca56a3ad613e92cb6ae79fc9e74100bf0fc8d4016af66962fc7a13f9
MD5 158b1c4befb3e3478902bb09fc56e4df
BLAKE2b-256 8ebed300aa963eab29c23cac66f57e96ab38049e69e762eaccb4a868a0164fc9

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