-
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.
[Doc] Improve the document and add new function method into Notebook …
…file. WHY: 1. Update new version 2. Want to check the content easily. HOW: 1. Re-construct the folder to user-portal and admin-portal. 2. Arrange the order of user portal notebook file. 3. Modify the content of user portal notebook file. 4. Modify the content of admin portal notebook file. Signed-off-by: Simon Liu <simonliu@infuseai.io>
- Loading branch information
Simon Liu
committed
Apr 6, 2023
1 parent
cf5bb60
commit b78ec26
Showing
32 changed files
with
6,895 additions
and
1,999 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 | ||
} |
Oops, something went wrong.