Name | scidmcli JSON |
Version |
0.0.4
JSON |
| download |
home_page | |
Summary | NCHC SciDM |
upload_time | 2023-11-23 08:08:00 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.6 |
license | apache2 |
keywords |
ckan
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# scidm cli
# 一、 說明
https://git.narl.org.tw/gitlab/datamarket-team/twdm-dev/-/issues/200
開發資料服務平台 CLI 使用套件,提供以 Python pip 快速安裝並提供以命令列使用之工具。
# 二、 用法
## 2.1 安裝
直接使用 pip 即可完成安裝
```
pip install scidmcli
```
## 2.2 執行
### scidmcli 指令
```
Options:
-v, --version Show scidm-cli version
-h, --help Show this message and exit.
Commands:
config Configure the SCIDM CLI [info|init|reset]
dataset Manage dataset [list|files|download|create|push|delete]
organization Manage organization [list]
user Manage user [list|token]
```
### scidmcli config 指令
```
Options:
-h, --help Show this message and exit.
Commands:
info Get exsisting information.
init Initialize the credential.
reset Reset the credential.
```
```
範例:
scidmcli config info 檢視認證設定
scidmcli config init --apikey {api_key} 初始化認證
scidmcli config reset --apikey {api_key} 重設認證
認證初始化後會儲存於~/.scidmcli/credential
```
### scidmcli dataset 指令
```
Options:
-h, --help Show this message and exit.
Commands:
create create new dataset
delete delete dataset or resource
download download the resources of dataset
files list the resources of dataset
list list the datasets of organization
push upload resources
```
```
範例:
scidmcli dataset create --data '{"name": "{dataset_name}", ... }' 建立資料集(JSON格式)
scidmcli dataset delete --type [ds|rs] --id {ds_id|rs_id} 刪除資料集或資源
scidmcli dataset download --id {dataset_name} --path {path} 下載資料集到指令路徑(預設~/.scidmcli/download)
scidmcli dataset files --id {dataset_name} 列出資料集底下資源
scidmcli dataset list --organization {org_name} 列出組織底下資料集
scidmcli dataset push --data '{"package_id": "{package_id}", ... }' 上傳資源(JSON格式)
```
### scidmcli organization 指令
```
Options:
-h, --help Show this message and exit.
Commands:
list show organization
```
```
範例:
scidmcli organization list 列出組織
```
### scidmcli user 指令
```
Options:
-h, --help Show this message and exit.
Commands:
list list the organizations or datasets that the user has permission
token show user's token
```
```
範例:
scidmcli user list --type [ds|org] 列出使用者有權限的組織或資料集
scidmcli user token 檢視當前用戶的API key
```
# 三、 開發
## 3.1_ 開發工具包
```
pip install build twine
```
## 3.2_ 檔案結構
* README.md
* pyproject.toml
* src
* scidmcli
* \_\_init\_\_.py
* example.py
## 3.3_ 打包
```
python -m build
```
## 3.4_ 上傳到 PypI
```
twine upload dist/*
```
## 3.5 測試 (安裝)
套件會裝在 python的 library 庫中,如 anaconda3/lib/python3.xx/site-packages/xx
```
pip install scidmcli
```
```
pip uninstall scidmcli
```
# X、補充
## X1_ (optional) 打包到 測試服 做測試
```
twine upload --repository-url https://test.pypi.org/legacy/ dist/* --verbose
```
```
pip install --index-url https://test.pypi.org/simple/ --no-deps scidmcli
```
## X2_ 用 token file 上傳到pypi
- ~/.pypirc
```
[distutils]
index-servers =
pypi
[pypi]
username = __token__
password = pypi-AgEIcH(....skip....)-P7f3FF-rbty7knQ
```
```
twine upload dist/*
```
## X3_ 本地端測試
建議可以使用python虛擬環境來獨立測試
```
geosense@twdm:~$ python3 -m venv pyenv
geosense@twdm:~$ . pyenv/bin/activate
```
從git上clone
```
(pyenv) geosense@twdm:~$ git clone https://git.narl.org.tw/gitlab/datamarket-team/scidmcli.git
```
本地安裝
```
(pyenv) geosense@twdm:~$ cd scidmcli
(pyenv) geosense@twdm:~/scidmcli$ pip install -e .
```
安裝完成
```
(pyenv) geosense@twdm:~/scidmcli$ scidmcli
Usage: scidmcli [OPTIONS] COMMAND [ARGS]...
Options:
-v, --version Show scidm-cli version
-h, --help Show this message and exit.
Commands:
config Configure the SCIDM CLI [info|init|reset]
dataset Manage dataset [list|files|download|create|push|delete]
organization Manage organization [list]
user Manage user [list|token]
```
初始化憑證
```
scidmcli config init --apikey {api_key}
```
顯示憑證資訊
```
(pyenv) geosense@twdm:~/scidmcli$ scidmcli config info
Hi, your information:
+------------------+--------------------------------------+
| key | value |
+------------------+--------------------------------------+
| scidm_data_path | /home/geosense/.scidm_cli |
| scidm_credential | /home/geosense/.scidm_cli/credential |
| scidm_api_key | {api_key} |
| server_url | https://twdm.nchc.org.tw/ |
+------------------+--------------------------------------+
```
Raw data
{
"_id": null,
"home_page": "",
"name": "scidmcli",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "ckan",
"author": "",
"author_email": "WeiYu <wychen@narlabs.org.tw>",
"download_url": "https://files.pythonhosted.org/packages/8d/10/b80d098d7de918c35ffec3dd5ebb0a671f34c0f3aa5b6c7a5e3467b1a3cc/scidmcli-0.0.4.tar.gz",
"platform": null,
"description": "# scidm cli\n\n# \u4e00\u3001 \u8aaa\u660e\nhttps://git.narl.org.tw/gitlab/datamarket-team/twdm-dev/-/issues/200\n\u958b\u767c\u8cc7\u6599\u670d\u52d9\u5e73\u53f0 CLI \u4f7f\u7528\u5957\u4ef6\uff0c\u63d0\u4f9b\u4ee5 Python pip \u5feb\u901f\u5b89\u88dd\u4e26\u63d0\u4f9b\u4ee5\u547d\u4ee4\u5217\u4f7f\u7528\u4e4b\u5de5\u5177\u3002\n\n# \u4e8c\u3001 \u7528\u6cd5\n\n## 2.1 \u5b89\u88dd\n\n\u76f4\u63a5\u4f7f\u7528 pip \u5373\u53ef\u5b8c\u6210\u5b89\u88dd\n```\npip install scidmcli\n```\n\n## 2.2 \u57f7\u884c\n\n### scidmcli \u6307\u4ee4\n\n```\nOptions:\n -v, --version Show scidm-cli version\n -h, --help Show this message and exit.\n\nCommands:\n config Configure the SCIDM CLI [info|init|reset] \n dataset Manage dataset [list|files|download|create|push|delete] \n organization Manage organization [list] \n user Manage user [list|token]\n```\n\n### scidmcli config \u6307\u4ee4\n\n```\nOptions:\n -h, --help Show this message and exit.\n\nCommands:\n info Get exsisting information.\n init Initialize the credential.\n reset Reset the credential.\n```\n\n```\n\u7bc4\u4f8b:\n scidmcli config info \u6aa2\u8996\u8a8d\u8b49\u8a2d\u5b9a\n scidmcli config init --apikey {api_key} \u521d\u59cb\u5316\u8a8d\u8b49\n scidmcli config reset --apikey {api_key} \u91cd\u8a2d\u8a8d\u8b49\n\n \u8a8d\u8b49\u521d\u59cb\u5316\u5f8c\u6703\u5132\u5b58\u65bc~/.scidmcli/credential\n```\n\n### scidmcli dataset \u6307\u4ee4\n\n```\nOptions:\n -h, --help Show this message and exit.\n\nCommands:\n create create new dataset\n delete delete dataset or resource\n download download the resources of dataset\n files list the resources of dataset\n list list the datasets of organization\n push upload resources\n```\n\n```\n\u7bc4\u4f8b:\n scidmcli dataset create --data '{\"name\": \"{dataset_name}\", ... }' \u5efa\u7acb\u8cc7\u6599\u96c6(JSON\u683c\u5f0f)\n scidmcli dataset delete --type [ds|rs] --id {ds_id|rs_id} \u522a\u9664\u8cc7\u6599\u96c6\u6216\u8cc7\u6e90\n scidmcli dataset download --id {dataset_name} --path {path} \u4e0b\u8f09\u8cc7\u6599\u96c6\u5230\u6307\u4ee4\u8def\u5f91(\u9810\u8a2d~/.scidmcli/download)\n scidmcli dataset files --id {dataset_name} \u5217\u51fa\u8cc7\u6599\u96c6\u5e95\u4e0b\u8cc7\u6e90\n scidmcli dataset list --organization {org_name} \u5217\u51fa\u7d44\u7e54\u5e95\u4e0b\u8cc7\u6599\u96c6\n scidmcli dataset push --data '{\"package_id\": \"{package_id}\", ... }' \u4e0a\u50b3\u8cc7\u6e90(JSON\u683c\u5f0f)\n```\n\n### scidmcli organization \u6307\u4ee4\n\n```\nOptions:\n -h, --help Show this message and exit.\n\nCommands:\n list show organization\n```\n\n```\n\u7bc4\u4f8b:\n scidmcli organization list \u5217\u51fa\u7d44\u7e54\n```\n\n### scidmcli user \u6307\u4ee4\n\n```\nOptions:\n -h, --help Show this message and exit.\n\nCommands:\n list list the organizations or datasets that the user has permission\n token show user's token\n```\n\n```\n\u7bc4\u4f8b:\n scidmcli user list --type [ds|org] \u5217\u51fa\u4f7f\u7528\u8005\u6709\u6b0a\u9650\u7684\u7d44\u7e54\u6216\u8cc7\u6599\u96c6\n scidmcli user token \u6aa2\u8996\u7576\u524d\u7528\u6236\u7684API key\n```\n\n# \u4e09\u3001 \u958b\u767c\n\n## 3.1_ \u958b\u767c\u5de5\u5177\u5305\n\n```\npip install build twine\n```\n\n## 3.2_ \u6a94\u6848\u7d50\u69cb\n* README.md\n* pyproject.toml\n* src \n * scidmcli\n * \\_\\_init\\_\\_.py\n * example.py\n\n\n## 3.3_ \u6253\u5305\n\n```\npython -m build\n```\n\n## 3.4_ \u4e0a\u50b3\u5230 PypI\n\n```\ntwine upload dist/*\n```\n\n## 3.5 \u6e2c\u8a66 (\u5b89\u88dd)\n\n\u5957\u4ef6\u6703\u88dd\u5728 python\u7684 library \u5eab\u4e2d\uff0c\u5982 anaconda3/lib/python3.xx/site-packages/xx\n```\npip install scidmcli\n```\n\n```\npip uninstall scidmcli\n```\n\n\n# X\u3001\u88dc\u5145\n\n## X1_ (optional) \u6253\u5305\u5230 \u6e2c\u8a66\u670d \u505a\u6e2c\u8a66\n\n```\ntwine upload --repository-url https://test.pypi.org/legacy/ dist/* --verbose\n```\n```\npip install --index-url https://test.pypi.org/simple/ --no-deps scidmcli\n```\n\n\n## X2_ \u7528 token file \u4e0a\u50b3\u5230pypi \n\n- ~/.pypirc \n```\n[distutils]\n index-servers =\n pypi\n\n[pypi]\n username = __token__\n password = pypi-AgEIcH(....skip....)-P7f3FF-rbty7knQ\n```\n\n```\ntwine upload dist/*\n```\n\n\n## X3_ \u672c\u5730\u7aef\u6e2c\u8a66\n\n\u5efa\u8b70\u53ef\u4ee5\u4f7f\u7528python\u865b\u64ec\u74b0\u5883\u4f86\u7368\u7acb\u6e2c\u8a66\n```\ngeosense@twdm:~$ python3 -m venv pyenv\ngeosense@twdm:~$ . pyenv/bin/activate\n```\n\n\u5f9egit\u4e0aclone\n```\n(pyenv) geosense@twdm:~$ git clone https://git.narl.org.tw/gitlab/datamarket-team/scidmcli.git\n```\n\n\u672c\u5730\u5b89\u88dd\n```\n(pyenv) geosense@twdm:~$ cd scidmcli\n(pyenv) geosense@twdm:~/scidmcli$ pip install -e . \n```\n\n\u5b89\u88dd\u5b8c\u6210\n```\n(pyenv) geosense@twdm:~/scidmcli$ scidmcli \nUsage: scidmcli [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n -v, --version Show scidm-cli version\n -h, --help Show this message and exit.\n\nCommands:\n config Configure the SCIDM CLI [info|init|reset]\n dataset Manage dataset [list|files|download|create|push|delete]\n organization Manage organization [list]\n user Manage user [list|token]\n```\n\n\u521d\u59cb\u5316\u6191\u8b49\n```\nscidmcli config init --apikey {api_key}\n```\n\n\u986f\u793a\u6191\u8b49\u8cc7\u8a0a\n```\n(pyenv) geosense@twdm:~/scidmcli$ scidmcli config info\nHi, your information:\n+------------------+--------------------------------------+\n| key | value |\n+------------------+--------------------------------------+\n| scidm_data_path | /home/geosense/.scidm_cli |\n| scidm_credential | /home/geosense/.scidm_cli/credential |\n| scidm_api_key | {api_key} |\n| server_url | https://twdm.nchc.org.tw/ |\n+------------------+--------------------------------------+\n```\n",
"bugtrack_url": null,
"license": "apache2",
"summary": "NCHC SciDM",
"version": "0.0.4",
"project_urls": null,
"split_keywords": [
"ckan"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7ce6065d9fab1c135e6f1d85090370a3a30eefdd90ede89cfe8addc7b358d154",
"md5": "c27467cca6663e0dda2769f7d5202a39",
"sha256": "f6ba5a8860132c2546f2cd8fab9de1178d719766e383420e6ed2cd3c1f036f29"
},
"downloads": -1,
"filename": "scidmcli-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c27467cca6663e0dda2769f7d5202a39",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 15173,
"upload_time": "2023-11-23T08:07:55",
"upload_time_iso_8601": "2023-11-23T08:07:55.620043Z",
"url": "https://files.pythonhosted.org/packages/7c/e6/065d9fab1c135e6f1d85090370a3a30eefdd90ede89cfe8addc7b358d154/scidmcli-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8d10b80d098d7de918c35ffec3dd5ebb0a671f34c0f3aa5b6c7a5e3467b1a3cc",
"md5": "2b0d446f5091405fd57cb574ed825ced",
"sha256": "d006a9d472a08c76899e6d170dc42fc5d82a9a285257f279177e6ef5717ac830"
},
"downloads": -1,
"filename": "scidmcli-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "2b0d446f5091405fd57cb574ed825ced",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 133077,
"upload_time": "2023-11-23T08:08:00",
"upload_time_iso_8601": "2023-11-23T08:08:00.156966Z",
"url": "https://files.pythonhosted.org/packages/8d/10/b80d098d7de918c35ffec3dd5ebb0a671f34c0f3aa5b6c7a5e3467b1a3cc/scidmcli-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-23 08:08:00",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "scidmcli"
}