Skip to content

Commit

Permalink
Updated to show logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryandaydev committed Oct 31, 2024
1 parent defcceb commit fbd87cd
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 13 deletions.
65 changes: 61 additions & 4 deletions example_sdk_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,82 @@
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" player_id gsis_id first_name last_name position last_changed_date \\\n",
"0 1001 00-0023459 Aaron Rodgers QB 2024-04-18 \n",
"1 1002 00-0023853 Matt Prater K 2024-04-18 \n",
"2 1003 00-0024243 Marcedes Lewis TE 2024-04-18 \n",
"3 1004 00-0025565 Nick Folk K 2024-04-18 \n",
"4 1005 00-0025580 Mason Crosby K 2024-04-18 \n",
".. ... ... ... ... ... ... \n",
"95 1096 00-0032392 Austin Hooper TE 2024-04-18 \n",
"96 1097 00-0032394 Nick Vannett TE 2024-04-18 \n",
"97 1098 00-0032398 Chris Moore WR 2024-04-18 \n",
"98 1099 00-0032434 Brandon Allen QB 2024-04-18 \n",
"99 1100 00-0032436 Jeff Driskel QB 2024-04-18 \n",
"\n",
" performances \n",
"0 [{'performance_id': 2501, 'player_id': 1001, '... \n",
"1 [{'performance_id': 2502, 'player_id': 1002, '... \n",
"2 [{'performance_id': 2503, 'player_id': 1003, '... \n",
"3 [{'performance_id': 2504, 'player_id': 1004, '... \n",
"4 [{'performance_id': 2505, 'player_id': 1005, '... \n",
".. ... \n",
"95 [{'performance_id': 2596, 'player_id': 1096, '... \n",
"96 [{'performance_id': 2597, 'player_id': 1097, '... \n",
"97 [{'performance_id': 2598, 'player_id': 1098, '... \n",
"98 [{'performance_id': 2599, 'player_id': 1099, '... \n",
"99 [{'performance_id': 2600, 'player_id': 1100, '... \n",
"\n",
"[100 rows x 7 columns]\n"
]
}
],
"source": [
"from pyswc import SWCClient, SWCConfig\n",
"from swcpy import SWCClient, SWCConfig\n",
"import pandas as pd\n",
"\n",
"config = SWCConfig()\n",
"client = SWCClient(config)\n",
"sdk_players = client.list_players()\n",
"\n",
"#convert the list of player instances to dictionaries\n",
"df = dp.DataFrame([player.model_dump() for player in sdk_players])\n",
"df = pd.DataFrame([player.model_dump() for player in sdk_players])\n",
"print(df)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down
73 changes: 64 additions & 9 deletions notebooks_with_client/shark_league_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -34,7 +34,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -43,10 +43,10 @@
"\n",
"logging.basicConfig(\n",
" filename='shark_notebook.log', \n",
" level=logging.INFO, \n",
"\n",
" level=logging.DEBUG, \n",
")\n",
"\n",
"logger = logging.getLogger(__name__) )"
"logger = logging.getLogger(__name__) "
]
},
{
Expand All @@ -58,13 +58,18 @@
},
{
"cell_type": "code",
"execution_count": 40,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"base_url = \"[input base url]\"\n"
"base_url = \"http://0.0.0.0:8000/\"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -75,9 +80,59 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>ppr_12_max_points</th>\n",
" <th>half_ppr_8_max_points</th>\n",
" </tr>\n",
" <tr>\n",
" <th>year</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2023</th>\n",
" <td>16716.0</td>\n",
" <td>12304.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ppr_12_max_points half_ppr_8_max_points\n",
"year \n",
"2023 16716.0 12304.0"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"logger.debug(f\"base_url: {base_url}, api_endpoint: {base_url,swc.LIST_WEEKS_ENDPOINT}\")\n",
"week_api_response = swc.call_api_endpoint(base_url,swc.LIST_WEEKS_ENDPOINT)\n",
Expand Down

0 comments on commit fbd87cd

Please sign in to comment.