This release is a pre-release and may not be stable for production use.
InstanceRepository Python SDK
Python SDK 源码版本为 1.4.7(待发布),Go、Java 为 1.4.6。Split create 可将初始 run_type 交给支持该能力的服务端原子写入,重复创建保留已有标签。具体兼容条件见下文。实际安装版本以获准制品库的发布记录为准。三语言功能矩阵。
安装与配置
Python3.10+。从批准的索引中选择已发布版本,真实OSS使用oss extra;镜像操作需要skopeo,不用镜像时显式push_image=False。源码隔离环境已有依赖时可使用:
cd sdk/python
python -m pip install -e .
规范主配置:AP_API_KEY、AP_BASE_URL、IR_API_ENV、AP_CLUSTER或INSTANCE_REPO_STORAGE_ENV。旧token/base/storage变量仅保留兼容。内部渠道包可能注入站点默认地址,外部包不能据此假设同样默认值。profile仅作标签;控制面Env不等于数据面环境,也不授予权限。
Dataset 实例操作
from instance_repo import Repo
from instance_repo.models import OwnerReference
def publish_input(repo: Repo, dataset: str, local_dir: str, owner: OwnerReference):
repo.splits.create(dataset, 'test')
result = repo.instances.push(local_dir, dataset, '', split='test',
owner_reference=owner, push_image=False, register=False)
repo.versions.ingest(dataset, '', splits=['test'])
return result
def download(repo: Repo, dataset: str, instance_id: str, output_dir: str):
return repo.instances.pull(dataset, '', instance_id, output_dir, split='test')
def remove_metadata(repo: Repo, dataset: str, instance_id: str):
return repo.instances.delete(dataset, '', instance_id, split='test')
业务Repo使用split_first;version位置参数传空串代表真实无版本,不是latest。Split create不接受非空storage_path。register=True通过ingest完成元数据注册,不能依赖历史:commit。已有目录格式与SWE单JSON格式的差异、批量结果和失败行为见当前指南。
Split 创建与服务端兼容
repo.splits.create(dataset, split, version=..., run_type=...) 在 POST 中传入初始标签。服务端返回 run_type_on_create_supported=true 时,SDK 直接读取详情,不再 PATCH 已有记录。重复创建会保留已有 run_type,包括空标签;新建记录的标签由服务端写入。
旧服务端没有返回该能力标识时,SDK 保留 POST 后 PATCH 的兼容流程。此时重复创建仍可能更新标签。需要严格保持已有标签的调用方,必须先部署支持该契约的服务端。SDK 不通过 legacy 列表或 OSS 扫描判断本次是否新建。
Python 版本升级通过 CR 合入后,可按 .aoneci/release_pysdk.yaml 使用 pysdk/v1.4.7 tag 的现有发布流程。本次源码版本不表示制品已经发布。
instances.list_objects返回文件/目录及truncated;不完整结果不能当完整目录。compute_source_hash与list_content_hashes用于变更检测;push/push_many的skip_unchanged不能替代内容校验或权限判定。
显式delete_files=True只处理匹配注册记录的canonical主JSON、专属assets/report;默认仍仅删除元数据。必须停止同实例的上传/ingest;OSS与DB无跨系统原子性,文件删除后DB可能失败。它不是尚在设计的operation_id删除协议,不会删除镜像、历史对象版本或任意manifest引用。
实例下载的元数据环境
repo.instances.pull(dataset, version, instance_id, output_dir, split="test", environment="pre")
使用 pre 元数据;online 同样覆盖本次读取。参数忽略首尾空白和大小写;空串、None(缺省)与 auto 沿用 profile 的元数据环境,保持原调用行为。参数只控制元数据查询,包含目录 manifest 的递归资产列举;OSS bucket、prefix、layout 和私网下载要求仍由原 Repo 承载。
显式环境与存储环境不匹配,或无法确认存储环境时,元数据缺失和目录接口失败不会转为 OSS discovery。开发存储映射到 pre,生产存储映射到 online。fallback_to_oss=False 只关闭 Registry 报 Dataset/Split 不存在后的 discovery,不改变原有内容格式探测或可选目录读取失败后的降级。未显式指定环境时,即使存储侧未知也保留原行为。现有内容下载和 digest 校验继续由 SDK 执行。
canonical user-data 与 shared
Repo(expected_replica_policy=policy, cluster=..., bootstrap_dataset=False)可用于只进行canonical用户操作的调用方。policy由部署方可信配置构造ReplicasPolicy,含恰好CN/SG的storage_id、bucket与OSS region;不能来自同一未验证的discovery响应。- 上传使用
upload_user_data_verified;下载使用download_user_data_verified;兼容 façadeupload_user_data/download_user_data同样走canonical流程。结果须按receipt和最终状态判定。 - metadata列表使用
user_data_entries_page/iter_user_data_entries/list_user_data,默认总限制10000行、32MiB、512页;旧直接OSS LIST与其语义不同。 - 目录操作是低层
UserDataDirectoriesClient.mkdir,必须提供可信policy及幂等UUID,不存在Repo.mkdir。 - 共享发布是独立
SharedReleaseClient,不存在Repo.shared;generic shared读取另需真实shared_library_id。精确ap-tool profile仅限当前注册的RewardKit格式。 - ACL façade的
grant/revoke/list/permissions保留,明确主体、role、subpath、storage_env和deadline;展示权限不是客户端授权证明。
准确构造示例、低层入口、错误族与流式/预算要求见当前指南。Dataset、user-data、shared、artifact配置及授权不得互相借用或静默降级。
验证
cd sdk/python
python -m pytest tests -m 'not integration'
真实环境只在具备批准权限与受控资源后执行;单元通过不等于生产双副本、真实STS或跨地域网络通过。日志不得保存API Key、AK/SK、STS、签名URL或含这些值的异常链。
测试影响评估
| 字段 | 内容 |
|---|---|
| 变更影响 | Python pull 新增 environment,统一首次元数据和递归目录查询。未传参数及 auto 保持 profile 默认;显式异侧或未知存储拒绝 discovery。 |
| 验证 | SDK 测试使用真实 Registry/InstancesClient 与离线HTTP、存储替身,覆盖 Custom资产清单/目录manifest、SWE附属目录、环境覆盖、原profile不变、非法值、旧registry默认签名和缺失元数据回退。端到端复用 Agent-Platform 的 docs/ap-cli-dataset/README.md 中3条下载验收case,不重复新增同目标case。 |
Metadata
Release files for instance-repo 1.4.8.dev0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| instance_repo-1.4.8.dev0.tar.gz | 292.0 kB | Without provenance | Details for instance_repo-1.4.8.dev0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| instance_repo-1.4.8.dev0-py3-none-any.whl | Python 3 | none | any | Details for instance_repo-1.4.8.dev0-py3-none-any.whl |
Total release size: 608.6 kB
Release files / instance_repo-1.4.8.dev0.tar.gz
| Download URL | instance_repo-1.4.8.dev0.tar.gz |
|---|---|
| Size | 292.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a563941e0f737b79d5db06ad913eaacef419cdce004da4ed3478eb02611f7f83
|
|
BLAKE2b-256 checksum How to use checksums |
a92f33086cf954c1083cd3f8e5578d668476e60c3755a631776a70b06e142bee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.19
|
Release files / instance_repo-1.4.8.dev0-py3-none-any.whl
| Download URL | instance_repo-1.4.8.dev0-py3-none-any.whl |
|---|---|
| Size | 316.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ccf8748682260461e7787f6430cd6fa8610e55899354b608ea5f6d4c3f930e7
|
|
BLAKE2b-256 checksum How to use checksums |
ab384e15adaf92a9f8667be2345cb86aa7faff50f16a9ce926c211e06eb539fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.19
|
Security for instance-repo 1.4.8.dev0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.