Skip to content
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

Move custom columns and replace with native Trace #465

Merged
merged 3 commits into from
Sep 22, 2023
Merged
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
92 changes: 39 additions & 53 deletions .github/nb_scripts/fix_login.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 51,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -13,7 +13,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -22,7 +22,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 53,
"metadata": {},
"outputs": [
{
Expand All @@ -31,7 +31,7 @@
"Path('/Users/tcapelle/work/examples/colabs/boosting/Credit_Scorecards_with_XGBoost_and_W&B.ipynb')"
]
},
"execution_count": 26,
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -43,30 +43,24 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 54,
"metadata": {},
"outputs": [],
"source": [
"def idx_login_cell(nb, delete_line=True):\n",
" for i, cell in enumerate(nb[\"cells\"]):\n",
" if cell[\"cell_type\"] == \"code\":\n",
" if \"login\" in cell[\"source\"]:\n",
" if delete_line:\n",
" cell_content = cell[\"source\"].split(\"\\n\")\n",
" cell_content = [line for line in cell_content if \"login\" not in line]\n",
" cell[\"source\"] = \"\\n\".join(cell_content) \n",
" return i"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!wandb login"
]
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 55,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -75,7 +69,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 56,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -84,7 +78,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 57,
"metadata": {},
"outputs": [
{
Expand All @@ -93,7 +87,7 @@
"nbformat.notebooknode.NotebookNode"
]
},
"execution_count": 30,
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -104,20 +98,19 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'attachments': {},\n",
" 'cell_type': 'markdown',\n",
" 'idx_': 1,\n",
" 'metadata': {},\n",
" 'source': '<img src=\"http://wandb.me/logo-im-png\" width=\"400\" alt=\"Weights & Biases\" /><br>\\n\\n<!--- @wandbcode{xgboost_vehicle_loan_default} -->\\n\\n<img src=\"http://wandb.me/mini-diagram\" width=\"600\" alt=\"Weights & Biases\" />'}"
]
},
"execution_count": 31,
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -128,7 +121,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 59,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -137,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 60,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -150,7 +143,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 61,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -159,20 +152,20 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 62,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'cell_type': 'code',\n",
" 'execution_count': None,\n",
" 'idx_': 19,\n",
" 'metadata': {},\n",
" 'source': ''}"
" 'outputs': [],\n",
" 'source': \"import wandb\\n\\nWANDB_PROJECT ='vehicle_loan_default'\"}"
]
},
"execution_count": 35,
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -183,21 +176,21 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 63,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'id': '98de0a69',\n",
"{'id': 'ff6708eb',\n",
" 'cell_type': 'code',\n",
" 'metadata': {},\n",
" 'execution_count': None,\n",
" 'source': '!wandb login',\n",
" 'outputs': []}"
]
},
"execution_count": 36,
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -208,20 +201,19 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 64,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'attachments': {},\n",
" 'cell_type': 'markdown',\n",
" 'idx_': 21,\n",
" 'metadata': {},\n",
" 'source': '## Vehicle Loan Dataset\\n\\nWe will be using a simplified version of the [Vehicle Loan Default Prediction dataset](https://www.kaggle.com/sneharshinde/ltfs-av-data) from L&T which has been stored in W&B Artifacts. '}"
]
},
"execution_count": 37,
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -232,7 +224,7 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 65,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -249,7 +241,7 @@
},
{
"cell_type": "code",
"execution_count": 49,
"execution_count": 66,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -259,23 +251,9 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 67,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "idx_",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/Users/tcapelle/work/examples/fix_login.ipynb Cell 17\u001b[0m line \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tcapelle/work/examples/fix_login.ipynb#X20sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m login_idx \u001b[39m=\u001b[39m idx_login_cell(nb)\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tcapelle/work/examples/fix_login.ipynb#X20sZmlsZQ%3D%3D?line=3'>4</a>\u001b[0m \u001b[39mif\u001b[39;00m login_idx \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/tcapelle/work/examples/fix_login.ipynb#X20sZmlsZQ%3D%3D?line=4'>5</a>\u001b[0m nb \u001b[39m=\u001b[39m insert_login_cell(nb, login_idx)\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tcapelle/work/examples/fix_login.ipynb#X20sZmlsZQ%3D%3D?line=5'>6</a>\u001b[0m \u001b[39m# delete path_ attribute\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tcapelle/work/examples/fix_login.ipynb#X20sZmlsZQ%3D%3D?line=6'>7</a>\u001b[0m nb\u001b[39m.\u001b[39mpop(\u001b[39m\"\u001b[39m\u001b[39mpath_\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39mNone\u001b[39;00m)\n",
"\u001b[1;32m/Users/tcapelle/work/examples/fix_login.ipynb Cell 17\u001b[0m line \u001b[0;36minsert_login_cell\u001b[0;34m(nb, idx, code)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tcapelle/work/examples/fix_login.ipynb#X20sZmlsZQ%3D%3D?line=4'>5</a>\u001b[0m \u001b[39m# update indexes\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tcapelle/work/examples/fix_login.ipynb#X20sZmlsZQ%3D%3D?line=5'>6</a>\u001b[0m \u001b[39mfor\u001b[39;00m cell \u001b[39min\u001b[39;00m nb[\u001b[39m\"\u001b[39m\u001b[39mcells\u001b[39m\u001b[39m\"\u001b[39m][idx\u001b[39m+\u001b[39m\u001b[39m2\u001b[39m:]:\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/tcapelle/work/examples/fix_login.ipynb#X20sZmlsZQ%3D%3D?line=6'>7</a>\u001b[0m cell\u001b[39m.\u001b[39midx_ \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/tcapelle/work/examples/fix_login.ipynb#X20sZmlsZQ%3D%3D?line=7'>8</a>\u001b[0m \u001b[39mreturn\u001b[39;00m nb\n",
"File \u001b[0;32m~/miniforge3/envs/nbdev2/lib/python3.10/site-packages/nbformat/_struct.py:125\u001b[0m, in \u001b[0;36mStruct.__getattr__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 123\u001b[0m result \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m[key]\n\u001b[1;32m 124\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mKeyError\u001b[39;00m:\n\u001b[0;32m--> 125\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mAttributeError\u001b[39;00m(key) \u001b[39mfrom\u001b[39;00m \u001b[39mNone\u001b[39m\n\u001b[1;32m 126\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 127\u001b[0m \u001b[39mreturn\u001b[39;00m result\n",
"\u001b[0;31mAttributeError\u001b[0m: idx_"
]
}
],
"outputs": [],
"source": [
"for nb_path in nbs_paths:\n",
" nb = nbformat.read(nb_path, 4)\n",
Expand All @@ -289,6 +267,13 @@
" nbformat.validate(nb)\n",
" nbformat.write(nb, nb_path)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -308,7 +293,8 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down
Loading