instance-repo 1.3.3.dev2__tar.gz → 1.3.5.dev0__tar.gz
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-1.3.3.dev2 → instance_repo-1.3.5.dev0}/PKG-INFO +1 -1
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/__init__.py +3 -1
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/instances.py +139 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/models.py +79 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo.egg-info/PKG-INFO +1 -1
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/pyproject.toml +1 -1
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/README.md +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/_routing.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/_site_defaults.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/artifacts.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/bootstrap.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/cache.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/cli.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/__init__.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/benchmarks.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/config.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/datasets.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/images.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/reports.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/scaffold.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/splits.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/versions.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/clients/workflows.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/concurrency.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/content.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/endpoints.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/errors.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/image.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/layout.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/loader.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/paths.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/release.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/repo.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/retry.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/store/__init__.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/store/acr.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/store/base.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/store/oss.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/store/oss_discovery.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/store/registry.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/tasktoml.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/transport.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo/validate.py +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo.egg-info/SOURCES.txt +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo.egg-info/dependency_links.txt +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo.egg-info/entry_points.txt +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo.egg-info/requires.txt +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo.egg-info/top_level.txt +0 -0
- {instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/setup.cfg +0 -0
|
@@ -9,6 +9,7 @@ from .models import (
|
|
|
9
9
|
DatasetSeries, DatasetVersion, DatasetInstance, ManifestEntry,
|
|
10
10
|
OwnerReference, Feedback, Identity, PushResult,
|
|
11
11
|
RolloutReport, RolloutJob, ScaffoldConfig,
|
|
12
|
+
DatasetObjectDirectory, DatasetObjectFile, DatasetObjectListResult,
|
|
12
13
|
canonical_json, parse_feedbacks, append_feedback,
|
|
13
14
|
)
|
|
14
15
|
from .errors import (
|
|
@@ -18,13 +19,14 @@ from .errors import (
|
|
|
18
19
|
TransportError,
|
|
19
20
|
)
|
|
20
21
|
|
|
21
|
-
__version__ = "1.3.
|
|
22
|
+
__version__ = "1.3.5.dev0"
|
|
22
23
|
|
|
23
24
|
__all__ = [
|
|
24
25
|
"Repo", "load_instances",
|
|
25
26
|
"DatasetSeries", "DatasetVersion", "DatasetInstance", "ManifestEntry",
|
|
26
27
|
"OwnerReference", "Feedback", "Identity", "PushResult",
|
|
27
28
|
"RolloutReport", "RolloutJob", "ScaffoldConfig",
|
|
29
|
+
"DatasetObjectDirectory", "DatasetObjectFile", "DatasetObjectListResult",
|
|
28
30
|
"canonical_json", "parse_feedbacks", "append_feedback",
|
|
29
31
|
"InstanceRepoError", "LayoutError", "SchemaError", "OwnerRefMissing",
|
|
30
32
|
"ImageMissing", "Immutable", "DigestMismatch", "Forbidden", "NotVisible",
|
|
@@ -384,6 +384,145 @@ class InstancesClient:
|
|
|
384
384
|
result[parts[0]] = ""
|
|
385
385
|
return result
|
|
386
386
|
|
|
387
|
+
# ── 实例目录/文件列举(GET /datasets/objects)──────────────────
|
|
388
|
+
|
|
389
|
+
def list_objects(self, dataset: str, instance_id: str,
|
|
390
|
+
split: str | None = None, *,
|
|
391
|
+
version: str = "",
|
|
392
|
+
prefix: str | None = None,
|
|
393
|
+
page_size: int = 100,
|
|
394
|
+
token: str | None = None,
|
|
395
|
+
environment: str | None = None,
|
|
396
|
+
metadata_model: str | None = None,
|
|
397
|
+
dataset_split_id: str | None = None
|
|
398
|
+
) -> "DatasetObjectListResult":
|
|
399
|
+
"""列举实例资产目录下的文件/子目录(单页)。
|
|
400
|
+
|
|
401
|
+
调用控制面 ``GET /apis/v1/datasets/objects``,返回指定实例的
|
|
402
|
+
``{split}-assets/{instance_id}/`` 路径下的目录和文件列表。
|
|
403
|
+
|
|
404
|
+
Parameters
|
|
405
|
+
----------
|
|
406
|
+
dataset : str
|
|
407
|
+
Dataset 名称(``L1/L2`` 格式)。
|
|
408
|
+
instance_id : str
|
|
409
|
+
实例 ID。
|
|
410
|
+
split : str, optional
|
|
411
|
+
Split 名称;为 None 时使用 ``"default"``。
|
|
412
|
+
version : str
|
|
413
|
+
版本号,默认空串(split_first 布局下可为空)。
|
|
414
|
+
prefix : str, optional
|
|
415
|
+
子目录前缀过滤(相对于实例资产根目录);为 None 时列举实例根目录。
|
|
416
|
+
page_size : int
|
|
417
|
+
每页大小,默认 100。
|
|
418
|
+
token : str, optional
|
|
419
|
+
分页游标(首次传 None,后续传上次返回的 ``next_token``)。
|
|
420
|
+
environment : str, optional
|
|
421
|
+
``online`` / ``pre``,None 时用 profile 派生值。
|
|
422
|
+
metadata_model : str, optional
|
|
423
|
+
``split_first`` / ``version_first``,None 时用 profile 派生值。
|
|
424
|
+
dataset_split_id : str, optional
|
|
425
|
+
Split ID,可直接指定以避免 split 名称解析。
|
|
426
|
+
|
|
427
|
+
Returns
|
|
428
|
+
-------
|
|
429
|
+
DatasetObjectListResult
|
|
430
|
+
包含 ``directories``、``files``、``next_token``、``truncated``。
|
|
431
|
+
"""
|
|
432
|
+
from urllib.parse import quote
|
|
433
|
+
from ..models import DatasetObjectListResult
|
|
434
|
+
if not (dataset or "").strip():
|
|
435
|
+
raise SchemaError("dataset is required for instances.list_objects")
|
|
436
|
+
if not (instance_id or "").strip():
|
|
437
|
+
raise SchemaError(
|
|
438
|
+
"instance_id is required for instances.list_objects")
|
|
439
|
+
split = (split or "default").strip()
|
|
440
|
+
# 计算实例资产根前缀:{split}-assets/{instance_id}/
|
|
441
|
+
instance_asset_prefix = f"{split}-assets/{instance_id.strip()}"
|
|
442
|
+
if prefix:
|
|
443
|
+
full_prefix = f"{instance_asset_prefix}/{prefix.strip().strip('/')}"
|
|
444
|
+
else:
|
|
445
|
+
full_prefix = instance_asset_prefix
|
|
446
|
+
# 构建查询参数
|
|
447
|
+
params: list[tuple[str, str]] = [
|
|
448
|
+
("dataset_name", dataset.strip()),
|
|
449
|
+
("split", split),
|
|
450
|
+
("prefix", full_prefix),
|
|
451
|
+
("page_size", str(int(page_size)))]
|
|
452
|
+
if (version or "").strip():
|
|
453
|
+
params.append(("version", version.strip()))
|
|
454
|
+
if (dataset_split_id or "").strip():
|
|
455
|
+
params.append(("dataset_split_id", dataset_split_id.strip()))
|
|
456
|
+
if (token or "").strip():
|
|
457
|
+
params.append(("token", token.strip()))
|
|
458
|
+
# environment / metadata_model:优先显式值,其次 profile 派生
|
|
459
|
+
env = (environment or "").strip()
|
|
460
|
+
if not env:
|
|
461
|
+
env = (getattr(self._p, "dataset_environment", "") or "").strip()
|
|
462
|
+
if env:
|
|
463
|
+
params.append(("environment", env))
|
|
464
|
+
mm = (metadata_model or "").strip()
|
|
465
|
+
if not mm:
|
|
466
|
+
mm = (getattr(self._p, "metadata_model", "") or "").strip()
|
|
467
|
+
if mm:
|
|
468
|
+
params.append(("metadata_model", mm))
|
|
469
|
+
qs = "&".join(f"{k}={quote(v, safe='')}" for k, v in params)
|
|
470
|
+
data = self._t.get(f"/apis/v1/datasets/objects?{qs}")
|
|
471
|
+
if isinstance(data, dict):
|
|
472
|
+
return DatasetObjectListResult.from_dict(data)
|
|
473
|
+
return DatasetObjectListResult()
|
|
474
|
+
|
|
475
|
+
def list_all_objects(self, dataset: str, instance_id: str,
|
|
476
|
+
split: str | None = None, *,
|
|
477
|
+
version: str = "",
|
|
478
|
+
prefix: str | None = None,
|
|
479
|
+
environment: str | None = None,
|
|
480
|
+
metadata_model: str | None = None,
|
|
481
|
+
dataset_split_id: str | None = None,
|
|
482
|
+
page_size: int = 100,
|
|
483
|
+
max_pages: int = 50
|
|
484
|
+
) -> "DatasetObjectListResult":
|
|
485
|
+
"""自动翻页列举实例资产目录下的全部文件/子目录。
|
|
486
|
+
|
|
487
|
+
反复调用 :meth:`list_objects` 直到 ``truncated=False`` 或达到
|
|
488
|
+
``max_pages`` 上限,合并所有页的 ``directories`` 和 ``files``。
|
|
489
|
+
|
|
490
|
+
Parameters
|
|
491
|
+
----------
|
|
492
|
+
max_pages : int
|
|
493
|
+
最大翻页数(安全阀,防无限循环),默认 50。
|
|
494
|
+
|
|
495
|
+
其余参数同 :meth:`list_objects`。
|
|
496
|
+
|
|
497
|
+
Returns
|
|
498
|
+
-------
|
|
499
|
+
DatasetObjectListResult
|
|
500
|
+
合并后的完整结果,``truncated`` 反映是否因 ``max_pages`` 截断。
|
|
501
|
+
"""
|
|
502
|
+
from ..models import DatasetObjectListResult
|
|
503
|
+
all_dirs: list = []
|
|
504
|
+
all_files: list = []
|
|
505
|
+
tk: str | None = None
|
|
506
|
+
result = DatasetObjectListResult()
|
|
507
|
+
for _ in range(max_pages):
|
|
508
|
+
page = self.list_objects(
|
|
509
|
+
dataset, instance_id, split,
|
|
510
|
+
version=version, prefix=prefix,
|
|
511
|
+
page_size=page_size, token=tk,
|
|
512
|
+
environment=environment,
|
|
513
|
+
metadata_model=metadata_model,
|
|
514
|
+
dataset_split_id=dataset_split_id)
|
|
515
|
+
all_dirs.extend(page.directories)
|
|
516
|
+
all_files.extend(page.files)
|
|
517
|
+
result = page # 保留最后一页的 dataset/version/prefix 元信息
|
|
518
|
+
if not page.truncated or not page.next_token:
|
|
519
|
+
break
|
|
520
|
+
tk = page.next_token
|
|
521
|
+
result.directories = all_dirs
|
|
522
|
+
result.files = all_files
|
|
523
|
+
# 若因 max_pages 截断,truncated 保持 True + 保留 next_token
|
|
524
|
+
return result
|
|
525
|
+
|
|
387
526
|
def update(self, dataset: str, version: str, instance_id: str, *,
|
|
388
527
|
split: str | None = None, dataset_split_id: str | None = None,
|
|
389
528
|
manifest: list[dict] | None = None,
|
|
@@ -871,3 +871,82 @@ class RoleBinding:
|
|
|
871
871
|
role_id=d.get("role_id", ""),
|
|
872
872
|
added_by=d.get("added_by", ""),
|
|
873
873
|
added_at=d.get("added_at", ""))
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
# ── Dataset Objects(目录/文件列举)──────────────────────────────────
|
|
877
|
+
|
|
878
|
+
@dataclass
|
|
879
|
+
class DatasetObjectDirectory:
|
|
880
|
+
"""``GET /datasets/objects`` 返回的目录项。"""
|
|
881
|
+
name: str
|
|
882
|
+
path: str
|
|
883
|
+
|
|
884
|
+
@classmethod
|
|
885
|
+
def from_dict(cls, d: dict) -> "DatasetObjectDirectory":
|
|
886
|
+
return cls(name=d.get("name", ""), path=d.get("path", ""))
|
|
887
|
+
|
|
888
|
+
def to_dict(self) -> dict:
|
|
889
|
+
return {"name": self.name, "path": self.path}
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
@dataclass
|
|
893
|
+
class DatasetObjectFile:
|
|
894
|
+
"""``GET /datasets/objects`` 返回的文件项。"""
|
|
895
|
+
name: str
|
|
896
|
+
path: str
|
|
897
|
+
size_bytes: int = 0
|
|
898
|
+
content_type: str = ""
|
|
899
|
+
previewable: bool = False
|
|
900
|
+
|
|
901
|
+
@classmethod
|
|
902
|
+
def from_dict(cls, d: dict) -> "DatasetObjectFile":
|
|
903
|
+
return cls(
|
|
904
|
+
name=d.get("name", ""),
|
|
905
|
+
path=d.get("path", ""),
|
|
906
|
+
size_bytes=int(d.get("size_bytes", 0)),
|
|
907
|
+
content_type=d.get("content_type", ""),
|
|
908
|
+
previewable=bool(d.get("previewable", False)))
|
|
909
|
+
|
|
910
|
+
def to_dict(self) -> dict:
|
|
911
|
+
return {"name": self.name, "path": self.path,
|
|
912
|
+
"size_bytes": self.size_bytes,
|
|
913
|
+
"content_type": self.content_type,
|
|
914
|
+
"previewable": self.previewable}
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
@dataclass
|
|
918
|
+
class DatasetObjectListResult:
|
|
919
|
+
"""``GET /datasets/objects`` 分页响应。
|
|
920
|
+
|
|
921
|
+
``directories`` 和 ``files`` 为当前页条目;``truncated`` 为 True 时
|
|
922
|
+
可用 ``next_token`` 继续翻页。
|
|
923
|
+
"""
|
|
924
|
+
dataset: str = ""
|
|
925
|
+
version: str = ""
|
|
926
|
+
prefix: str = ""
|
|
927
|
+
directories: list[DatasetObjectDirectory] = field(default_factory=list)
|
|
928
|
+
files: list[DatasetObjectFile] = field(default_factory=list)
|
|
929
|
+
next_token: str = ""
|
|
930
|
+
truncated: bool = False
|
|
931
|
+
|
|
932
|
+
@classmethod
|
|
933
|
+
def from_dict(cls, d: dict) -> "DatasetObjectListResult":
|
|
934
|
+
return cls(
|
|
935
|
+
dataset=d.get("dataset", ""),
|
|
936
|
+
version=d.get("version", ""),
|
|
937
|
+
prefix=d.get("prefix", ""),
|
|
938
|
+
directories=[DatasetObjectDirectory.from_dict(x)
|
|
939
|
+
for x in d.get("directories", [])],
|
|
940
|
+
files=[DatasetObjectFile.from_dict(x)
|
|
941
|
+
for x in d.get("files", [])],
|
|
942
|
+
next_token=d.get("next_token", ""),
|
|
943
|
+
truncated=bool(d.get("truncated", False)))
|
|
944
|
+
|
|
945
|
+
def to_dict(self) -> dict:
|
|
946
|
+
return {
|
|
947
|
+
"dataset": self.dataset, "version": self.version,
|
|
948
|
+
"prefix": self.prefix,
|
|
949
|
+
"directories": [d.to_dict() for d in self.directories],
|
|
950
|
+
"files": [f.to_dict() for f in self.files],
|
|
951
|
+
"next_token": self.next_token,
|
|
952
|
+
"truncated": self.truncated}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{instance_repo-1.3.3.dev2 → instance_repo-1.3.5.dev0}/instance_repo.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|