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.1.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.1-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.1.tar.gz.

File metadata

File hashes

Hashes for huace_aigc_oss_proxy_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0613930035fc46cf461dbb5d316c0da5e09da8c70fb4611e842a23d8e38bd354
MD5 b1e7160aad5cafe9005932b21a4be776
BLAKE2b-256 1021785f2bdf2bf081c2271475fcd68628675eb5fa1e6c6079082e9bd0b576a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for huace_aigc_oss_proxy_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 daf96f6a63636efcaac7531a6c450c690baa8ce1b2623bf798c8c46ac8480b93
MD5 0037c6fda88011ed6ac79e4af4e65368
BLAKE2b-256 79b17584490e2a996a0478c500ebfdef4f5092ab4f794cedc268e3781b9d7ccb

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