-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from InfuseAI/feature/sc-21471/datasets
add admin datasets group
- Loading branch information
Showing
23 changed files
with
1,617 additions
and
38 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3365d96c", | ||
"metadata": {}, | ||
"source": [ | ||
"# [admin] Datasets command\n", | ||
"\n", | ||
"\n", | ||
"The `datasets` command in `admin` scope could help you manage datasets.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0e684e90", | ||
"metadata": {}, | ||
"source": [ | ||
"## Setup PrimeHub Python SDK\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2ed0bf22", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from primehub import PrimeHub, PrimeHubConfig\n", | ||
"ph = PrimeHub(PrimeHubConfig())\n", | ||
"\n", | ||
"if ph.is_ready():\n", | ||
" print(\"PrimeHub Python SDK setup successfully\")\n", | ||
"else:\n", | ||
" print(\"PrimeHub Python SDK couldn't get the group information, follow the 00-getting-started.ipynb to complete it\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3720ad82", | ||
"metadata": {}, | ||
"source": [ | ||
"## Help documentation" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2055801e", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"help(ph.admin.datasets)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ac0e2516", | ||
"metadata": {}, | ||
"source": [ | ||
"## Dataset management\n", | ||
"\n", | ||
"---\n", | ||
"\n", | ||
"\n", | ||
"```\n", | ||
"$ primehub admin datasets\n", | ||
"\n", | ||
"Usage:\n", | ||
" primehub admin datasets <command>\n", | ||
"\n", | ||
"Manage datasets\n", | ||
"\n", | ||
"Available Commands:\n", | ||
" create Create a dataset\n", | ||
" delete Delete a dataset by id\n", | ||
" get Get a dataset by name\n", | ||
" list Delete a dataset by id\n", | ||
" update Update the dataset\n", | ||
" upload_secret Regenerate the secret of the upload server\n", | ||
"```\n", | ||
"\n", | ||
"---\n", | ||
"\n", | ||
"\n", | ||
"## Dataset configuration\n", | ||
"\n", | ||
"You need a configuration `create` and `update` to operate. Here is an example to create a `pv-dataset`:\n", | ||
"\n", | ||
"```json\n", | ||
"{\n", | ||
" \"name\": \"pv-dataset\",\n", | ||
" \"displayName\": \"the dataset created by SDK\",\n", | ||
" \"description\": \"It is a PV dataset\",\n", | ||
" \"type\": \"pv\",\n", | ||
" \"global\": true,\n", | ||
" \"pvProvisioning\": \"auto\",\n", | ||
" \"volumeSize\": 1\n", | ||
"}\n", | ||
"```\n", | ||
"\n", | ||
"In our system, there are 5 types for datasets: `['pv', 'nfs', 'hostPath', 'git', 'env']`. Please check the fields reference to give a proper configuration to create your own dataset.\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"## Fields for creating or updating\n", | ||
"\n", | ||
"| field | required | type | description |\n", | ||
"| --- | --- | --- | --- |\n", | ||
"| name | required | string | it should be a valid resource name for kubernetes |\n", | ||
"| displayName | optional | string | display name for this dataset |\n", | ||
"| description | optional | string | |\n", | ||
"| global | optional | boolean | when a dataset is global, it could be seen for each group |\n", | ||
"| type | required | string | one of ['pv', 'nfs', 'hostPath', 'git', 'env'] |\n", | ||
"| url | conditional | string | **MUST** use with `git` type |\n", | ||
"| pvProvisioning | conditional | string | onf of ['auto', 'manual'], **MUST** use with `pv` type. This field only uses in `CREATE` action |\n", | ||
"| nfsServer | conditional | string | **MUST** use with `nfs` type |\n", | ||
"| nfsPath | conditional | string | **MUST** use with `nfs` type |\n", | ||
"| hostPath | conditional | string | **MUST** use with `hostPath` type |\n", | ||
"| variables | optional | dict | **MAY** use with `env` type. It is key value pairs. All values have to a string value. For example: `{\"key1\":\"value1\",\"key2\":\"value2\"}`. |\n", | ||
"| groups | optional | list of connected groups (dict) | please see the `connect` examples |\n", | ||
"| secret | optional | dict | **MAY** use with `git` type. it binds a `secret` to the `git` dataset |\n", | ||
"| volumeSize | conditional | integer | **MUST** use with `pv` type. The unit is `GB`.|\n", | ||
"| enableUploadServer | optional | boolean | it only works with one of ['pv', 'nfs', 'hostPath'] writable types |\n", | ||
"\n", | ||
"> There is a simple rule to use fields for `UPDATE`. All required fields should not be in the payload.\n", | ||
"\n", | ||
"For example, there is a configuration for creating env dataset:\n", | ||
"\n", | ||
"```bash\n", | ||
"primehub admin datasets create <<EOF\n", | ||
"{\n", | ||
" \"name\": \"env-dataset\",\n", | ||
" \"description\": \"\",\n", | ||
" \"type\": \"env\",\n", | ||
" \"variables\": {\n", | ||
" \"ENV\": \"prod\",\n", | ||
" \"LUCKY_NUMBER\": \"7\"\n", | ||
" }\n", | ||
"}\n", | ||
"EOF\n", | ||
"```\n", | ||
"\n", | ||
"After removing required `name` and `type` fields, it could be used with updating:\n", | ||
"\n", | ||
"```bash\n", | ||
"primehub admin datasets update env-dataset <<EOF\n", | ||
"{\n", | ||
" \"description\": \"make changes to the description\",\n", | ||
" \"variables\": {\n", | ||
" \"ENV\": \"prod\",\n", | ||
" \"LUCKY_NUMBER\": \"8\"\n", | ||
" }\n", | ||
"}\n", | ||
"EOF\n", | ||
"```\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "dcb77e3d", | ||
"metadata": {}, | ||
"source": [ | ||
"## Examples" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b4eb5746", | ||
"metadata": {}, | ||
"source": [ | ||
"You could find [more examples on our github](https://github.com/InfuseAI/primehub-python-sdk/blob/main/docs/CLI/admin/datasets.md)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "639e6281", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# List datasets\n", | ||
"list(ph.admin.datasets.list())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "908759a6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Get a dataset\n", | ||
"ph.admin.datasets.get('primehub')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ef3c1a91", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "PrimeHub SDK", | ||
"language": "python", | ||
"name": "myenv" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,4 +98,4 @@ | |
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.