intellif-aihub 0.1.49__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.
- intellif_aihub-0.1.49/LICENSE +201 -0
- intellif_aihub-0.1.49/PKG-INFO +123 -0
- intellif_aihub-0.1.49/README.md +100 -0
- intellif_aihub-0.1.49/pyproject.toml +72 -0
- intellif_aihub-0.1.49/setup.cfg +4 -0
- intellif_aihub-0.1.49/src/aihub/__init__.py +1 -0
- intellif_aihub-0.1.49/src/aihub/cli/__init__.py +1 -0
- intellif_aihub-0.1.49/src/aihub/cli/__main__.py +8 -0
- intellif_aihub-0.1.49/src/aihub/cli/config.py +136 -0
- intellif_aihub-0.1.49/src/aihub/cli/main.py +295 -0
- intellif_aihub-0.1.49/src/aihub/cli/model_center.py +355 -0
- intellif_aihub-0.1.49/src/aihub/client.py +154 -0
- intellif_aihub-0.1.49/src/aihub/exceptions.py +130 -0
- intellif_aihub-0.1.49/src/aihub/models/__init__.py +0 -0
- intellif_aihub-0.1.49/src/aihub/models/artifact.py +110 -0
- intellif_aihub-0.1.49/src/aihub/models/common.py +13 -0
- intellif_aihub-0.1.49/src/aihub/models/data_warehouse.py +95 -0
- intellif_aihub-0.1.49/src/aihub/models/dataset_management.py +240 -0
- intellif_aihub-0.1.49/src/aihub/models/document_center.py +36 -0
- intellif_aihub-0.1.49/src/aihub/models/eval.py +283 -0
- intellif_aihub-0.1.49/src/aihub/models/labelfree.py +47 -0
- intellif_aihub-0.1.49/src/aihub/models/model_center.py +279 -0
- intellif_aihub-0.1.49/src/aihub/models/model_deployment.py +163 -0
- intellif_aihub-0.1.49/src/aihub/models/model_training_platform.py +294 -0
- intellif_aihub-0.1.49/src/aihub/models/notebook_management.py +167 -0
- intellif_aihub-0.1.49/src/aihub/models/quota_schedule_management.py +285 -0
- intellif_aihub-0.1.49/src/aihub/models/tag_resource_management.py +78 -0
- intellif_aihub-0.1.49/src/aihub/models/task_center.py +153 -0
- intellif_aihub-0.1.49/src/aihub/models/user_system.py +335 -0
- intellif_aihub-0.1.49/src/aihub/models/workflow_center.py +737 -0
- intellif_aihub-0.1.49/src/aihub/services/__init__.py +0 -0
- intellif_aihub-0.1.49/src/aihub/services/artifact.py +362 -0
- intellif_aihub-0.1.49/src/aihub/services/data_warehouse.py +111 -0
- intellif_aihub-0.1.49/src/aihub/services/dataset_management.py +673 -0
- intellif_aihub-0.1.49/src/aihub/services/document_center.py +67 -0
- intellif_aihub-0.1.49/src/aihub/services/eval.py +524 -0
- intellif_aihub-0.1.49/src/aihub/services/labelfree.py +59 -0
- intellif_aihub-0.1.49/src/aihub/services/model_center.py +548 -0
- intellif_aihub-0.1.49/src/aihub/services/model_deployment.py +238 -0
- intellif_aihub-0.1.49/src/aihub/services/model_training_platform.py +333 -0
- intellif_aihub-0.1.49/src/aihub/services/notebook_management.py +283 -0
- intellif_aihub-0.1.49/src/aihub/services/quota_schedule_management.py +325 -0
- intellif_aihub-0.1.49/src/aihub/services/reporter.py +20 -0
- intellif_aihub-0.1.49/src/aihub/services/tag_resource_management.py +120 -0
- intellif_aihub-0.1.49/src/aihub/services/task_center.py +269 -0
- intellif_aihub-0.1.49/src/aihub/services/user_system.py +741 -0
- intellif_aihub-0.1.49/src/aihub/services/workflow_center.py +1085 -0
- intellif_aihub-0.1.49/src/aihub/utils/__init__.py +0 -0
- intellif_aihub-0.1.49/src/aihub/utils/di.py +337 -0
- intellif_aihub-0.1.49/src/aihub/utils/download.py +73 -0
- intellif_aihub-0.1.49/src/aihub/utils/http.py +20 -0
- intellif_aihub-0.1.49/src/aihub/utils/s3.py +120 -0
- intellif_aihub-0.1.49/src/intellif_aihub.egg-info/PKG-INFO +123 -0
- intellif_aihub-0.1.49/src/intellif_aihub.egg-info/SOURCES.txt +73 -0
- intellif_aihub-0.1.49/src/intellif_aihub.egg-info/dependency_links.txt +1 -0
- intellif_aihub-0.1.49/src/intellif_aihub.egg-info/entry_points.txt +2 -0
- intellif_aihub-0.1.49/src/intellif_aihub.egg-info/requires.txt +9 -0
- intellif_aihub-0.1.49/src/intellif_aihub.egg-info/top_level.txt +1 -0
- intellif_aihub-0.1.49/tests/test_artifact.py +31 -0
- intellif_aihub-0.1.49/tests/test_data_warehouse.py +31 -0
- intellif_aihub-0.1.49/tests/test_dataset_management.py +136 -0
- intellif_aihub-0.1.49/tests/test_di.py +160 -0
- intellif_aihub-0.1.49/tests/test_document_center.py +200 -0
- intellif_aihub-0.1.49/tests/test_eval.py +959 -0
- intellif_aihub-0.1.49/tests/test_labelfree.py +15 -0
- intellif_aihub-0.1.49/tests/test_model_center.py +108 -0
- intellif_aihub-0.1.49/tests/test_model_deployment.py +164 -0
- intellif_aihub-0.1.49/tests/test_model_training_platform.py +79 -0
- intellif_aihub-0.1.49/tests/test_notebook_management.py +65 -0
- intellif_aihub-0.1.49/tests/test_quota_schedule_management.py +76 -0
- intellif_aihub-0.1.49/tests/test_s3.py +18 -0
- intellif_aihub-0.1.49/tests/test_tag_resource_management.py +18 -0
- intellif_aihub-0.1.49/tests/test_task_center.py +80 -0
- intellif_aihub-0.1.49/tests/test_user_system.py +123 -0
- intellif_aihub-0.1.49/tests/test_workflow_center.py +326 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: intellif-aihub
|
|
3
|
+
Version: 0.1.49
|
|
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.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: httpx>=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>=21.0.0
|
|
17
|
+
Requires-Dist: tqdm<5.0,>=4.66
|
|
18
|
+
Requires-Dist: loguru>=0.7.3
|
|
19
|
+
Requires-Dist: minio==7.2.7
|
|
20
|
+
Requires-Dist: requests>=2.32.4
|
|
21
|
+
Requires-Dist: typer>=0.12.0
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# Intellif AI-Hub SDK
|
|
25
|
+
|
|
26
|
+
**Intellif AI-Hub** 官方 Python 开发包。
|
|
27
|
+
一个 `Client` 对象即可完成数据集管理、标注统计、任务中心等常见操作,无需手写 HTTP 请求。
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
aihub_sdk/
|
|
31
|
+
├─ pyproject.toml
|
|
32
|
+
├─ requirements.txt
|
|
33
|
+
├─ src/aihub/
|
|
34
|
+
│ ├─ client.py
|
|
35
|
+
│ ├─ exceptions.py
|
|
36
|
+
│ ├─ models/…
|
|
37
|
+
│ ├─ services/…
|
|
38
|
+
│ └─ utils/…
|
|
39
|
+
└─ tests/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 💻 安装
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# PyPI 安装
|
|
48
|
+
pip install intellif-aihub
|
|
49
|
+
# 运行环境:Python ≥ 3.9
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 🚀 快速上手
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from aihub import Client
|
|
58
|
+
|
|
59
|
+
BASE = "http://192.168.13.160:30021"
|
|
60
|
+
TOKEN = "eyJhb..." # 或设置环境变量:export AI_HUB_TOKEN=...
|
|
61
|
+
|
|
62
|
+
with Client(base_url=BASE, token=TOKEN) as cli:
|
|
63
|
+
# 1. 同时创建数据集 + 版本(上传本地 ZIP)
|
|
64
|
+
ds_id, ver_id, tag = cli.dataset_management.create_dataset_and_version(
|
|
65
|
+
dataset_name="cats",
|
|
66
|
+
is_local_upload=True,
|
|
67
|
+
local_file_path="/data/cats.zip",
|
|
68
|
+
version_description="first release",
|
|
69
|
+
)
|
|
70
|
+
print("数据集标识:", tag) # 输出:cats/V1
|
|
71
|
+
|
|
72
|
+
# 2. 下载数据集
|
|
73
|
+
cli.dataset_management.run_download(
|
|
74
|
+
dataset_version_name=tag,
|
|
75
|
+
local_dir="/tmp/cats",
|
|
76
|
+
worker=8,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# 3. 获取标注平台全局统计
|
|
80
|
+
stats = cli.labelfree.get_project_global_stats("cat-project")
|
|
81
|
+
print("总标注数:", stats.global_stats.total_annotations)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🌍 环境变量
|
|
87
|
+
|
|
88
|
+
| 变量 | 作用 | 默认值 |
|
|
89
|
+
|----------------------------|-------------------------------------------|----------------------------------|
|
|
90
|
+
| `AI_HUB_TOKEN` | API 鉴权 Token(可不在 `Client` 中显式传入) | – |
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 📦 打包 & 发布
|
|
95
|
+
|
|
96
|
+
项目采用 PEP 517 / `pyproject.toml` 构建规范。
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# 1️⃣ 构建 wheel / sdist
|
|
100
|
+
python -m pip install --upgrade build
|
|
101
|
+
python -m build # 生成 dist/*.whl dist/*.tar.gz
|
|
102
|
+
|
|
103
|
+
# 2️⃣ 本地验证
|
|
104
|
+
pip install --force-reinstall dist/*.whl
|
|
105
|
+
python -c "import aihub, sys; print('SDK 版本:', aihub.__version__)"
|
|
106
|
+
|
|
107
|
+
# 3️⃣ 发布到 PyPI 或私有仓库
|
|
108
|
+
python -m pip install --upgrade twine
|
|
109
|
+
twine upload dist/*
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
文档调试:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
mkdocs serve
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
构建文档镜像:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
docker build -t 192.168.14.129:80/library/aihub/sdk_doc:latest -f doc.Dockerfile .
|
|
122
|
+
```
|
|
123
|
+
---
|
|
@@ -0,0 +1,100 @@
|
|
|
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.9
|
|
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
|
+
文档调试:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
mkdocs serve
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
构建文档镜像:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
docker build -t 192.168.14.129:80/library/aihub/sdk_doc:latest -f doc.Dockerfile .
|
|
99
|
+
```
|
|
100
|
+
---
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "intellif-aihub"
|
|
3
|
+
version = "0.1.49"
|
|
4
|
+
description = "Intellif AI-hub SDK."
|
|
5
|
+
readme = {file = "README.md", content-type = "text/markdown"}
|
|
6
|
+
requires-python = ">=3.9"
|
|
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",
|
|
16
|
+
"pydantic>=2.5.3,<3.0",
|
|
17
|
+
"typing-extensions>=4.13.2,<5.0",
|
|
18
|
+
"pyarrow>=21.0.0",
|
|
19
|
+
"tqdm>=4.66,<5.0",
|
|
20
|
+
"loguru>=0.7.3",
|
|
21
|
+
"minio==7.2.7",
|
|
22
|
+
"requests>=2.32.4",
|
|
23
|
+
"typer>=0.12.0",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
aihub = "aihub.cli.main:app"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
[build-system]
|
|
31
|
+
requires = ["setuptools>=61", "wheel"]
|
|
32
|
+
build-backend = "setuptools.build_meta"
|
|
33
|
+
|
|
34
|
+
[tool.setuptools]
|
|
35
|
+
package-dir = {"" = "src"}
|
|
36
|
+
include-package-data = true
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
where = ["src"]
|
|
40
|
+
|
|
41
|
+
[[tool.uv.index]]
|
|
42
|
+
name = "tsinghua"
|
|
43
|
+
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
44
|
+
default = true
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
dev = [
|
|
48
|
+
"black>=24.8.0",
|
|
49
|
+
"griffe-pydantic; python_version>='3.9'",
|
|
50
|
+
"mkdocs-glightbox>=0.4.0",
|
|
51
|
+
"mkdocs-material>=9.6.15",
|
|
52
|
+
"mkdocstrings-python>=1.11.1",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
[tool.black]
|
|
57
|
+
line-length = 120
|
|
58
|
+
target-version = ["py39", "py310"]
|
|
59
|
+
include = '\.pyi?$'
|
|
60
|
+
exclude = '''
|
|
61
|
+
/(
|
|
62
|
+
\.git
|
|
63
|
+
| \.hg
|
|
64
|
+
| \.mypy_cache
|
|
65
|
+
| \.tox
|
|
66
|
+
| \.venv
|
|
67
|
+
| _build
|
|
68
|
+
| buck-out
|
|
69
|
+
| build
|
|
70
|
+
| dist
|
|
71
|
+
)/
|
|
72
|
+
'''
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.49"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# CLI module for aihub SDK
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""CLI 配置管理模块"""
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Dict, Optional
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ConfigError(Exception):
|
|
12
|
+
"""配置相关错误"""
|
|
13
|
+
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Config:
|
|
18
|
+
"""CLI 配置管理类"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, config_file: Optional[str] = None):
|
|
21
|
+
"""初始化配置管理
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
config_file: 配置文件路径,如果不提供则使用默认路径
|
|
25
|
+
"""
|
|
26
|
+
if config_file:
|
|
27
|
+
self.config_file = Path(config_file)
|
|
28
|
+
else:
|
|
29
|
+
# 默认配置文件路径:~/.aihub/config.json
|
|
30
|
+
config_dir = Path.home() / ".aihub"
|
|
31
|
+
config_dir.mkdir(exist_ok=True)
|
|
32
|
+
self.config_file = config_dir / "config.json"
|
|
33
|
+
|
|
34
|
+
def _load_config(self) -> Dict[str, str]:
|
|
35
|
+
"""加载配置文件"""
|
|
36
|
+
if not self.config_file.exists():
|
|
37
|
+
return {}
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
with open(self.config_file, "r", encoding="utf-8") as f:
|
|
41
|
+
return json.load(f)
|
|
42
|
+
except (json.JSONDecodeError, IOError) as e:
|
|
43
|
+
raise ConfigError(f"无法读取配置文件 {self.config_file}: {e}")
|
|
44
|
+
|
|
45
|
+
def _save_config(self, config: Dict[str, str]) -> None:
|
|
46
|
+
"""保存配置文件"""
|
|
47
|
+
try:
|
|
48
|
+
# 确保目录存在
|
|
49
|
+
self.config_file.parent.mkdir(parents=True, exist_ok=True)
|
|
50
|
+
|
|
51
|
+
with open(self.config_file, "w", encoding="utf-8") as f:
|
|
52
|
+
json.dump(config, f, indent=2, ensure_ascii=False)
|
|
53
|
+
except IOError as e:
|
|
54
|
+
raise ConfigError(f"无法写入配置文件 {self.config_file}: {e}")
|
|
55
|
+
|
|
56
|
+
def get(self, key: str) -> Optional[str]:
|
|
57
|
+
"""获取配置项
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
key: 配置项名称
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
配置项值,如果不存在则返回 None
|
|
64
|
+
"""
|
|
65
|
+
# 优先从环境变量获取
|
|
66
|
+
env_key = f"AIHUB_{key.upper()}"
|
|
67
|
+
env_value = os.getenv(env_key)
|
|
68
|
+
if env_value:
|
|
69
|
+
return env_value
|
|
70
|
+
|
|
71
|
+
# 从配置文件获取
|
|
72
|
+
config = self._load_config()
|
|
73
|
+
return config.get(key)
|
|
74
|
+
|
|
75
|
+
def set(self, key: str, value: str) -> None:
|
|
76
|
+
"""设置配置项
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
key: 配置项名称
|
|
80
|
+
value: 配置项值
|
|
81
|
+
"""
|
|
82
|
+
config = self._load_config()
|
|
83
|
+
config[key] = value
|
|
84
|
+
self._save_config(config)
|
|
85
|
+
|
|
86
|
+
def list_all(self) -> Dict[str, str]:
|
|
87
|
+
"""列出所有配置项
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
所有配置项的字典
|
|
91
|
+
"""
|
|
92
|
+
config = self._load_config()
|
|
93
|
+
|
|
94
|
+
# 合并环境变量
|
|
95
|
+
for key in ["base_url", "token"]:
|
|
96
|
+
env_key = f"AIHUB_{key.upper()}"
|
|
97
|
+
env_value = os.getenv(env_key)
|
|
98
|
+
if env_value:
|
|
99
|
+
config[key] = env_value
|
|
100
|
+
|
|
101
|
+
return config
|
|
102
|
+
|
|
103
|
+
def delete(self, key: str) -> bool:
|
|
104
|
+
"""删除配置项
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
key: 配置项名称
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
是否成功删除
|
|
111
|
+
"""
|
|
112
|
+
config = self._load_config()
|
|
113
|
+
if key in config:
|
|
114
|
+
del config[key]
|
|
115
|
+
self._save_config(config)
|
|
116
|
+
return True
|
|
117
|
+
return False
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# 全局配置实例
|
|
121
|
+
_config_instance: Optional[Config] = None
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def get_config(config_file: Optional[str] = None) -> Config:
|
|
125
|
+
"""获取配置实例(单例模式)
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
config_file: 配置文件路径
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
配置实例
|
|
132
|
+
"""
|
|
133
|
+
global _config_instance
|
|
134
|
+
if _config_instance is None:
|
|
135
|
+
_config_instance = Config(config_file)
|
|
136
|
+
return _config_instance
|