华策 AIGC OSS Proxy Client - 统一 RustFS / 阿里云 OSS / 七牛云,支持下载降级与上传路由
Project description
AIGC OSS Proxy Python SDK
面向华策 AIGC 插件的统一对象存储 SDK:内网 RustFS(S3 兼容)、阿里云 OSS、七牛云,支持下载自动降级与上传内外网路由。
详细设计见 DESIGN.md。
安装
# 全量后端(RustFS + 阿里云 + 七牛)
pip install huace-aigc-oss-proxy-client[all]
# 仅阿里云 OSS
pip install huace-aigc-oss-proxy-client[aliyun]
# 仅 RustFS / S3 兼容内网(boto3)
pip install huace-aigc-oss-proxy-client[rustfs]
# 仅七牛云
pip install huace-aigc-oss-proxy-client[qiniu]
本地 RustFS 开发环境
docker compose -f docker-compose/rustfs/docker-compose.yml up -d
控制台:http://127.0.0.1:9001 (minioadmin / minioadmin)
API:http://127.0.0.1:9000,默认桶 aigc-intranet。
环境变量
完整示例见 env.example,复制为 .env 后修改。
# 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
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 huace_aigc_oss_proxy_client-0.1.3.tar.gz.
File metadata
- Download URL: huace_aigc_oss_proxy_client-0.1.3.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed889eb95074daef44f1146e72493b2e1f760fbcfa154353009635c6a21da6f4
|
|
| MD5 |
3a1e481494c1f9ea4466358a75033661
|
|
| BLAKE2b-256 |
3a16d2c8003b2a0667206c3e619290e4a65b95cc3a5b378b0531de8f7f7c4dad
|
File details
Details for the file huace_aigc_oss_proxy_client-0.1.3-py3-none-any.whl.
File metadata
- Download URL: huace_aigc_oss_proxy_client-0.1.3-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
558a8a0090f6cf42a24ed41f507df12f5a615101606176a547b4b5f3e75bb9f1
|
|
| MD5 |
84a0329fff2fa6e10705a675509fbe67
|
|
| BLAKE2b-256 |
63896f3da00f71d09d4f67d1386037e7adfb261795f252813dda6a017cecfef4
|