intellif-aihub 0.1.1__tar.gz → 0.1.3__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.

Potentially problematic release.


This version of intellif-aihub might be problematic. Click here for more details.

Files changed (56) hide show
  1. intellif_aihub-0.1.3/PKG-INFO +110 -0
  2. intellif_aihub-0.1.3/README.md +89 -0
  3. intellif_aihub-0.1.3/pyproject.toml +48 -0
  4. intellif_aihub-0.1.3/src/aihub/__init__.py +1 -0
  5. intellif_aihub-0.1.3/src/aihub/client.py +91 -0
  6. intellif_aihub-0.1.3/src/aihub/exceptions.py +18 -0
  7. intellif_aihub-0.1.3/src/aihub/models/__init__.py +0 -0
  8. intellif_aihub-0.1.3/src/aihub/models/artifact.py +137 -0
  9. intellif_aihub-0.1.3/src/aihub/models/common.py +13 -0
  10. intellif_aihub-0.1.3/src/aihub/models/dataset_management.py +99 -0
  11. intellif_aihub-0.1.3/src/aihub/models/document_center.py +28 -0
  12. intellif_aihub-0.1.3/src/aihub/models/labelfree.py +31 -0
  13. intellif_aihub-0.1.3/src/aihub/models/model_training_platform.py +230 -0
  14. intellif_aihub-0.1.3/src/aihub/models/quota_schedule_management.py +0 -0
  15. intellif_aihub-0.1.3/src/aihub/models/tag_resource_management.py +50 -0
  16. intellif_aihub-0.1.3/src/aihub/models/task_center.py +117 -0
  17. intellif_aihub-0.1.3/src/aihub/models/user_system.py +262 -0
  18. intellif_aihub-0.1.3/src/aihub/services/__init__.py +0 -0
  19. intellif_aihub-0.1.3/src/aihub/services/artifact.py +353 -0
  20. intellif_aihub-0.1.3/src/aihub/services/dataset_management.py +240 -0
  21. intellif_aihub-0.1.3/src/aihub/services/document_center.py +43 -0
  22. intellif_aihub-0.1.3/src/aihub/services/labelfree.py +44 -0
  23. intellif_aihub-0.1.3/src/aihub/services/model_training_platform.py +135 -0
  24. intellif_aihub-0.1.3/src/aihub/services/quota_schedule_management.py +18 -0
  25. intellif_aihub-0.1.3/src/aihub/services/reporter.py +20 -0
  26. intellif_aihub-0.1.3/src/aihub/services/tag_resource_management.py +55 -0
  27. intellif_aihub-0.1.3/src/aihub/services/task_center.py +190 -0
  28. intellif_aihub-0.1.3/src/aihub/services/user_system.py +339 -0
  29. intellif_aihub-0.1.3/src/aihub/utils/__init__.py +0 -0
  30. intellif_aihub-0.1.3/src/aihub/utils/download.py +69 -0
  31. intellif_aihub-0.1.3/src/aihub/utils/http.py +13 -0
  32. intellif_aihub-0.1.3/src/aihub/utils/s3.py +77 -0
  33. intellif_aihub-0.1.3/src/intellif_aihub.egg-info/PKG-INFO +110 -0
  34. intellif_aihub-0.1.3/src/intellif_aihub.egg-info/SOURCES.txt +46 -0
  35. intellif_aihub-0.1.3/src/intellif_aihub.egg-info/requires.txt +7 -0
  36. intellif_aihub-0.1.3/tests/test_artifact.py +31 -0
  37. intellif_aihub-0.1.3/tests/test_dataset_management.py +30 -0
  38. intellif_aihub-0.1.3/tests/test_document_center.py +200 -0
  39. intellif_aihub-0.1.3/tests/test_labelfree.py +15 -0
  40. intellif_aihub-0.1.3/tests/test_model_training_platform.py +76 -0
  41. intellif_aihub-0.1.3/tests/test_s3.py +18 -0
  42. intellif_aihub-0.1.3/tests/test_tag_resource_management.py +18 -0
  43. intellif_aihub-0.1.3/tests/test_task_center.py +57 -0
  44. intellif_aihub-0.1.3/tests/test_user_system.py +112 -0
  45. intellif_aihub-0.1.1/PKG-INFO +0 -24
  46. intellif_aihub-0.1.1/README.md +0 -10
  47. intellif_aihub-0.1.1/aihub/__init__.py +0 -4
  48. intellif_aihub-0.1.1/aihub/_version.py +0 -1
  49. intellif_aihub-0.1.1/aihub/stop.py +0 -50
  50. intellif_aihub-0.1.1/intellif_aihub.egg-info/PKG-INFO +0 -24
  51. intellif_aihub-0.1.1/intellif_aihub.egg-info/SOURCES.txt +0 -10
  52. intellif_aihub-0.1.1/pyproject.toml +0 -17
  53. {intellif_aihub-0.1.1 → intellif_aihub-0.1.3}/LICENSE +0 -0
  54. {intellif_aihub-0.1.1 → intellif_aihub-0.1.3}/setup.cfg +0 -0
  55. {intellif_aihub-0.1.1 → intellif_aihub-0.1.3/src}/intellif_aihub.egg-info/dependency_links.txt +0 -0
  56. {intellif_aihub-0.1.1 → intellif_aihub-0.1.3/src}/intellif_aihub.egg-info/top_level.txt +0 -0
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: intellif-aihub
3
+ Version: 0.1.3
4
+ Summary: Intellif AI-hub SDK.
5
+ Author-email: Platform Team <aihub@example.com>
6
+ License-Expression: Apache-2.0
7
+ Keywords: AI-hub,sdk,intellif
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: httpx<0.28,>=0.27
14
+ Requires-Dist: pydantic<3.0,>=2.5.3
15
+ Requires-Dist: typing-extensions<5.0,>=4.13.2
16
+ Requires-Dist: pyarrow<16.0,>=15.0.2
17
+ Requires-Dist: tqdm<5.0,>=4.66
18
+ Requires-Dist: loguru>=0.7.3
19
+ Requires-Dist: minio>=7.2.7
20
+ Dynamic: license-file
21
+
22
+ # Intellif AI-Hub SDK
23
+
24
+ **Intellif AI-Hub** 官方 Python 开发包。
25
+ 一个 `Client` 对象即可完成数据集管理、标注统计、任务中心等常见操作,无需手写 HTTP 请求。
26
+
27
+ ```
28
+ aihub_sdk/
29
+ ├─ pyproject.toml
30
+ ├─ requirements.txt
31
+ ├─ src/aihub/
32
+ │ ├─ client.py
33
+ │ ├─ exceptions.py
34
+ │ ├─ models/…
35
+ │ ├─ services/…
36
+ │ └─ utils/…
37
+ └─ tests/
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 💻 安装
43
+
44
+ ```bash
45
+ # PyPI 安装
46
+ pip install intellif-aihub
47
+ # 运行环境:Python ≥ 3.8
48
+ ```
49
+
50
+ ---
51
+
52
+ ## 🚀 快速上手
53
+
54
+ ```python
55
+ from aihub import Client
56
+
57
+ BASE = "http://192.168.13.160:30021"
58
+ TOKEN = "eyJhb..." # 或设置环境变量:export AI_HUB_TOKEN=...
59
+
60
+ with Client(base_url=BASE, token=TOKEN) as cli:
61
+ # 1. 同时创建数据集 + 版本(上传本地 ZIP)
62
+ ds_id, ver_id, tag = cli.dataset_management.create_dataset_and_version(
63
+ dataset_name="cats",
64
+ is_local_upload=True,
65
+ local_file_path="/data/cats.zip",
66
+ version_description="first release",
67
+ )
68
+ print("数据集标识:", tag) # 输出:cats/V1
69
+
70
+ # 2. 下载数据集
71
+ cli.dataset_management.run_download(
72
+ dataset_version_name=tag,
73
+ local_dir="/tmp/cats",
74
+ worker=8,
75
+ )
76
+
77
+ # 3. 获取标注平台全局统计
78
+ stats = cli.labelfree.get_project_global_stats("cat-project")
79
+ print("总标注数:", stats.global_stats.total_annotations)
80
+ ```
81
+
82
+ ---
83
+
84
+ ## 🌍 环境变量
85
+
86
+ | 变量 | 作用 | 默认值 |
87
+ |----------------------------|-------------------------------------------|----------------------------------|
88
+ | `AI_HUB_TOKEN` | API 鉴权 Token(可不在 `Client` 中显式传入) | – |
89
+
90
+ ---
91
+
92
+ ## 📦 打包 & 发布
93
+
94
+ 项目采用 PEP 517 / `pyproject.toml` 构建规范。
95
+
96
+ ```bash
97
+ # 1️⃣ 构建 wheel / sdist
98
+ python -m pip install --upgrade build
99
+ python -m build # 生成 dist/*.whl dist/*.tar.gz
100
+
101
+ # 2️⃣ 本地验证
102
+ pip install --force-reinstall dist/*.whl
103
+ python -c "import aihub, sys; print('SDK 版本:', aihub.__version__)"
104
+
105
+ # 3️⃣ 发布到 PyPI 或私有仓库
106
+ python -m pip install --upgrade twine
107
+ twine upload dist/*
108
+ ```
109
+
110
+ ---
@@ -0,0 +1,89 @@
1
+ # Intellif AI-Hub SDK
2
+
3
+ **Intellif AI-Hub** 官方 Python 开发包。
4
+ 一个 `Client` 对象即可完成数据集管理、标注统计、任务中心等常见操作,无需手写 HTTP 请求。
5
+
6
+ ```
7
+ aihub_sdk/
8
+ ├─ pyproject.toml
9
+ ├─ requirements.txt
10
+ ├─ src/aihub/
11
+ │ ├─ client.py
12
+ │ ├─ exceptions.py
13
+ │ ├─ models/…
14
+ │ ├─ services/…
15
+ │ └─ utils/…
16
+ └─ tests/
17
+ ```
18
+
19
+ ---
20
+
21
+ ## 💻 安装
22
+
23
+ ```bash
24
+ # PyPI 安装
25
+ pip install intellif-aihub
26
+ # 运行环境:Python ≥ 3.8
27
+ ```
28
+
29
+ ---
30
+
31
+ ## 🚀 快速上手
32
+
33
+ ```python
34
+ from aihub import Client
35
+
36
+ BASE = "http://192.168.13.160:30021"
37
+ TOKEN = "eyJhb..." # 或设置环境变量:export AI_HUB_TOKEN=...
38
+
39
+ with Client(base_url=BASE, token=TOKEN) as cli:
40
+ # 1. 同时创建数据集 + 版本(上传本地 ZIP)
41
+ ds_id, ver_id, tag = cli.dataset_management.create_dataset_and_version(
42
+ dataset_name="cats",
43
+ is_local_upload=True,
44
+ local_file_path="/data/cats.zip",
45
+ version_description="first release",
46
+ )
47
+ print("数据集标识:", tag) # 输出:cats/V1
48
+
49
+ # 2. 下载数据集
50
+ cli.dataset_management.run_download(
51
+ dataset_version_name=tag,
52
+ local_dir="/tmp/cats",
53
+ worker=8,
54
+ )
55
+
56
+ # 3. 获取标注平台全局统计
57
+ stats = cli.labelfree.get_project_global_stats("cat-project")
58
+ print("总标注数:", stats.global_stats.total_annotations)
59
+ ```
60
+
61
+ ---
62
+
63
+ ## 🌍 环境变量
64
+
65
+ | 变量 | 作用 | 默认值 |
66
+ |----------------------------|-------------------------------------------|----------------------------------|
67
+ | `AI_HUB_TOKEN` | API 鉴权 Token(可不在 `Client` 中显式传入) | – |
68
+
69
+ ---
70
+
71
+ ## 📦 打包 & 发布
72
+
73
+ 项目采用 PEP 517 / `pyproject.toml` 构建规范。
74
+
75
+ ```bash
76
+ # 1️⃣ 构建 wheel / sdist
77
+ python -m pip install --upgrade build
78
+ python -m build # 生成 dist/*.whl dist/*.tar.gz
79
+
80
+ # 2️⃣ 本地验证
81
+ pip install --force-reinstall dist/*.whl
82
+ python -c "import aihub, sys; print('SDK 版本:', aihub.__version__)"
83
+
84
+ # 3️⃣ 发布到 PyPI 或私有仓库
85
+ python -m pip install --upgrade twine
86
+ twine upload dist/*
87
+ ```
88
+
89
+ ---
@@ -0,0 +1,48 @@
1
+ [project]
2
+ name = "intellif-aihub"
3
+ version = "0.1.3"
4
+ description = "Intellif AI-hub SDK."
5
+ readme = {file = "README.md", content-type = "text/markdown"}
6
+ requires-python = ">=3.8"
7
+ license = "Apache-2.0"
8
+ authors = [{name="Platform Team", email="aihub@example.com"}]
9
+ keywords = ["AI-hub", "sdk", "intellif"]
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Operating System :: OS Independent",
13
+ ]
14
+ dependencies = [
15
+ "httpx>=0.27,<0.28",
16
+ "pydantic>=2.5.3,<3.0",
17
+ "typing-extensions>=4.13.2,<5.0",
18
+ "pyarrow>=15.0.2,<16.0",
19
+ "tqdm>=4.66,<5.0",
20
+ "loguru>=0.7.3",
21
+ "minio>=7.2.7",
22
+ ]
23
+
24
+
25
+ [build-system]
26
+ requires = ["setuptools>=61", "wheel"]
27
+ build-backend = "setuptools.build_meta"
28
+
29
+ [tool.setuptools]
30
+ package-dir = {"" = "src"}
31
+ include-package-data = true
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
35
+
36
+ [[tool.uv.index]]
37
+ name = "tsinghua"
38
+ url = "https://pypi.tuna.tsinghua.edu.cn/simple"
39
+ default = true
40
+
41
+ [dependency-groups]
42
+ dev = [
43
+ "black>=24.8.0",
44
+ "griffe-pydantic; python_version>='3.9'",
45
+ "mkdocs-glightbox>=0.4.0",
46
+ "mkdocs-material>=9.6.15",
47
+ "mkdocstrings-python>=1.11.1",
48
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.3"
@@ -0,0 +1,91 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+
5
+ import httpx
6
+
7
+ from .exceptions import APIError
8
+ from .services import artifact
9
+ from .services import dataset_management
10
+ from .services import document_center
11
+ from .services import labelfree
12
+ from .services import model_training_platform
13
+ from .services import tag_resource_management
14
+ from .services import task_center
15
+ from .services import user_system
16
+ from .services.artifact import ArtifactService
17
+ from .services.dataset_management import DatasetManagementService
18
+ from .services.document_center import DocumentCenterService
19
+ from .services.labelfree import LabelfreeService
20
+ from .services.model_training_platform import ModelTrainingPlatformService
21
+ from .services.tag_resource_management import TagResourceManagementService
22
+ from .services.task_center import TaskCenterService
23
+ from .services.user_system import UserSystemService
24
+
25
+
26
+ class Client:
27
+ """AI-HUB python SDK 客户端
28
+
29
+ Attributes:
30
+ dataset_management (DatasetManagementService): 数据集管理服务
31
+ labelfree (LabelfreeService): 标注服务
32
+ task_center (TaskCenterService): 任务中心
33
+ artifact (ArtifactService): 制品管理
34
+
35
+ """
36
+
37
+ labelfree: LabelfreeService = None
38
+ tag_resource_management: TagResourceManagementService = None
39
+ document_center: DocumentCenterService = None
40
+ task_center: TaskCenterService = None
41
+ dataset_management: DatasetManagementService = None
42
+ artifact: ArtifactService = None
43
+ user_system: UserSystemService = None
44
+ model_training_platform: ModelTrainingPlatformService = None
45
+
46
+ def __init__(self, *, base_url: str, token: str | None = None, timeout: float = 60.0):
47
+ """AI-HUB python SDK 客户端
48
+
49
+ Args:
50
+ base_url (str): 服务地址
51
+ token (str): 密钥,显式传入,或在环境变量AI_HUB_TOKEN中设置
52
+
53
+ Examples:
54
+ >>> from aihub.client import Client
55
+ >>> client = Client(base_url="xxx", token="xxxx")
56
+
57
+ """
58
+ if not base_url:
59
+ raise ValueError("base_url必须填写")
60
+
61
+ token = os.getenv("AI_HUB_TOKEN") or token
62
+ if not token:
63
+ raise ValueError("缺少token:请显式传入,或在环境变量AI_HUB_TOKEN中设置")
64
+
65
+ self._http = httpx.Client(
66
+ base_url=base_url.rstrip("/"),
67
+ timeout=timeout,
68
+ headers={"Authorization": f"Bearer {token}"},
69
+ # event_hooks={"response": [self._raise_for_status]},
70
+ )
71
+ self.dataset_management = dataset_management.DatasetManagementService(self._http)
72
+ self.labelfree = labelfree.LabelfreeService(self._http)
73
+ self.tag_resource_management = tag_resource_management.TagResourceManagementService(self._http)
74
+ self.document_center = document_center.DocumentCenterService(self._http)
75
+ self.task_center = task_center.TaskCenterService(self._http)
76
+ self.artifact = artifact.ArtifactService(self._http)
77
+ self.user_system = user_system.UserSystemService(self._http)
78
+ self.model_training_platform = model_training_platform.ModelTrainingPlatformService(self._http)
79
+
80
+ @staticmethod
81
+ def _raise_for_status(r: httpx.Response):
82
+ try:
83
+ r.raise_for_status()
84
+ except httpx.HTTPStatusError as e:
85
+ raise APIError(f"{e.response.status_code}: {e.response.text}") from e
86
+
87
+ def __enter__(self):
88
+ return self
89
+
90
+ def __exit__(self, *a):
91
+ self._http.close()
@@ -0,0 +1,18 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Optional
4
+
5
+
6
+ class SDKError(Exception):
7
+ pass
8
+
9
+
10
+ class APIError(SDKError):
11
+ def __init__(self, message: str, *, status: Optional[int] = None, detail: Any = None) -> None:
12
+ super().__init__(message)
13
+ self.message: str = message
14
+ self.status: Optional[int] = status
15
+ self.detail: Any = detail
16
+
17
+ def __str__(self) -> str:
18
+ return f"[HTTP {self.status}] {self.message}" if self.status else self.message
File without changes
@@ -0,0 +1,137 @@
1
+ # !/usr/bin/env python
2
+ # -*-coding:utf-8 -*-
3
+ """制品管理模型模块
4
+
5
+ 该模块定义了制品管理相关的数据模型,包括制品类型、创建制品请求、制品响应等。
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from enum import Enum
10
+ from typing import List, Optional
11
+
12
+ from pydantic import BaseModel
13
+
14
+
15
+ class ArtifactType(str, Enum):
16
+ """制品类型枚举
17
+
18
+ 定义了系统支持的各种制品类型。
19
+ """
20
+
21
+ dataset = "dataset" # 数据集类型
22
+ model = "model" # 模型类型
23
+ metrics = "metrics" # 指标类型
24
+ log = "log" # 日志类型
25
+ checkpoint = "checkpoint" # 检查点类型
26
+ image = "image" # 图像类型
27
+ prediction = "prediction" # 预测结果类型
28
+ other = "other" # 其他类型
29
+
30
+
31
+ class CreateArtifactsReq(BaseModel):
32
+ """创建制品请求模型
33
+
34
+ 用于向服务器发送创建制品的请求。
35
+ """
36
+
37
+ entity_id: str
38
+ """实体ID,通常是运行ID,用于关联制品与特定运行"""
39
+
40
+ entity_type: ArtifactType = ArtifactType.other
41
+ """制品类型,指定制品的类型,默认为other"""
42
+
43
+ src_path: str
44
+ """源路径,制品在系统中的路径标识"""
45
+
46
+ is_dir: bool = False
47
+ """是否为目录,True表示制品是一个目录,False表示是单个文件"""
48
+
49
+
50
+ class CreateArtifactsResponseData(BaseModel):
51
+ """创建制品响应数据模型
52
+
53
+ 服务器创建制品后返回的数据。
54
+ """
55
+
56
+ id: int # 制品ID
57
+ s3_path: str # S3存储路径
58
+
59
+
60
+ class CreateArtifactsResponseModel(BaseModel):
61
+ """创建制品响应模型
62
+
63
+ 服务器对创建制品请求的完整响应。
64
+ """
65
+
66
+ code: int # 响应码,0表示成功
67
+ msg: str = "" # 响应消息
68
+ data: CreateArtifactsResponseData | None = None # 响应数据
69
+
70
+
71
+ class CreatEvalReq(BaseModel):
72
+ """创建评估请求模型
73
+
74
+ 用于创建模型评估的请求。
75
+ """
76
+
77
+ dataset_id: int # 数据集ID
78
+ dataset_version_id: int # 数据集版本ID
79
+ prediction_artifact_path: str # 预测结果制品路径
80
+ evaled_artifact_path: str # 评估结果制品路径
81
+ run_id: str # 运行ID
82
+ user_id: int # 用户ID
83
+ report: dict = {} # 评估报告
84
+
85
+
86
+ class ArtifactResp(BaseModel):
87
+ """制品响应模型
88
+
89
+ 表示一个制品的详细信息。
90
+ """
91
+
92
+ id: int # 制品ID
93
+ entity_type: str # 实体类型
94
+ entity_id: str # 实体ID
95
+ src_path: str # 源路径
96
+ s3_path: str # S3存储路径
97
+ is_dir: bool # 是否为目录
98
+
99
+
100
+ class ArtifactRespData(BaseModel):
101
+ """制品响应数据模型
102
+
103
+ 包含分页信息和制品列表的响应数据。
104
+ """
105
+
106
+ total: int # 总记录数
107
+ page_size: int # 每页大小
108
+ page_num: int # 页码
109
+ data: List[ArtifactResp] # 制品列表
110
+
111
+
112
+ class ArtifactRespModel(BaseModel):
113
+ """制品响应模型
114
+
115
+ 服务器对获取制品请求的完整响应。
116
+ """
117
+
118
+ code: int # 响应码,0表示成功
119
+ msg: str = "" # 响应消息
120
+ data: ArtifactRespData # 响应数据
121
+
122
+
123
+ # 无限大的页面大小,用于一次性获取所有制品
124
+ InfinityPageSize = 10000 * 100
125
+
126
+
127
+ class StsResp(BaseModel):
128
+ """STS临时凭证响应模型
129
+
130
+ 包含访问S3存储所需的临时凭证信息。
131
+ """
132
+
133
+ access_key_id: Optional[str] = None # 访问密钥ID
134
+ secret_access_key: Optional[str] = None # 秘密访问密钥
135
+ session_token: Optional[str] = None # 会话令牌
136
+ expiration: Optional[int] = None # 过期时间
137
+ endpoint: Optional[str] = None # 端点URL
@@ -0,0 +1,13 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Generic, Optional, TypeVar
4
+
5
+ from pydantic import BaseModel
6
+
7
+ T = TypeVar("T")
8
+
9
+
10
+ class APIWrapper(BaseModel, Generic[T]):
11
+ code: int
12
+ msg: Optional[str] = None
13
+ data: Optional[T]
@@ -0,0 +1,99 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import List, Optional
4
+
5
+ from pydantic import BaseModel, Field
6
+
7
+
8
+ class CreateDatasetRequest(BaseModel):
9
+ name: str
10
+ description: str
11
+ tags: List[int]
12
+ cover_img: Optional[str] = Field(None, alias="cover_img")
13
+ create_by: Optional[int] = Field(None, alias="create_by")
14
+ is_private: Optional[bool] = Field(None, alias="is_private")
15
+ access_user_ids: Optional[List[int]] = Field(None, alias="access_user_ids")
16
+
17
+
18
+ class CreateDatasetResponse(BaseModel):
19
+ id: int = Field(alias="id")
20
+
21
+
22
+ class DatasetVersionBase(BaseModel):
23
+ id: int
24
+ version: int
25
+ status: int
26
+ parquet_index_path: Optional[str] = Field(None, alias="parquet_index_path")
27
+ data_count: int = Field(alias="data_count")
28
+
29
+
30
+ class DatasetDetail(BaseModel):
31
+ id: int
32
+ name: str
33
+ description: str
34
+ cover_img: Optional[str] = Field(None, alias="cover_img")
35
+ created_at: int = Field(alias="created_at")
36
+ updated_at: int = Field(alias="update_at")
37
+ user_id: int = Field(alias="user_id")
38
+ username: str
39
+ tags: List[int]
40
+ access_user_ids: Optional[List[int]] = Field(None, alias="access_user_ids")
41
+ is_private: Optional[bool] = Field(None, alias="is_private")
42
+ versions: List[DatasetVersionBase]
43
+
44
+
45
+ class ExtInfo(BaseModel):
46
+ rec_file_path: Optional[str] = Field(None, alias="rec_file_path")
47
+ idx_file_path: Optional[str] = Field(None, alias="idx_file_path")
48
+ json_file_path: Optional[str] = Field(None, alias="json_file_path")
49
+ image_dir_path: Optional[str] = Field(None, alias="image_dir_path")
50
+
51
+
52
+ class CreateDatasetVersionRequest(BaseModel):
53
+ upload_path: str = Field(alias="upload_path")
54
+ description: Optional[str] = None
55
+ dataset_id: int = Field(alias="dataset_id")
56
+ object_cnt: Optional[int] = Field(None, alias="object_cnt")
57
+ data_size: Optional[int] = Field(None, alias="data_size")
58
+ create_by: Optional[int] = Field(None, alias="create_by")
59
+ upload_type: Optional[int] = Field(4, alias="upload_type")
60
+ ext_info: Optional[ExtInfo] = Field(None, alias="ext_info")
61
+
62
+
63
+ class CreateDatasetVersionResponse(BaseModel):
64
+ id: int = Field(alias="id")
65
+
66
+
67
+ class UploadDatasetVersionRequest(BaseModel):
68
+ upload_path: str = Field(alias="upload_path")
69
+ upload_type: int = Field(alias="upload_type")
70
+ dataset_id: int = Field(alias="dataset_id")
71
+ parent_version_id: Optional[int] = Field(None, alias="parent_version_id")
72
+ description: Optional[str] = Field(None, alias="description")
73
+
74
+
75
+ class UploadDatasetVersionResponse(BaseModel):
76
+ id: int = Field(alias="id")
77
+
78
+
79
+ class DatasetVersionDetail(BaseModel):
80
+ id: int
81
+ version: int
82
+ dataset_id: int = Field(alias="dataset_id")
83
+ upload_path: str = Field(alias="upload_path")
84
+ upload_type: int = Field(alias="upload_type")
85
+ parent_version_id: Optional[int] = Field(None, alias="parent_version_id")
86
+ description: Optional[str] = None
87
+ status: int
88
+ message: Optional[str] = None
89
+ created_at: int = Field(alias="created_at")
90
+ user_id: int = Field(alias="user_id")
91
+ data_size: Optional[int] = Field(None, alias="data_size")
92
+ data_count: Optional[int] = Field(None, alias="data_count")
93
+ parquet_index_path: Optional[str] = Field(None, alias="parquet_index_path")
94
+ ext_info: Optional[ExtInfo] = Field(None, alias="ext_info")
95
+
96
+
97
+ class FileUploadData(BaseModel):
98
+ path: str
99
+ url: str
@@ -0,0 +1,28 @@
1
+ # !/usr/bin/env python
2
+ # -*-coding:utf-8 -*-
3
+
4
+ from __future__ import annotations
5
+
6
+ from typing import List, Optional, Any
7
+
8
+ from pydantic import BaseModel
9
+
10
+
11
+ class Document(BaseModel):
12
+ id: int
13
+ title: str
14
+ type: int
15
+ edit_time: int
16
+ need_update: bool
17
+ content: str
18
+ username: str
19
+ user_id: int
20
+ created_at: int
21
+ comments: Optional[Any] = None
22
+
23
+
24
+ class GetDocumentsResponse(BaseModel):
25
+ total: int
26
+ page_size: int
27
+ page_num: int
28
+ data: List[Document]
@@ -0,0 +1,31 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Optional
4
+
5
+ from pydantic import BaseModel, Field
6
+
7
+
8
+ class Stats(BaseModel):
9
+ """标注统计信息"""
10
+
11
+ total_annotations: int = Field(alias="total_annotations")
12
+ labeled_annotations: int = Field(alias="labeled_annotations")
13
+ total_labels: int = Field(alias="total_labels")
14
+ total_reviews: Optional[int] = Field(None, alias="total_reviews")
15
+ unlabeled_reviews: Optional[int] = Field(None, alias="unlabeled_reviews")
16
+ labeled_reviews: Optional[int] = Field(None, alias="labeled_reviews")
17
+ accepted_count: Optional[int] = Field(None, alias="accepted_count")
18
+ rejected_count: Optional[int] = Field(None, alias="rejected_count")
19
+
20
+
21
+ class GetGlobalStatsResponse(BaseModel):
22
+ """
23
+ 标注统计概况
24
+ """
25
+
26
+ global_stats: Stats = Field(alias="global_stats")
27
+ valid_ten_percent: bool = Field(alias="valid_ten_percent")
28
+ valid_fifty_percent: bool = Field(alias="valid_fifty_percent")
29
+ valid_hundred_percent: bool = Field(alias="valid_hundred_percent")
30
+ data_exported_count: int = Field(alias="data_exported_count")
31
+ exported_dataset_name: str = Field(alias="exported_dataset_name")