gsnet-sdk 0.1.0__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.
- gsnet_sdk-0.1.0/PKG-INFO +120 -0
- gsnet_sdk-0.1.0/README.md +95 -0
- gsnet_sdk-0.1.0/pyproject.toml +8 -0
- gsnet_sdk-0.1.0/setup.cfg +4 -0
- gsnet_sdk-0.1.0/setup.py +28 -0
- gsnet_sdk-0.1.0/src/gsnet/__init__.py +32 -0
- gsnet_sdk-0.1.0/src/gsnet/_dataclass.py +404 -0
- gsnet_sdk-0.1.0/src/gsnet/_exceptions.py +273 -0
- gsnet_sdk-0.1.0/src/gsnet/_file.py +300 -0
- gsnet_sdk-0.1.0/src/gsnet/_login.py +183 -0
- gsnet_sdk-0.1.0/src/gsnet/_session.py +319 -0
- gsnet_sdk-0.1.0/src/gsnet/_tqdm.py +141 -0
- gsnet_sdk-0.1.0/src/gsnet/adaptor/__init__.py +0 -0
- gsnet_sdk-0.1.0/src/gsnet/adaptor/om_hub/__init__.py +3 -0
- gsnet_sdk-0.1.0/src/gsnet/adaptor/om_hub/download.py +155 -0
- gsnet_sdk-0.1.0/src/gsnet/adaptor/om_hub/file_manager.py +382 -0
- gsnet_sdk-0.1.0/src/gsnet/adaptor/om_hub/upload.py +137 -0
- gsnet_sdk-0.1.0/src/gsnet/adaptor/om_hub/utils.py +50 -0
- gsnet_sdk-0.1.0/src/gsnet/api.py +820 -0
- gsnet_sdk-0.1.0/src/gsnet/commands/__init__.py +13 -0
- gsnet_sdk-0.1.0/src/gsnet/commands/dataset.py +222 -0
- gsnet_sdk-0.1.0/src/gsnet/commands/dataset_deprecated.py +203 -0
- gsnet_sdk-0.1.0/src/gsnet/commands/gsnet_cli.py +47 -0
- gsnet_sdk-0.1.0/src/gsnet/commands/model.py +220 -0
- gsnet_sdk-0.1.0/src/gsnet/commands/model_deprecated.py +235 -0
- gsnet_sdk-0.1.0/src/gsnet/commands/user.py +121 -0
- gsnet_sdk-0.1.0/src/gsnet/constants.py +59 -0
- gsnet_sdk-0.1.0/src/gsnet/downloader.py +361 -0
- gsnet_sdk-0.1.0/src/gsnet/log.py +72 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/__init__.py +2 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/api.py +0 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/constants.py +105 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/controlled/__init__.py +51 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/controlled/crypto.py +145 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/controlled/exceptions.py +41 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/controlled/header.py +29 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/controlled/kms_client.py +183 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/controlled/models.py +145 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/core/__init__.py +1 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/core/auth.py +58 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/core/dataclass.py +70 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/core/router.py +324 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/core/session.py +156 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/plugins/__init__.py +0 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/plugins/errors.py +211 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/plugins/log.py +47 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/plugins/progress.py +585 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/sdk.py +126 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/service/__init__.py +0 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/service/downloader.py +809 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/service/file_manager.py +522 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/service/notification.py +81 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/service/uploader.py +820 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/service/validators.py +47 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/utils/__init__.py +0 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/utils/deprecate.py +18 -0
- gsnet_sdk-0.1.0/src/gsnet/refactor/utils/utils.py +13 -0
- gsnet_sdk-0.1.0/src/gsnet/uploader.py +340 -0
- gsnet_sdk-0.1.0/src/gsnet/utils.py +129 -0
- gsnet_sdk-0.1.0/src/gsnet_sdk.egg-info/PKG-INFO +120 -0
- gsnet_sdk-0.1.0/src/gsnet_sdk.egg-info/SOURCES.txt +63 -0
- gsnet_sdk-0.1.0/src/gsnet_sdk.egg-info/dependency_links.txt +1 -0
- gsnet_sdk-0.1.0/src/gsnet_sdk.egg-info/entry_points.txt +2 -0
- gsnet_sdk-0.1.0/src/gsnet_sdk.egg-info/requires.txt +9 -0
- gsnet_sdk-0.1.0/src/gsnet_sdk.egg-info/top_level.txt +1 -0
gsnet_sdk-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: gsnet-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK and CLI for the GSnet platform
|
|
5
|
+
Home-page: https://gsnet.pcl.ac.cn/OpenIOSSG/gsnet-sdk
|
|
6
|
+
Author: chenzh05
|
|
7
|
+
Author-email: chenzh.ds@outlook.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: requests
|
|
17
|
+
Requires-Dist: tqdm
|
|
18
|
+
Requires-Dist: deprecated
|
|
19
|
+
Requires-Dist: pwinput
|
|
20
|
+
Requires-Dist: httpx
|
|
21
|
+
Requires-Dist: rich
|
|
22
|
+
Requires-Dist: aiofiles
|
|
23
|
+
Requires-Dist: h2
|
|
24
|
+
Requires-Dist: cryptography>=42.0.0
|
|
25
|
+
|
|
26
|
+
# GSnet
|
|
27
|
+
|
|
28
|
+
> PYPI package for GSnet平台。
|
|
29
|
+
|
|
30
|
+
## 安装
|
|
31
|
+
|
|
32
|
+
_适配 python3.8 及以上版本_
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install gsnet-sdk
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
PyPI 发布名为 `gsnet-sdk`,Python 导入名和命令行名称均为 `gsnet`:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import gsnet
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
gsnet --help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
首次发布版本为 `0.1.0`,后续版本规则与发布步骤见 [版本与发布指南](doc/version-guide.md)。
|
|
49
|
+
|
|
50
|
+
## 功能介绍
|
|
51
|
+
|
|
52
|
+
- 支持进行本地上传与下载文件到GSnet平台
|
|
53
|
+
- 支持代码调用函数,可在本地Python脚本或notebook使用;支持终端命令行,方便在服务器上使用。
|
|
54
|
+
- 具体请参考 [帮助文档](doc/sdk.md)
|
|
55
|
+
|
|
56
|
+
## 使用示例
|
|
57
|
+
|
|
58
|
+
以 [MNIST 示例数据集](https://gsnet.pcl.ac.cn/datasets/detail/OpenIOSSG/MnistDataset_mindspore)为例。
|
|
59
|
+
|
|
60
|
+
- `python` 代码中下载(可直接复制到 python 文件或 notebook 中运行)
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from gsnet import gsnet_download_file
|
|
64
|
+
|
|
65
|
+
# 下载整个数据集;只下载部分文件时用 filename(需带远端子目录,多个文件传列表)
|
|
66
|
+
# 下载单个文件加上:filename="train/train-images-idx3-ubyte"
|
|
67
|
+
gsnet_download_file(
|
|
68
|
+
repo_id="OpenIOSSG/MnistDataset_mindspore", # 必填:拥有者/数据集名
|
|
69
|
+
local_dir="./downloads", # 选填:本地保存目录,默认当前目录下的 `MnistDataset_mindspore/`
|
|
70
|
+
#filename="train/train-images-idx3-ubyte" # 选填:下载指定文件,不填默认下载整个数据集
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- 上述代码调用对应的终端命令(可直接复制到终端命令行中运行)
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
gsnet dataset download OpenIOSSG/MnistDataset_mindspore --local_dir ./downloads
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- 执行结果:实时显示整体进度与各文件进度,并按远端目录结构保存到本地
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
数据集 `OpenIOSSG/MnistDataset_mindspore` 获取文件列表中……
|
|
84
|
+
- 云端共找到 5 个文件。
|
|
85
|
+
- 开始下载 5 个文件……
|
|
86
|
+
- 本地保存目录 D:/MnistDataset_mindspore/downloads
|
|
87
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
88
|
+
│ 10 workers | 已处理文件: 5/5 -------------- 100% 60.1MiB/s 52.4MiB 0:00:00 │
|
|
89
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
90
|
+
README.md -------------------- 100% ? 193bytes 0:00:00
|
|
91
|
+
(…)t10k-images-idx3-ubyte -------------------- 100% 44.8MiB/s 7.5MiB 0:00:00
|
|
92
|
+
(…)t10k-labels-idx1-ubyte -------------------- 100% ? 9.8KiB 0:00:00
|
|
93
|
+
(…)rain-images-idx3-ubyte -------------------- 100% 90.2MiB/s 44.9MiB 0:00:00
|
|
94
|
+
(…)rain-labels-idx1-ubyte -------------------- 100% 55.7MiB/s 58.6KiB 0:00:00
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
下载完成后的本地目录结构(与远端 `test/`、`train/` 一致):
|
|
98
|
+
|
|
99
|
+
```text
|
|
100
|
+
downloads/
|
|
101
|
+
├── README.md 193 B
|
|
102
|
+
├── test/
|
|
103
|
+
│ ├── t10k-images-idx3-ubyte 7.84 MB
|
|
104
|
+
│ └── t10k-labels-idx1-ubyte 9.78 KB
|
|
105
|
+
└── train/
|
|
106
|
+
├── train-images-idx3-ubyte 44.86 MB
|
|
107
|
+
└── train-labels-idx1-ubyte 58.60 KB
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- 只下载部分文件:`-f`
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# 单个文件 -> ./MnistDataset_mindspore/train/train-images-idx3-ubyte
|
|
114
|
+
gsnet dataset download OpenIOSSG/MnistDataset_mindspore -f train/train-images-idx3-ubyte
|
|
115
|
+
|
|
116
|
+
# 多个文件(逗号隔开) -> ./MnistDataset_mindspore/test/t10k-images-idx3-ubyte 与 .../test/t10k-labels-idx1-ubyte
|
|
117
|
+
gsnet dataset download OpenIOSSG/MnistDataset_mindspore -f test/t10k-images-idx3-ubyte,test/t10k-labels-idx1-ubyte
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- 更多使用指南(上传、受控数据集、权限与常见报错等)请参考 [帮助文档](doc/sdk.md)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# GSnet
|
|
2
|
+
|
|
3
|
+
> PYPI package for GSnet平台。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
_适配 python3.8 及以上版本_
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install gsnet-sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
PyPI 发布名为 `gsnet-sdk`,Python 导入名和命令行名称均为 `gsnet`:
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import gsnet
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
gsnet --help
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
首次发布版本为 `0.1.0`,后续版本规则与发布步骤见 [版本与发布指南](doc/version-guide.md)。
|
|
24
|
+
|
|
25
|
+
## 功能介绍
|
|
26
|
+
|
|
27
|
+
- 支持进行本地上传与下载文件到GSnet平台
|
|
28
|
+
- 支持代码调用函数,可在本地Python脚本或notebook使用;支持终端命令行,方便在服务器上使用。
|
|
29
|
+
- 具体请参考 [帮助文档](doc/sdk.md)
|
|
30
|
+
|
|
31
|
+
## 使用示例
|
|
32
|
+
|
|
33
|
+
以 [MNIST 示例数据集](https://gsnet.pcl.ac.cn/datasets/detail/OpenIOSSG/MnistDataset_mindspore)为例。
|
|
34
|
+
|
|
35
|
+
- `python` 代码中下载(可直接复制到 python 文件或 notebook 中运行)
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from gsnet import gsnet_download_file
|
|
39
|
+
|
|
40
|
+
# 下载整个数据集;只下载部分文件时用 filename(需带远端子目录,多个文件传列表)
|
|
41
|
+
# 下载单个文件加上:filename="train/train-images-idx3-ubyte"
|
|
42
|
+
gsnet_download_file(
|
|
43
|
+
repo_id="OpenIOSSG/MnistDataset_mindspore", # 必填:拥有者/数据集名
|
|
44
|
+
local_dir="./downloads", # 选填:本地保存目录,默认当前目录下的 `MnistDataset_mindspore/`
|
|
45
|
+
#filename="train/train-images-idx3-ubyte" # 选填:下载指定文件,不填默认下载整个数据集
|
|
46
|
+
)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- 上述代码调用对应的终端命令(可直接复制到终端命令行中运行)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
gsnet dataset download OpenIOSSG/MnistDataset_mindspore --local_dir ./downloads
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- 执行结果:实时显示整体进度与各文件进度,并按远端目录结构保存到本地
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
数据集 `OpenIOSSG/MnistDataset_mindspore` 获取文件列表中……
|
|
59
|
+
- 云端共找到 5 个文件。
|
|
60
|
+
- 开始下载 5 个文件……
|
|
61
|
+
- 本地保存目录 D:/MnistDataset_mindspore/downloads
|
|
62
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
63
|
+
│ 10 workers | 已处理文件: 5/5 -------------- 100% 60.1MiB/s 52.4MiB 0:00:00 │
|
|
64
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
65
|
+
README.md -------------------- 100% ? 193bytes 0:00:00
|
|
66
|
+
(…)t10k-images-idx3-ubyte -------------------- 100% 44.8MiB/s 7.5MiB 0:00:00
|
|
67
|
+
(…)t10k-labels-idx1-ubyte -------------------- 100% ? 9.8KiB 0:00:00
|
|
68
|
+
(…)rain-images-idx3-ubyte -------------------- 100% 90.2MiB/s 44.9MiB 0:00:00
|
|
69
|
+
(…)rain-labels-idx1-ubyte -------------------- 100% 55.7MiB/s 58.6KiB 0:00:00
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
下载完成后的本地目录结构(与远端 `test/`、`train/` 一致):
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
downloads/
|
|
76
|
+
├── README.md 193 B
|
|
77
|
+
├── test/
|
|
78
|
+
│ ├── t10k-images-idx3-ubyte 7.84 MB
|
|
79
|
+
│ └── t10k-labels-idx1-ubyte 9.78 KB
|
|
80
|
+
└── train/
|
|
81
|
+
├── train-images-idx3-ubyte 44.86 MB
|
|
82
|
+
└── train-labels-idx1-ubyte 58.60 KB
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- 只下载部分文件:`-f`
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# 单个文件 -> ./MnistDataset_mindspore/train/train-images-idx3-ubyte
|
|
89
|
+
gsnet dataset download OpenIOSSG/MnistDataset_mindspore -f train/train-images-idx3-ubyte
|
|
90
|
+
|
|
91
|
+
# 多个文件(逗号隔开) -> ./MnistDataset_mindspore/test/t10k-images-idx3-ubyte 与 .../test/t10k-labels-idx1-ubyte
|
|
92
|
+
gsnet dataset download OpenIOSSG/MnistDataset_mindspore -f test/t10k-images-idx3-ubyte,test/t10k-labels-idx1-ubyte
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- 更多使用指南(上传、受控数据集、权限与常见报错等)请参考 [帮助文档](doc/sdk.md)
|
gsnet_sdk-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from setuptools import find_packages, setup
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as f:
|
|
4
|
+
long_description = f.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="gsnet-sdk",
|
|
8
|
+
version="0.1.0",
|
|
9
|
+
description="Python SDK and CLI for the GSnet platform",
|
|
10
|
+
package_dir={"": "src"},
|
|
11
|
+
packages=find_packages(where="src"),
|
|
12
|
+
long_description=long_description,
|
|
13
|
+
long_description_content_type="text/markdown",
|
|
14
|
+
url="https://gsnet.pcl.ac.cn/OpenIOSSG/gsnet-sdk",
|
|
15
|
+
author="chenzh05",
|
|
16
|
+
author_email="chenzh.ds@outlook.com",
|
|
17
|
+
license="MIT",
|
|
18
|
+
classifiers=[
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Topic :: Software Development :: Build Tools",
|
|
22
|
+
"Programming Language :: Python :: 3.8",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
],
|
|
25
|
+
entry_points={"console_scripts": ["gsnet = gsnet.commands.gsnet_cli:main"]},
|
|
26
|
+
install_requires=["requests", "tqdm", "deprecated", "pwinput", "httpx", "rich", "aiofiles", "h2", "cryptography>=42.0.0"],
|
|
27
|
+
python_requires=">=3.8",
|
|
28
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from gsnet._login import login, logout, whoami
|
|
6
|
+
from gsnet.refactor.constants import BOLD, DIM, RESET
|
|
7
|
+
from gsnet.refactor.core import GSnetRouter
|
|
8
|
+
from gsnet.refactor.plugins.log import setup_logging
|
|
9
|
+
from gsnet.refactor.sdk import notice, gsnet_download_file, gsnet_upload_file
|
|
10
|
+
|
|
11
|
+
from .downloader import download_file, download_model, download_model_file
|
|
12
|
+
from .uploader import upload_file, upload_model, upload_model_file
|
|
13
|
+
|
|
14
|
+
setup_logging()
|
|
15
|
+
|
|
16
|
+
# if windows machine, do not set uvloop
|
|
17
|
+
if os.name == "nt":
|
|
18
|
+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
|
19
|
+
else:
|
|
20
|
+
try:
|
|
21
|
+
import uvloop
|
|
22
|
+
except ImportError:
|
|
23
|
+
import subprocess
|
|
24
|
+
|
|
25
|
+
print(f"{DIM}Module {BOLD}`uvloop`{RESET} {DIM}undetected, installing...{RESET}")
|
|
26
|
+
subprocess.check_call(
|
|
27
|
+
[sys.executable, "-m", "pip", "install", "-qq", "uvloop"],
|
|
28
|
+
stdout=subprocess.DEVNULL,
|
|
29
|
+
stderr=subprocess.DEVNULL,
|
|
30
|
+
)
|
|
31
|
+
import uvloop
|
|
32
|
+
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import asdict, dataclass, field
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from typing import Any, Dict, List, Optional
|
|
6
|
+
|
|
7
|
+
from .utils import parse_time
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class UserInfo:
|
|
12
|
+
"""
|
|
13
|
+
User Info Dataclass
|
|
14
|
+
|
|
15
|
+
Attributes:
|
|
16
|
+
username (str):
|
|
17
|
+
username for GSnet links and repo_id
|
|
18
|
+
id (int):
|
|
19
|
+
unique number id of user
|
|
20
|
+
login (str):
|
|
21
|
+
username used for login purpose
|
|
22
|
+
subject_name (str):
|
|
23
|
+
self-defined name for display
|
|
24
|
+
email (str):
|
|
25
|
+
registered email address
|
|
26
|
+
avatar_url (str):
|
|
27
|
+
user avatar url
|
|
28
|
+
language (str):
|
|
29
|
+
user default language
|
|
30
|
+
is_admin (bool):
|
|
31
|
+
whether the user is admin or not
|
|
32
|
+
is_active (bool):
|
|
33
|
+
whether the user is active or not
|
|
34
|
+
last_login (str):
|
|
35
|
+
last login time
|
|
36
|
+
created (str):
|
|
37
|
+
created time
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
username: str
|
|
41
|
+
id: Optional[int]
|
|
42
|
+
login: Optional[str]
|
|
43
|
+
subject_name: Optional[str]
|
|
44
|
+
email: Optional[str]
|
|
45
|
+
avatar_url: Optional[str]
|
|
46
|
+
language: Optional[str]
|
|
47
|
+
is_admin: Optional[bool]
|
|
48
|
+
is_active: Optional[bool]
|
|
49
|
+
last_login: Optional[str]
|
|
50
|
+
created: Optional[str]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@dataclass
|
|
54
|
+
class RepoPermission:
|
|
55
|
+
"""
|
|
56
|
+
Permission Info Dataclass
|
|
57
|
+
|
|
58
|
+
Attributes:
|
|
59
|
+
admin (bool):
|
|
60
|
+
whether the user is admin or not
|
|
61
|
+
push (bool):
|
|
62
|
+
whether the user can push to the repository or not
|
|
63
|
+
pull (bool):
|
|
64
|
+
whether the user can pull from the repository or not
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
admin: bool
|
|
68
|
+
push: bool
|
|
69
|
+
pull: bool
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@dataclass
|
|
73
|
+
class RepoInfo:
|
|
74
|
+
"""
|
|
75
|
+
Repo Info Dataclass
|
|
76
|
+
|
|
77
|
+
Attributes:
|
|
78
|
+
id (int):
|
|
79
|
+
repo id
|
|
80
|
+
owner (UserInfo):
|
|
81
|
+
owner info
|
|
82
|
+
name (str):
|
|
83
|
+
repo name
|
|
84
|
+
repo_id (str):
|
|
85
|
+
repo id in `Username/Reponame` format
|
|
86
|
+
size (int):
|
|
87
|
+
repo size
|
|
88
|
+
html_url (str):
|
|
89
|
+
repo url
|
|
90
|
+
permissions (RepoPermission):
|
|
91
|
+
repo permissions
|
|
92
|
+
created_at (str):
|
|
93
|
+
created time
|
|
94
|
+
updated_at (str):
|
|
95
|
+
updated time
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
id: int
|
|
99
|
+
owner: UserInfo
|
|
100
|
+
name: str
|
|
101
|
+
repo_id: str
|
|
102
|
+
size: Optional[int]
|
|
103
|
+
html_url: Optional[str]
|
|
104
|
+
permissions: Optional[RepoPermission]
|
|
105
|
+
created_at: Optional[datetime]
|
|
106
|
+
updated_at: Optional[datetime]
|
|
107
|
+
|
|
108
|
+
def __init__(self, **kwargs):
|
|
109
|
+
self.id = kwargs.pop("id")
|
|
110
|
+
self.owner = UserInfo(**kwargs.pop("owner"))
|
|
111
|
+
self.name = kwargs.pop("name")
|
|
112
|
+
self.repo_id = kwargs.pop("subject_name")
|
|
113
|
+
|
|
114
|
+
self.size = kwargs.pop("size", None)
|
|
115
|
+
self.html_url = kwargs.pop("html_url", None)
|
|
116
|
+
permissions = kwargs.pop("permissions", None)
|
|
117
|
+
self.permissions = RepoPermission(**permissions) if permissions else None
|
|
118
|
+
|
|
119
|
+
created_at = kwargs.pop("created_at", None)
|
|
120
|
+
self.created_at = parse_time(created_at) if created_at else None
|
|
121
|
+
updated_at = kwargs.pop("updated_at", None)
|
|
122
|
+
self.updated_at = parse_time(updated_at) if updated_at else None
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@dataclass
|
|
126
|
+
class DatasetFile:
|
|
127
|
+
"""TODO"""
|
|
128
|
+
|
|
129
|
+
uuid: str
|
|
130
|
+
name: str
|
|
131
|
+
size: int
|
|
132
|
+
type: int
|
|
133
|
+
id: int
|
|
134
|
+
datasetId: int
|
|
135
|
+
repo_id: str
|
|
136
|
+
uploaderId: Optional[int]
|
|
137
|
+
isPrivate: Optional[bool]
|
|
138
|
+
decompressState: Optional[int]
|
|
139
|
+
|
|
140
|
+
def __init__(self, **kwargs):
|
|
141
|
+
self.uuid = kwargs.pop("uuid")
|
|
142
|
+
self.name = kwargs.pop("name")
|
|
143
|
+
self.size = kwargs.pop("size")
|
|
144
|
+
self.type = kwargs.pop("type")
|
|
145
|
+
self.id = kwargs.pop("id")
|
|
146
|
+
self.datasetId = kwargs.pop("datasetId")
|
|
147
|
+
self.repo_id = kwargs.pop("repo_id")
|
|
148
|
+
|
|
149
|
+
self.uploaderId = kwargs.pop("uploaderId", None)
|
|
150
|
+
self.isPrivate = kwargs.pop("isPrivate", None)
|
|
151
|
+
self.decompressState = kwargs.pop("decompressState", None)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@dataclass
|
|
155
|
+
class DatasetInfo:
|
|
156
|
+
"""TODO"""
|
|
157
|
+
|
|
158
|
+
id: str
|
|
159
|
+
userId: int
|
|
160
|
+
repoId: int
|
|
161
|
+
title: str
|
|
162
|
+
repo_id: str
|
|
163
|
+
attachments: Optional[List[DatasetFile]]
|
|
164
|
+
status: Optional[int]
|
|
165
|
+
|
|
166
|
+
def __init__(self, **kwargs):
|
|
167
|
+
self.id = kwargs.pop("id")
|
|
168
|
+
self.userId = kwargs.pop("userId")
|
|
169
|
+
self.repoId = kwargs.pop("repoId")
|
|
170
|
+
self.title = kwargs.pop("title")
|
|
171
|
+
self.repo_id = kwargs.pop("repo_id")
|
|
172
|
+
|
|
173
|
+
attachments = kwargs.pop("attachments", [])
|
|
174
|
+
if attachments:
|
|
175
|
+
for data in attachments:
|
|
176
|
+
data.update({"repo_id": self.repo_id})
|
|
177
|
+
self.attachments = [DatasetFile(**data) for data in attachments]
|
|
178
|
+
else:
|
|
179
|
+
self.attachments = None
|
|
180
|
+
|
|
181
|
+
self.status = kwargs.pop("status", None)
|
|
182
|
+
self.recommend = kwargs.pop("recommend", None)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@dataclass
|
|
186
|
+
class FileChunkInfo:
|
|
187
|
+
"""
|
|
188
|
+
File Chunk Info Dataclass
|
|
189
|
+
|
|
190
|
+
API Response (dict):
|
|
191
|
+
- dataset "/attachments/get_chunks"
|
|
192
|
+
"uuid": fileChunk.UUID,
|
|
193
|
+
"uploaded": strconv.Itoa(fileChunk.IsUploaded),
|
|
194
|
+
"uploadID": fileChunk.UploadID,
|
|
195
|
+
"chunks": string(chunks),
|
|
196
|
+
"attachID": "0",
|
|
197
|
+
"datasetID": "0",
|
|
198
|
+
"fileName": "",
|
|
199
|
+
"datasetName": "",
|
|
200
|
+
|
|
201
|
+
- model "/attachments/model/get_chunks"
|
|
202
|
+
"uuid": fileChunk.UUID,
|
|
203
|
+
"uploaded": strconv.Itoa(fileChunk.IsUploaded),
|
|
204
|
+
"uploadID": fileChunk.UploadID,
|
|
205
|
+
"chunks": string(chunks),
|
|
206
|
+
"attachID": "0",
|
|
207
|
+
"modeluuid": modeluuid,
|
|
208
|
+
"datasetID": "0",
|
|
209
|
+
"fileName": "",
|
|
210
|
+
"modelName": "",
|
|
211
|
+
|
|
212
|
+
- error response
|
|
213
|
+
"result_code": "-1",
|
|
214
|
+
"msg": errStr,
|
|
215
|
+
|
|
216
|
+
Attributes:
|
|
217
|
+
result_code (int):
|
|
218
|
+
return 0 when success, otherwise return -1 with error message
|
|
219
|
+
msg (str):
|
|
220
|
+
return plain string error message, return "success" when None
|
|
221
|
+
uploaded (Optional[bool]):
|
|
222
|
+
whether the file is uploaded or not
|
|
223
|
+
attachID (Optional[int]):
|
|
224
|
+
attachment id
|
|
225
|
+
uploaded_chunks (Optional[list]):
|
|
226
|
+
list of uploaded chunks
|
|
227
|
+
uploadID (Optional[str]):
|
|
228
|
+
upload id
|
|
229
|
+
uuid (Optional[str]):
|
|
230
|
+
file uuid
|
|
231
|
+
repo_id (Optional[str]):
|
|
232
|
+
repo id in `Username/Reponame` format
|
|
233
|
+
dataset_or_model_name (Optional[str]):
|
|
234
|
+
dataset or model name
|
|
235
|
+
"""
|
|
236
|
+
|
|
237
|
+
result_code: int
|
|
238
|
+
msg: str
|
|
239
|
+
uploaded: Optional[bool]
|
|
240
|
+
md5: Optional[str]
|
|
241
|
+
fileName: Optional[str]
|
|
242
|
+
attachID: Optional[int]
|
|
243
|
+
uploaded_chunks: Optional[list]
|
|
244
|
+
uploadID: Optional[str]
|
|
245
|
+
uuid: Optional[str]
|
|
246
|
+
repo_id: Optional[str]
|
|
247
|
+
dataset_or_model_name: Optional[str]
|
|
248
|
+
realName: Optional[str]
|
|
249
|
+
datasetID: Optional[str]
|
|
250
|
+
upload_mode: Optional[str]
|
|
251
|
+
|
|
252
|
+
def __init__(self, **kwargs):
|
|
253
|
+
result_code = kwargs.pop("result_code", 0)
|
|
254
|
+
self.result_code = int(result_code)
|
|
255
|
+
self.msg = kwargs.pop("msg", "success")
|
|
256
|
+
|
|
257
|
+
uploaded = kwargs.pop("uploaded", "")
|
|
258
|
+
self.uploaded = True if uploaded == "1" else False
|
|
259
|
+
self.attachID = kwargs.pop("attachID", None)
|
|
260
|
+
|
|
261
|
+
raw_chunks = kwargs.pop("chunks", "")
|
|
262
|
+
uploaded_chunks = [i for i in raw_chunks.split(",") if i != ""]
|
|
263
|
+
self.uploaded_chunks = uploaded_chunks
|
|
264
|
+
|
|
265
|
+
uploadID = kwargs.pop("uploadID", "")
|
|
266
|
+
self.uploadID = uploadID if uploadID != "" else None
|
|
267
|
+
uuid = kwargs.pop("uuid", "")
|
|
268
|
+
self.uuid = uuid if uuid != "" else None
|
|
269
|
+
|
|
270
|
+
repo = kwargs.pop("repoName", None)
|
|
271
|
+
owner = kwargs.pop("repoOwner", None)
|
|
272
|
+
self.repo_id = owner + "/" + repo if owner and repo else None
|
|
273
|
+
|
|
274
|
+
if kwargs.pop("upload_mode") == "dataset":
|
|
275
|
+
self.dataset_or_model_name = kwargs.pop("datasetName", "")
|
|
276
|
+
else:
|
|
277
|
+
self.dataset_or_model_name = kwargs.pop("modelName", "")
|
|
278
|
+
|
|
279
|
+
self.fileName = kwargs.pop("fileName", "")
|
|
280
|
+
self.realName = self.fileName
|
|
281
|
+
self.datasetID = kwargs.pop("datasetID", "")
|
|
282
|
+
self.md5 = kwargs.pop("md5", None)
|
|
283
|
+
self.upload_mode = kwargs.pop("upload_mode", None)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@dataclass
|
|
287
|
+
class NewMultipart:
|
|
288
|
+
"""TODO"""
|
|
289
|
+
|
|
290
|
+
result_code: int
|
|
291
|
+
msg: str
|
|
292
|
+
uuid: Optional[str]
|
|
293
|
+
uploadID: Optional[str]
|
|
294
|
+
|
|
295
|
+
def __init__(self, **kwargs):
|
|
296
|
+
result_code = kwargs.pop("result_code", 0)
|
|
297
|
+
self.result_code = int(result_code)
|
|
298
|
+
self.msg = kwargs.pop("msg", "success")
|
|
299
|
+
self.uuid = kwargs.pop("uuid", None)
|
|
300
|
+
self.uploadID = kwargs.pop("uploadID", None)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
@dataclass
|
|
304
|
+
class MultipartUrl:
|
|
305
|
+
"""TODO"""
|
|
306
|
+
|
|
307
|
+
url: Optional[str] = None
|
|
308
|
+
msg: Optional[str] = None
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
@dataclass
|
|
312
|
+
class ModelFile:
|
|
313
|
+
FileName: Optional[str]
|
|
314
|
+
ModTime: Optional[str]
|
|
315
|
+
IsDir: Optional[bool]
|
|
316
|
+
Size: Optional[int]
|
|
317
|
+
ParenDir: Optional[str]
|
|
318
|
+
UUID: Optional[str]
|
|
319
|
+
RelativePath: Optional[str]
|
|
320
|
+
repo_id: Optional[str]
|
|
321
|
+
model_id: Optional[str]
|
|
322
|
+
IsSupportPreview: Optional[str] = ""
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
@dataclass
|
|
326
|
+
class ModelInfo:
|
|
327
|
+
id: Optional[str]
|
|
328
|
+
name: Optional[str]
|
|
329
|
+
size: Optional[int]
|
|
330
|
+
path: Optional[str]
|
|
331
|
+
repo_id: Optional[str]
|
|
332
|
+
repoId: Optional[int]
|
|
333
|
+
userId: Optional[int]
|
|
334
|
+
userName: Optional[str]
|
|
335
|
+
isCanOper: Optional[bool]
|
|
336
|
+
isCanDelete: Optional[bool]
|
|
337
|
+
isCanDownload: Optional[bool]
|
|
338
|
+
repoName: Optional[str]
|
|
339
|
+
repoOwnerName: Optional[str]
|
|
340
|
+
modelFileList: Optional[List[ModelFile]]
|
|
341
|
+
modelType: Optional[int]
|
|
342
|
+
|
|
343
|
+
def __init__(self, **kwargs):
|
|
344
|
+
self.id = kwargs.pop("id", None)
|
|
345
|
+
self.name = kwargs.pop("name", None)
|
|
346
|
+
self.size = kwargs.pop("size", None)
|
|
347
|
+
self.path = kwargs.pop("path", None)
|
|
348
|
+
self.repo_id = kwargs.pop("repo_id", None)
|
|
349
|
+
self.repoId = kwargs.pop("repoId", None)
|
|
350
|
+
self.userId = kwargs.pop("userId", None)
|
|
351
|
+
self.userName = kwargs.pop("userName", None)
|
|
352
|
+
self.isCanOper = kwargs.pop("isCanOper", None)
|
|
353
|
+
self.isCanDelete = kwargs.pop("isCanDelete", None)
|
|
354
|
+
self.isCanDownload = kwargs.pop("isCanDownload", None)
|
|
355
|
+
self.repoName = kwargs.pop("repoName", None)
|
|
356
|
+
self.repoOwnerName = kwargs.pop("repoOwnerName", None)
|
|
357
|
+
|
|
358
|
+
modelFileList = kwargs.pop("modelFileList", [])
|
|
359
|
+
if modelFileList:
|
|
360
|
+
for data in modelFileList:
|
|
361
|
+
data.update({"repo_id": self.repo_id, "model_id": self.id})
|
|
362
|
+
self.modelFileList = [ModelFile(**data) for data in modelFileList]
|
|
363
|
+
else:
|
|
364
|
+
self.modelFileList = None
|
|
365
|
+
|
|
366
|
+
self.modelType = kwargs.pop("modelType", None)
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
@dataclass
|
|
370
|
+
class ModelCreate:
|
|
371
|
+
code: str
|
|
372
|
+
msg: Optional[str] = None
|
|
373
|
+
id: Optional[int] = None
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
@dataclass
|
|
377
|
+
class BasicResp:
|
|
378
|
+
code: int
|
|
379
|
+
msg: str
|
|
380
|
+
data: any
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
@dataclass
|
|
384
|
+
class CreateRepoOption:
|
|
385
|
+
name: str
|
|
386
|
+
alias: Optional[str] = None
|
|
387
|
+
description: Optional[str] = None
|
|
388
|
+
private: bool = False
|
|
389
|
+
issue_labels: Optional[str] = None
|
|
390
|
+
auto_init: bool = False
|
|
391
|
+
gitignores: Optional[str] = None
|
|
392
|
+
license: Optional[str] = None
|
|
393
|
+
readme: Optional[str] = None
|
|
394
|
+
default_branch: Optional[str] = None
|
|
395
|
+
|
|
396
|
+
def __post_init__(self):
|
|
397
|
+
if len(self.name) > 100:
|
|
398
|
+
raise ValueError("Name must be at most 100 characters long")
|
|
399
|
+
if self.alias and len(self.alias) > 100:
|
|
400
|
+
raise ValueError("Alias must be at most 100 characters long")
|
|
401
|
+
if self.description and len(self.description) > 255:
|
|
402
|
+
raise ValueError("Description must be at most 255 characters long")
|
|
403
|
+
if self.default_branch and len(self.default_branch) > 100:
|
|
404
|
+
raise ValueError("Default branch must be at most 100 characters long")
|