instance-repo 1.3.2.dev3__py3-none-any.whl → 1.3.2.dev4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- instance_repo/__init__.py +1 -1
- instance_repo/clients/datasets.py +5 -3
- instance_repo/clients/versions.py +14 -9
- instance_repo/store/oss_discovery.py +70 -0
- {instance_repo-1.3.2.dev3.dist-info → instance_repo-1.3.2.dev4.dist-info}/METADATA +1 -1
- {instance_repo-1.3.2.dev3.dist-info → instance_repo-1.3.2.dev4.dist-info}/RECORD +9 -9
- {instance_repo-1.3.2.dev3.dist-info → instance_repo-1.3.2.dev4.dist-info}/WHEEL +0 -0
- {instance_repo-1.3.2.dev3.dist-info → instance_repo-1.3.2.dev4.dist-info}/entry_points.txt +0 -0
- {instance_repo-1.3.2.dev3.dist-info → instance_repo-1.3.2.dev4.dist-info}/top_level.txt +0 -0
instance_repo/__init__.py
CHANGED
|
@@ -161,7 +161,8 @@ class DatasetsClient:
|
|
|
161
161
|
except TransportError as e:
|
|
162
162
|
if (e.biz_code == 92001 and fallback_to_oss
|
|
163
163
|
and self._content is not None):
|
|
164
|
-
return self._discover_detail(name, storage_env=environment
|
|
164
|
+
return self._discover_detail(name, storage_env=environment,
|
|
165
|
+
metadata_model=metadata_model)
|
|
165
166
|
raise
|
|
166
167
|
|
|
167
168
|
def update(self, name: str, *, display_name: str | None = None,
|
|
@@ -396,13 +397,14 @@ class DatasetsClient:
|
|
|
396
397
|
# ── OSS fallback discovery (private) ─────────────────────────────────
|
|
397
398
|
|
|
398
399
|
def _discover_detail(self, name: str, *,
|
|
399
|
-
storage_env: str | None = None
|
|
400
|
+
storage_env: str | None = None,
|
|
401
|
+
metadata_model: str | None = None) -> DatasetDetail:
|
|
400
402
|
from ..store.oss_discovery import (
|
|
401
403
|
parse_dataset_level, build_synthetic_dataset_detail,
|
|
402
404
|
_warn_if_truncated)
|
|
403
405
|
info = parse_dataset_level(
|
|
404
406
|
self._content, name, oss_prefix=self._oss_prefix,
|
|
405
|
-
metadata_model=self._metadata_model)
|
|
407
|
+
metadata_model=metadata_model or self._metadata_model)
|
|
406
408
|
_warn_if_truncated(info, name, 500)
|
|
407
409
|
if not info.versions and not info.unversioned_splits:
|
|
408
410
|
from ..errors import DatasetNotFound
|
|
@@ -229,7 +229,7 @@ class VersionsClient:
|
|
|
229
229
|
except TransportError as e:
|
|
230
230
|
if (e.biz_code == 92001 and fallback_to_oss
|
|
231
231
|
and self._content is not None):
|
|
232
|
-
return self._discover_versions(dataset)
|
|
232
|
+
return self._discover_versions(dataset, metadata_model=metadata_model)
|
|
233
233
|
raise
|
|
234
234
|
|
|
235
235
|
def list_paged(self, dataset: str, *, status: str | None = None,
|
|
@@ -264,7 +264,8 @@ class VersionsClient:
|
|
|
264
264
|
if (e.biz_code == 92001 and fallback_to_oss
|
|
265
265
|
and self._content is not None):
|
|
266
266
|
return self._discover_versions_paged(
|
|
267
|
-
dataset, status, int(page), int(page_size)
|
|
267
|
+
dataset, status, int(page), int(page_size),
|
|
268
|
+
metadata_model=metadata_model)
|
|
268
269
|
raise
|
|
269
270
|
rows = data.get("versions", data) if isinstance(data, dict) else data
|
|
270
271
|
rows = rows if isinstance(rows, list) else []
|
|
@@ -295,7 +296,8 @@ class VersionsClient:
|
|
|
295
296
|
except TransportError as e:
|
|
296
297
|
if (e.biz_code == 92001 and fallback_to_oss
|
|
297
298
|
and self._content is not None):
|
|
298
|
-
return self._discover_version(dataset, version
|
|
299
|
+
return self._discover_version(dataset, version,
|
|
300
|
+
metadata_model=metadata_model)
|
|
299
301
|
raise
|
|
300
302
|
|
|
301
303
|
def status(self, dataset: str, version: str, *,
|
|
@@ -891,12 +893,13 @@ class VersionsClient:
|
|
|
891
893
|
|
|
892
894
|
# ── OSS fallback discovery (private) ─────────────────────────────────
|
|
893
895
|
|
|
894
|
-
def _discover_versions(self, dataset: str
|
|
896
|
+
def _discover_versions(self, dataset: str,
|
|
897
|
+
metadata_model: str | None = None) -> list:
|
|
895
898
|
from ..store.oss_discovery import (
|
|
896
899
|
parse_dataset_level, build_synthetic_version, _warn_if_truncated)
|
|
897
900
|
info = parse_dataset_level(
|
|
898
901
|
self._content, dataset, oss_prefix=self._oss_prefix,
|
|
899
|
-
metadata_model=self._discovery_mm())
|
|
902
|
+
metadata_model=metadata_model or self._discovery_mm())
|
|
900
903
|
_warn_if_truncated(info, dataset, 500)
|
|
901
904
|
# split_first 无版本布局(只有 split)也是发现成功,只是没有版本可列
|
|
902
905
|
if not info.versions and not info.unversioned_splits:
|
|
@@ -905,20 +908,22 @@ class VersionsClient:
|
|
|
905
908
|
return [build_synthetic_version(dataset, v) for v in info.versions]
|
|
906
909
|
|
|
907
910
|
def _discover_versions_paged(self, dataset: str, status: str | None,
|
|
908
|
-
page: int, page_size: int
|
|
911
|
+
page: int, page_size: int,
|
|
912
|
+
metadata_model: str | None = None):
|
|
909
913
|
"""OSS 回退的 list_paged:全量探测后按 status 过滤 + 内存分页。"""
|
|
910
914
|
from ..store.oss_discovery import _in_memory_paged
|
|
911
|
-
items = self._discover_versions(dataset)
|
|
915
|
+
items = self._discover_versions(dataset, metadata_model=metadata_model)
|
|
912
916
|
if (status or "").strip():
|
|
913
917
|
items = [v for v in items if v.status == status.strip()]
|
|
914
918
|
return _in_memory_paged(items, int(page), int(page_size))
|
|
915
919
|
|
|
916
|
-
def _discover_version(self, dataset: str, version: str
|
|
920
|
+
def _discover_version(self, dataset: str, version: str,
|
|
921
|
+
metadata_model: str | None = None):
|
|
917
922
|
from ..store.oss_discovery import (
|
|
918
923
|
parse_dataset_level, build_synthetic_version, _warn_if_truncated)
|
|
919
924
|
info = parse_dataset_level(
|
|
920
925
|
self._content, dataset, oss_prefix=self._oss_prefix,
|
|
921
|
-
metadata_model=self._discovery_mm())
|
|
926
|
+
metadata_model=metadata_model or self._discovery_mm())
|
|
922
927
|
_warn_if_truncated(info, dataset, 500)
|
|
923
928
|
for v in info.versions:
|
|
924
929
|
if v.version == version:
|
|
@@ -23,6 +23,7 @@ from ..models import (
|
|
|
23
23
|
DatasetInstance,
|
|
24
24
|
DatasetSplit,
|
|
25
25
|
DatasetVersion,
|
|
26
|
+
ManifestEntry,
|
|
26
27
|
PagedResult,
|
|
27
28
|
SplitManifest,
|
|
28
29
|
)
|
|
@@ -564,6 +565,62 @@ def build_synthetic_instances(
|
|
|
564
565
|
return instances
|
|
565
566
|
|
|
566
567
|
|
|
568
|
+
def _instance_dir(dataset: str, version: str, split: str | None,
|
|
569
|
+
instance_id: str, suffix: str, oss_prefix: str) -> str:
|
|
570
|
+
"""拼接实例的 -assets/-report 目录;version 为空表示无版本 split 布局。"""
|
|
571
|
+
l1, l2 = P.split_dataset(dataset)
|
|
572
|
+
base = f"{oss_prefix}/{l1}/{l2}" + (f"/{version}" if version else "")
|
|
573
|
+
if split and split != "default":
|
|
574
|
+
return f"{base}/{split}-{suffix}/{instance_id}/"
|
|
575
|
+
return f"{base}-{suffix}/{instance_id}/"
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
def _format_from_key(key: str) -> str:
|
|
579
|
+
if key.endswith(".jsonl"):
|
|
580
|
+
return "jsonl"
|
|
581
|
+
if key.endswith(".json"):
|
|
582
|
+
return "json"
|
|
583
|
+
if key.endswith(".tgz") or key.endswith(".tar.gz"):
|
|
584
|
+
return "tgz"
|
|
585
|
+
return ""
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
def _instance_manifest(
|
|
589
|
+
content_store,
|
|
590
|
+
dataset: str,
|
|
591
|
+
version: str,
|
|
592
|
+
instance_id: str,
|
|
593
|
+
split: str | None,
|
|
594
|
+
metadata_key: str,
|
|
595
|
+
*,
|
|
596
|
+
oss_prefix: str,
|
|
597
|
+
) -> list[ManifestEntry]:
|
|
598
|
+
"""用 LIST 枚举实例的文件结构(metadata + {split}-assets + {split}-report)。
|
|
599
|
+
|
|
600
|
+
发现模式(list-only STS)无 GetObject,读不到 metadata JSON 内容,但目录
|
|
601
|
+
结构可通过 LIST 完整呈现——恰好满足「查看实例的目录文件结构」需求。
|
|
602
|
+
"""
|
|
603
|
+
keys = [metadata_key]
|
|
604
|
+
for suffix in ("assets", "report"):
|
|
605
|
+
try:
|
|
606
|
+
keys.extend(k for k in content_store.list_objects(
|
|
607
|
+
_instance_dir(dataset, version, split, instance_id,
|
|
608
|
+
suffix, oss_prefix),
|
|
609
|
+
list_only=True) if not k.endswith("/"))
|
|
610
|
+
except Exception: # noqa: BLE001
|
|
611
|
+
pass # best-effort:无 assets/report 目录时忽略
|
|
612
|
+
bucket = getattr(content_store, "bucket_name", "") or ""
|
|
613
|
+
return [
|
|
614
|
+
ManifestEntry(
|
|
615
|
+
file_path=f"oss://{bucket}/{k}" if bucket else k,
|
|
616
|
+
content_type="file",
|
|
617
|
+
content_format=_format_from_key(k),
|
|
618
|
+
object_path=k,
|
|
619
|
+
)
|
|
620
|
+
for k in keys
|
|
621
|
+
]
|
|
622
|
+
|
|
623
|
+
|
|
567
624
|
def build_synthetic_instance(
|
|
568
625
|
content_store,
|
|
569
626
|
dataset: str,
|
|
@@ -573,11 +630,17 @@ def build_synthetic_instance(
|
|
|
573
630
|
*,
|
|
574
631
|
oss_prefix: str = "swe/datasets",
|
|
575
632
|
read_content: bool = False,
|
|
633
|
+
include_files: bool = True,
|
|
576
634
|
) -> DatasetInstance | None:
|
|
577
635
|
"""Build a single :class:`DatasetInstance` by exact key lookup in OSS.
|
|
578
636
|
|
|
579
637
|
Returns ``None`` if the metadata JSON does not exist. ``read_content``
|
|
580
638
|
语义同 :func:`build_synthetic_instances`(发现模式默认跳过 JSON 回填)。
|
|
639
|
+
|
|
640
|
+
``include_files``(默认 True)用 LIST 枚举实例文件结构(metadata + assets
|
|
641
|
+
+ report 目录)回填 ``manifest``——文件名为真实值,digest/大小留空
|
|
642
|
+
(list-only STS 无 GetObject)。仅 instance get 单条路径开启,避免列表
|
|
643
|
+
路径 N 倍 LIST 开销。
|
|
581
644
|
"""
|
|
582
645
|
if version:
|
|
583
646
|
key = P.metadata_key(
|
|
@@ -609,6 +672,13 @@ def build_synthetic_instance(
|
|
|
609
672
|
split=split or "default",
|
|
610
673
|
registered=False,
|
|
611
674
|
)
|
|
675
|
+
if include_files:
|
|
676
|
+
try:
|
|
677
|
+
inst.manifest = _instance_manifest(
|
|
678
|
+
content_store, dataset, version, instance_id, split, key,
|
|
679
|
+
oss_prefix=oss_prefix)
|
|
680
|
+
except Exception: # noqa: BLE001
|
|
681
|
+
pass # best-effort:manifest 枚举失败不阻断实例返回
|
|
612
682
|
if read_content:
|
|
613
683
|
data = _read_json_object(content_store, key)
|
|
614
684
|
if data:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
instance_repo/__init__.py,sha256=
|
|
1
|
+
instance_repo/__init__.py,sha256=lAyyofR-xkJ6HHVt7KUbO5Ar3_hFdKTJxyAK13u7hnE,1422
|
|
2
2
|
instance_repo/_routing.py,sha256=fX3oKJNca1XTD1pKK304eq0clf7I8iEdFkd2WFO3oV4,8414
|
|
3
3
|
instance_repo/_site_defaults.py,sha256=ck7aHHTup8ibBo0l5MSR03XpTtxJ11hYo7oM2DzWs4A,2383
|
|
4
4
|
instance_repo/artifacts.py,sha256=OOcSI1ehB_dw1ZNScjyhzghPqOdL534kQp_iI2Hz7IU,10659
|
|
@@ -23,22 +23,22 @@ instance_repo/validate.py,sha256=NMR-vFBIU_FQ0WKdBZuQ-ua4jtkAzvWwEjnAHyAFwDs,118
|
|
|
23
23
|
instance_repo/clients/__init__.py,sha256=5V7Pe0b6nnMiwIhACA4ctQowovrL4iHTiHKKcjmsBQo,488
|
|
24
24
|
instance_repo/clients/benchmarks.py,sha256=RzHY8VzDP1o2jT4M8gxxbcr3amuNr4mlSblZhhJqG_w,2778
|
|
25
25
|
instance_repo/clients/config.py,sha256=UdfNDqeQnFaOBBAl-Aj-W2JvuouvJ11q-_gB4da9yBg,21209
|
|
26
|
-
instance_repo/clients/datasets.py,sha256=
|
|
26
|
+
instance_repo/clients/datasets.py,sha256=snSqr4tHVzOCj4HnQlGHoKmqtz1HrxEoMNoja4yrSuI,24497
|
|
27
27
|
instance_repo/clients/images.py,sha256=8i0FXxAAL2mOUUTrVgDdWSYM2imJ5nOEXzpVRBa-G-k,4911
|
|
28
28
|
instance_repo/clients/instances.py,sha256=IOAKl3MAlW3UcftX8b5cGIEdC5_1qfouaVSE_0-OAxE,58125
|
|
29
29
|
instance_repo/clients/reports.py,sha256=4Z8bpcSi-mmfkQLKpMklelLI4mgHcnjfb0725bE2nkI,3001
|
|
30
30
|
instance_repo/clients/scaffold.py,sha256=VLicNFnqKi2iYB-gjOkQ9wa1unNOJXO7UxBZlz7El5A,4998
|
|
31
31
|
instance_repo/clients/splits.py,sha256=o8ygCVAMrxECNojzfUdaHQtuwL4Imzm7ghNKWPxG-VE,28255
|
|
32
|
-
instance_repo/clients/versions.py,sha256=
|
|
32
|
+
instance_repo/clients/versions.py,sha256=IOzGckKjQGTWC4w1Zqg12hN6bdzX2gClOZdgNCHdeyA,53639
|
|
33
33
|
instance_repo/clients/workflows.py,sha256=6ftl1tuyEGx8BtMLSjfExP9_VcQhK4veo7ex1jDOdlc,3686
|
|
34
34
|
instance_repo/store/__init__.py,sha256=fGwePNjKuojqx1yagSaY-svONE5pjaEz2BZmG0ISUZ0,674
|
|
35
35
|
instance_repo/store/acr.py,sha256=OD7LH3GZY4HrrbEht86Mf3NfW_lh-8MhCTOGyX6gLT4,19468
|
|
36
36
|
instance_repo/store/base.py,sha256=7feHdDXDvSkq60wXYvF6p8TK9KRj7YTLlESdgZ5MQHo,2622
|
|
37
37
|
instance_repo/store/oss.py,sha256=-1dBPlUBLD0z-aI4GOuO6kwGyIgZX1zRvYCD-IPp-Zs,30672
|
|
38
|
-
instance_repo/store/oss_discovery.py,sha256=
|
|
38
|
+
instance_repo/store/oss_discovery.py,sha256=gFZmHkpl1136hsXGL2CEBcHEbnpbTz3kAt2OZA71U-E,25894
|
|
39
39
|
instance_repo/store/registry.py,sha256=1R2GqXsuDZ8wc3IGpncF9yL6IHk-FeiwUlZN7v2ndSc,10837
|
|
40
|
-
instance_repo-1.3.2.
|
|
41
|
-
instance_repo-1.3.2.
|
|
42
|
-
instance_repo-1.3.2.
|
|
43
|
-
instance_repo-1.3.2.
|
|
44
|
-
instance_repo-1.3.2.
|
|
40
|
+
instance_repo-1.3.2.dev4.dist-info/METADATA,sha256=CY7IFFYrk54y2DSipSc5lSGMsFgGQfZiHfdh2ykx518,14227
|
|
41
|
+
instance_repo-1.3.2.dev4.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
42
|
+
instance_repo-1.3.2.dev4.dist-info/entry_points.txt,sha256=tn6jgwYChSx7eAqw9YNed_JFYYgoRtE7WkFn8xqa8Rw,53
|
|
43
|
+
instance_repo-1.3.2.dev4.dist-info/top_level.txt,sha256=mblK0Bkwwp6jCZioS6q3sSuFFs8NR9DKTJ0DJpIRDmY,14
|
|
44
|
+
instance_repo-1.3.2.dev4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|