Skip to content

[Doc] Improve the document and add new function method into Notebook file. #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,496 changes: 1,496 additions & 0 deletions docs/notebook/admin-portal/01-groups.ipynb

Large diffs are not rendered by default.

829 changes: 829 additions & 0 deletions docs/notebook/admin-portal/02-users.ipynb

Large diffs are not rendered by default.

757 changes: 757 additions & 0 deletions docs/notebook/admin-portal/03-instancetypes.ipynb

Large diffs are not rendered by default.

751 changes: 751 additions & 0 deletions docs/notebook/admin-portal/04-images.ipynb

Large diffs are not rendered by default.

815 changes: 815 additions & 0 deletions docs/notebook/admin-portal/05-volumes.ipynb

Large diffs are not rendered by default.

470 changes: 470 additions & 0 deletions docs/notebook/admin-portal/06-secrets.ipynb

Large diffs are not rendered by default.

329 changes: 329 additions & 0 deletions docs/notebook/admin-portal/07-usage-reports.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,329 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "b8a41dda",
"metadata": {},
"source": [
"# [admin] Usage Reports command\n",
"\n",
"\n",
"The `reports` command in `admin` scope could help you manage groups.\n"
]
},
{
"cell_type": "markdown",
"id": "740039bc",
"metadata": {},
"source": [
"## Setup PrimeHub Python SDK\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "effe3482",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PrimeHub Python SDK setup successfully\n"
]
}
],
"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": "bfb99744",
"metadata": {},
"source": [
"## Help documentation"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9dd7964e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on AdminReport in module primehub.admin_reports object:\n",
"\n",
"class AdminReport(primehub.Helpful, primehub.Module)\n",
" | AdminReport(primehub: primehub.PrimeHub, **kwargs)\n",
" | \n",
" | Method resolution order:\n",
" | AdminReport\n",
" | primehub.Helpful\n",
" | primehub.Module\n",
" | primehub.HTTPSupport\n",
" | builtins.object\n",
" | \n",
" | Methods defined here:\n",
" | \n",
" | download(self, url, **kwargs)\n",
" | Download a report csv file from the given url.\n",
" | \n",
" | It will convert the URI to filename by default. For example, there are summary url and details url\n",
" | * https://primehub-python-sdk.primehub.io/api/report/monthly/2022/12\n",
" | * https://primehub-python-sdk.primehub.io/api/report/monthly/details/2022/12\n",
" | \n",
" | Will save to\n",
" | * 202212.csv\n",
" | * 202212_details.csv\n",
" | \n",
" | If you give a dest, it will use the given dest as the filename.\n",
" | \n",
" | :type url: str\n",
" | :param url: The report url.\n",
" | \n",
" | :type dest: str\n",
" | :param dest: The local path to save the report csv file\n",
" | \n",
" | :type recusive: bool\n",
" | :param recusive: Copy recursively, it works when a path is a directory.\n",
" | \n",
" | help_description(self)\n",
" | one line description for all commands\n",
" | \n",
" | list(self, **kwargs) -> Iterator\n",
" | List reports\n",
" | \n",
" | :type page: int\n",
" | :param page: the page of all data\n",
" | \n",
" | :rtype Iterator\n",
" | :return user iterator\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data and other attributes defined here:\n",
" | \n",
" | __abstractmethods__ = frozenset()\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data descriptors inherited from primehub.Helpful:\n",
" | \n",
" | __dict__\n",
" | dictionary for instance variables (if defined)\n",
" | \n",
" | __weakref__\n",
" | list of weak references to the object (if defined)\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Methods inherited from primehub.Module:\n",
" | \n",
" | __init__(self, primehub: primehub.PrimeHub, **kwargs)\n",
" | Initialize self. See help(type(self)) for accurate signature.\n",
" | \n",
" | display(self, action: dict, value: Any)\n",
" | \n",
" | get_display(self) -> primehub.utils.display.Displayable\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Static methods inherited from primehub.Module:\n",
" | \n",
" | output(result: dict, object_path: str)\n",
" | Give a dict {'data': {'a': {'b': 'c'}}}\n",
" | we could get the c by the path a.b\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data descriptors inherited from primehub.Module:\n",
" | \n",
" | current_group\n",
" | \n",
" | endpoint\n",
" | \n",
" | group_id\n",
" | \n",
" | group_name\n",
" | \n",
" | primehub_config\n",
"\n"
]
}
],
"source": [
"help(ph.admin.reports)"
]
},
{
"cell_type": "markdown",
"id": "19b1d67f",
"metadata": {},
"source": [
"## Usage reports management"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "9633fcc5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Usage: \n",
" primehub admin reports <command>\n",
"\n",
"Get reports\n",
"\n",
"Available Commands:\n",
" download Download a report by url\n",
" list List reports\n",
"\n",
"Options:\n",
" -h, --help Show the help\n",
"\n",
"Global Options:\n",
" --config CONFIG Change the path of the config file (Default: ~/.primehub/config.json)\n",
" --endpoint ENDPOINT Override the GraphQL API endpoint\n",
" --token TOKEN Override the API Token\n",
" --group GROUP Override the current group\n",
" --json Output the json format (output human-friendly format by default)\n"
]
}
],
"source": [
"!primehub admin reports help"
]
},
{
"cell_type": "markdown",
"id": "a903cc39",
"metadata": {},
"source": [
"## Examples"
]
},
{
"cell_type": "markdown",
"id": "eb6dc413",
"metadata": {},
"source": [
"You could find [more examples on our github](https://github.com/InfuseAI/primehub-python-sdk/blob/main/docs/CLI/admin/groups.md)."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "fab56243",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"id": "461d85cf",
"metadata": {},
"source": [
"#### List all usage reports"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fa172bf3",
"metadata": {},
"outputs": [],
"source": [
"reports_df = pd.DataFrame(ph.admin.reports.list())\n",
"reports_df"
]
},
{
"cell_type": "markdown",
"id": "c93324ed",
"metadata": {},
"source": [
"#### Download usage reports"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "6ef6faa8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'filename': '/home/jovyan/primehub-python-sdk/docs/notebook/admin-portal/latest-summary-reports.csv'}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Summary Reports\n",
"latest_summary_url = reports_df[\"summaryUrl\"][0]\n",
"\n",
"ph.admin.reports.download(latest_summary_url, dest=\"./latest-summary-reports.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "3593537a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'filename': '/home/jovyan/primehub-python-sdk/docs/notebook/admin-portal/latest-detailed-reports.csv'}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Detailed Reports\n",
"latest_detailed_url = reports_df[\"detailedUrl\"][0]\n",
"\n",
"ph.admin.reports.download(latest_detailed_url, dest=\"./latest-detailed-reports.csv\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"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.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading