Skip to content
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
462 changes: 462 additions & 0 deletions archive/md exp pts/md3 exp pts.csv

Large diffs are not rendered by default.

23 changes: 16 additions & 7 deletions archive/notebooks/calculate_team_recent_form.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from pathlib import Path\n",
"_chrome_start = Path(globals().get(\"__vsc_ipynb_file__\", Path.cwd())).resolve()\n",
"for _chrome_root in (_chrome_start, *_chrome_start.parents):\n",
" if (_chrome_root / \"chrome_runtime.py\").is_file():\n",
" sys.path.insert(0, str(_chrome_root))\n",
" break\n",
"else:\n",
" raise FileNotFoundError(\"Start Jupyter from the Kickbase project directory.\")\n",
"\n",
"# 1. Imports\n",
"import json\n",
"from datetime import datetime, timezone\n",
Expand All @@ -39,7 +49,11 @@
" \"Required packages are missing. Install undetected-chromedriver, \"\n",
" \"selenium, beautifulsoup4, and pandas in this Jupyter kernel, \"\n",
" \"then restart the kernel.\"\n",
" ) from exc\n"
" ) from exc\n",
"\n",
"from chrome_runtime import detect_chrome_major_version\n",
"CHROME_EXECUTABLE_PATH = uc.find_chrome_executable()\n",
"CHROME_MAJOR_VERSION = detect_chrome_major_version(CHROME_EXECUTABLE_PATH)\n"
]
},
{
Expand All @@ -63,7 +77,6 @@
" raise ValueError(\"Matchday must be a positive integer.\")\n",
"\n",
"# Edit these values if your local Chrome setup or preferred limits differ.\n",
"CHROME_MAJOR_VERSION = 150\n",
"# Set workflow configuration value: HEADLESS.\n",
"HEADLESS = False\n",
"# Set workflow configuration value: PAGE_LOAD_TIMEOUT_SECONDS.\n",
Expand Down Expand Up @@ -211,11 +224,7 @@
"driver = None\n",
"# Handle expected failures with a clear, actionable message.\n",
"try:\n",
" driver = uc.Chrome(\n",
" options=options,\n",
" version_main=CHROME_MAJOR_VERSION,\n",
" use_subprocess=True,\n",
" )\n",
" driver = uc.Chrome(options=options, use_subprocess=True, browser_executable_path=CHROME_EXECUTABLE_PATH, version_main=CHROME_MAJOR_VERSION)\n",
" driver.set_page_load_timeout(PAGE_LOAD_TIMEOUT_SECONDS)\n",
"except Exception as exc:\n",
" if driver is not None:\n",
Expand Down
22 changes: 16 additions & 6 deletions archive/notebooks/extract_sofascore_match_ids.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from pathlib import Path\n",
"_chrome_start = Path(globals().get(\"__vsc_ipynb_file__\", Path.cwd())).resolve()\n",
"for _chrome_root in (_chrome_start, *_chrome_start.parents):\n",
" if (_chrome_root / \"chrome_runtime.py\").is_file():\n",
" sys.path.insert(0, str(_chrome_root))\n",
" break\n",
"else:\n",
" raise FileNotFoundError(\"Start Jupyter from the Kickbase project directory.\")\n",
"\n",
"# Import the libraries required by this notebook step.\n",
"import json\n",
"from pathlib import Path\n",
Expand All @@ -49,14 +59,17 @@
"# Set workflow configuration value: OUTPUT_PATH_TEMPLATE.\n",
"OUTPUT_PATH_TEMPLATE = \"match_ids_{match_day}.json\"\n",
"# Set workflow configuration value: CHROME_MAJOR_VERSION.\n",
"CHROME_MAJOR_VERSION = 150\n",
"# Set workflow configuration value: WAIT_TIMEOUT_SECONDS.\n",
"WAIT_TIMEOUT_SECONDS = 30\n",
"\n",
"\n",
"# Define Extraction Error to keep related behaviour explicit.\n",
"class ExtractionError(RuntimeError):\n",
" \"\"\"Raised when match data cannot be retrieved or validated.\"\"\""
" \"\"\"Raised when match data cannot be retrieved or validated.\"\"\"\n",
"\n",
"from chrome_runtime import detect_chrome_major_version\n",
"CHROME_EXECUTABLE_PATH = uc.find_chrome_executable()\n",
"CHROME_MAJOR_VERSION = detect_chrome_major_version(CHROME_EXECUTABLE_PATH)\n"
]
},
{
Expand All @@ -78,10 +91,7 @@
" try:\n",
" # Handle expected failures with a clear, actionable message.\n",
" try:\n",
" driver = uc.Chrome(\n",
" options=options,\n",
" version_main=CHROME_MAJOR_VERSION,\n",
" )\n",
" driver = uc.Chrome(options=options, browser_executable_path=CHROME_EXECUTABLE_PATH, version_main=CHROME_MAJOR_VERSION)\n",
" except Exception as exc:\n",
" raise ExtractionError(\n",
" f\"Could not start Chrome {CHROME_MAJOR_VERSION}: {exc}\"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from pathlib import Path\n",
"_chrome_start = Path(globals().get(\"__vsc_ipynb_file__\", Path.cwd())).resolve()\n",
"for _chrome_root in (_chrome_start, *_chrome_start.parents):\n",
" if (_chrome_root / \"chrome_runtime.py\").is_file():\n",
" sys.path.insert(0, str(_chrome_root))\n",
" break\n",
"else:\n",
" raise FileNotFoundError(\"Start Jupyter from the Kickbase project directory.\")\n",
"\n",
"# 1. Imports\n",
"import json\n",
"from datetime import datetime, timezone\n",
Expand All @@ -42,7 +52,11 @@
" \"Required packages are missing. Install undetected-chromedriver, \"\n",
" \"selenium, beautifulsoup4, and pandas in this Jupyter kernel, \"\n",
" \"then restart the kernel.\"\n",
" ) from exc\n"
" ) from exc\n",
"\n",
"from chrome_runtime import detect_chrome_major_version\n",
"CHROME_EXECUTABLE_PATH = uc.find_chrome_executable()\n",
"CHROME_MAJOR_VERSION = detect_chrome_major_version(CHROME_EXECUTABLE_PATH)\n"
]
},
{
Expand All @@ -53,7 +67,6 @@
"outputs": [],
"source": [
"# 2. Parameters, Paths, and Snapshot Key\n",
"CHROME_MAJOR_VERSION = 150\n",
"# Set workflow configuration value: HEADLESS.\n",
"HEADLESS = False\n",
"# Set workflow configuration value: PAGE_LOAD_TIMEOUT_SECONDS.\n",
Expand Down Expand Up @@ -174,11 +187,7 @@
"driver = None\n",
"# Handle expected failures with a clear, actionable message.\n",
"try:\n",
" driver = uc.Chrome(\n",
" options=options,\n",
" version_main=CHROME_MAJOR_VERSION,\n",
" use_subprocess=True,\n",
" )\n",
" driver = uc.Chrome(options=options, use_subprocess=True, browser_executable_path=CHROME_EXECUTABLE_PATH, version_main=CHROME_MAJOR_VERSION)\n",
" driver.set_page_load_timeout(PAGE_LOAD_TIMEOUT_SECONDS)\n",
"except Exception as exc:\n",
" if driver is not None:\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from pathlib import Path\n",
"_chrome_start = Path(globals().get(\"__vsc_ipynb_file__\", Path.cwd())).resolve()\n",
"for _chrome_root in (_chrome_start, *_chrome_start.parents):\n",
" if (_chrome_root / \"chrome_runtime.py\").is_file():\n",
" sys.path.insert(0, str(_chrome_root))\n",
" break\n",
"else:\n",
" raise FileNotFoundError(\"Start Jupyter from the Kickbase project directory.\")\n",
"\n",
"# Import the libraries required by this notebook step.\n",
"import difflib\n",
"import json\n",
Expand Down Expand Up @@ -93,7 +103,6 @@
" ) from exc\n",
"\n",
"# Set workflow configuration value: CHROME_MAJOR_VERSION.\n",
"CHROME_MAJOR_VERSION = 150\n",
"# Set workflow configuration value: COMPETITION.\n",
"COMPETITION = \"Bundesliga\"\n",
"# Set workflow configuration value: SEASON.\n",
Expand Down Expand Up @@ -121,7 +130,11 @@
")\n",
"\n",
"# Set this to a Path only if the kernel does not start in the notebook directory.\n",
"NOTEBOOK_DIR_OVERRIDE = None\n"
"NOTEBOOK_DIR_OVERRIDE = None\n",
"\n",
"from chrome_runtime import detect_chrome_major_version\n",
"CHROME_EXECUTABLE_PATH = uc.find_chrome_executable()\n",
"CHROME_MAJOR_VERSION = detect_chrome_major_version(CHROME_EXECUTABLE_PATH)\n"
]
},
{
Expand Down Expand Up @@ -401,7 +414,7 @@
"try:\n",
" # Handle expected failures with a clear, actionable message.\n",
" try:\n",
" driver = uc.Chrome(version_main=150)\n",
" driver = uc.Chrome(browser_executable_path=CHROME_EXECUTABLE_PATH, version_main=CHROME_MAJOR_VERSION)\n",
" driver.set_page_load_timeout(PAGE_LOAD_TIMEOUT_SECONDS)\n",
" except Exception as exc:\n",
" raise RuntimeError(\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
"# Import the libraries required by this notebook step.\n",
"from __future__ import annotations\n",
"\n",
"import sys\n",
"from pathlib import Path\n",
"_chrome_start = Path(globals().get(\"__vsc_ipynb_file__\", Path.cwd())).resolve()\n",
"for _chrome_root in (_chrome_start, *_chrome_start.parents):\n",
" if (_chrome_root / \"chrome_runtime.py\").is_file():\n",
" sys.path.insert(0, str(_chrome_root))\n",
" break\n",
"else:\n",
" raise FileNotFoundError(\"Start Jupyter from the Kickbase project directory.\")\n",
"\n",
"\n",
"import csv\n",
"import json\n",
"import math\n",
Expand Down Expand Up @@ -49,7 +60,6 @@
" ) from exc\n",
"\n",
"# Set workflow configuration value: CHROME_MAJOR_VERSION.\n",
"CHROME_MAJOR_VERSION = 150\n",
"# Set workflow configuration value: HEADLESS.\n",
"HEADLESS = False\n",
"# Set workflow configuration value: PAGE_LOAD_TIMEOUT_SECONDS.\n",
Expand Down Expand Up @@ -85,7 +95,11 @@
" or isinstance(setting_value, bool)\n",
" or setting_value < 1\n",
" ):\n",
" raise ValueError(f\"{setting_name} must be a positive integer.\")\n"
" raise ValueError(f\"{setting_name} must be a positive integer.\")\n",
"\n",
"from chrome_runtime import detect_chrome_major_version\n",
"CHROME_EXECUTABLE_PATH = uc.find_chrome_executable()\n",
"CHROME_MAJOR_VERSION = detect_chrome_major_version(CHROME_EXECUTABLE_PATH)\n"
]
},
{
Expand Down Expand Up @@ -637,11 +651,7 @@
" driver = None\n",
" # Handle expected failures with a clear, actionable message.\n",
" try:\n",
" driver = uc.Chrome(\n",
" options=options,\n",
" version_main=150,\n",
" use_subprocess=True,\n",
" )\n",
" driver = uc.Chrome(options=options, use_subprocess=True, browser_executable_path=CHROME_EXECUTABLE_PATH, version_main=CHROME_MAJOR_VERSION)\n",
" driver.set_page_load_timeout(PAGE_LOAD_TIMEOUT_SECONDS)\n",
" print(\n",
" \"One reusable undetected Chrome session is ready \"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from pathlib import Path\n",
"_chrome_start = Path(globals().get(\"__vsc_ipynb_file__\", Path.cwd())).resolve()\n",
"for _chrome_root in (_chrome_start, *_chrome_start.parents):\n",
" if (_chrome_root / \"chrome_runtime.py\").is_file():\n",
" sys.path.insert(0, str(_chrome_root))\n",
" break\n",
"else:\n",
" raise FileNotFoundError(\"Start Jupyter from the Kickbase project directory.\")\n",
"\n",
"# Import the libraries required by this notebook step.\n",
"import json\n",
"from pathlib import Path\n",
Expand All @@ -47,14 +57,17 @@
"# Set workflow configuration value: OUTPUT_PATH.\n",
"OUTPUT_PATH = Path(\"match_ids.json\")\n",
"# Set workflow configuration value: CHROME_MAJOR_VERSION.\n",
"CHROME_MAJOR_VERSION = 150\n",
"# Set workflow configuration value: WAIT_TIMEOUT_SECONDS.\n",
"WAIT_TIMEOUT_SECONDS = 30\n",
"\n",
"\n",
"# Define Extraction Error to keep related behaviour explicit.\n",
"class ExtractionError(RuntimeError):\n",
" \"\"\"Raised when match data cannot be retrieved or validated.\"\"\""
" \"\"\"Raised when match data cannot be retrieved or validated.\"\"\"\n",
"\n",
"from chrome_runtime import detect_chrome_major_version\n",
"CHROME_EXECUTABLE_PATH = uc.find_chrome_executable()\n",
"CHROME_MAJOR_VERSION = detect_chrome_major_version(CHROME_EXECUTABLE_PATH)\n"
]
},
{
Expand All @@ -76,10 +89,7 @@
" try:\n",
" # Handle expected failures with a clear, actionable message.\n",
" try:\n",
" driver = uc.Chrome(\n",
" options=options,\n",
" version_main=CHROME_MAJOR_VERSION,\n",
" )\n",
" driver = uc.Chrome(options=options, browser_executable_path=CHROME_EXECUTABLE_PATH, version_main=CHROME_MAJOR_VERSION)\n",
" except Exception as exc:\n",
" raise ExtractionError(\n",
" f\"Could not start Chrome {CHROME_MAJOR_VERSION}: {exc}\"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from pathlib import Path\n",
"_chrome_start = Path(globals().get(\"__vsc_ipynb_file__\", Path.cwd())).resolve()\n",
"for _chrome_root in (_chrome_start, *_chrome_start.parents):\n",
" if (_chrome_root / \"chrome_runtime.py\").is_file():\n",
" sys.path.insert(0, str(_chrome_root))\n",
" break\n",
"else:\n",
" raise FileNotFoundError(\"Start Jupyter from the Kickbase project directory.\")\n",
"\n",
"# Import the libraries required by this notebook step.\n",
"import json\n",
"from pathlib import Path\n",
Expand All @@ -46,14 +56,17 @@
"# Set workflow configuration value: OUTPUT_PATH_TEMPLATE.\n",
"OUTPUT_PATH_TEMPLATE = \"match_ids_{match_day}.json\"\n",
"# Set workflow configuration value: CHROME_MAJOR_VERSION.\n",
"CHROME_MAJOR_VERSION = 150\n",
"# Set workflow configuration value: WAIT_TIMEOUT_SECONDS.\n",
"WAIT_TIMEOUT_SECONDS = 30\n",
"\n",
"\n",
"# Define Extraction Error to keep related behaviour explicit.\n",
"class ExtractionError(RuntimeError):\n",
" \"\"\"Raised when match data cannot be retrieved or validated.\"\"\""
" \"\"\"Raised when match data cannot be retrieved or validated.\"\"\"\n",
"\n",
"from chrome_runtime import detect_chrome_major_version\n",
"CHROME_EXECUTABLE_PATH = uc.find_chrome_executable()\n",
"CHROME_MAJOR_VERSION = detect_chrome_major_version(CHROME_EXECUTABLE_PATH)\n"
]
},
{
Expand All @@ -74,10 +87,7 @@
" try:\n",
" # Handle expected failures with a clear, actionable message.\n",
" try:\n",
" driver = uc.Chrome(\n",
" options=options,\n",
" version_main=CHROME_MAJOR_VERSION,\n",
" )\n",
" driver = uc.Chrome(options=options, browser_executable_path=CHROME_EXECUTABLE_PATH, version_main=CHROME_MAJOR_VERSION)\n",
" except Exception as exc:\n",
" raise ExtractionError(\n",
" f\"Could not start Chrome {CHROME_MAJOR_VERSION}: {exc}\"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from pathlib import Path\n",
"_chrome_start = Path(globals().get(\"__vsc_ipynb_file__\", Path.cwd())).resolve()\n",
"for _chrome_root in (_chrome_start, *_chrome_start.parents):\n",
" if (_chrome_root / \"chrome_runtime.py\").is_file():\n",
" sys.path.insert(0, str(_chrome_root))\n",
" break\n",
"else:\n",
" raise FileNotFoundError(\"Start Jupyter from the Kickbase project directory.\")\n",
"\n",
"# Imports\n",
"import json\n",
"from fractions import Fraction\n",
Expand All @@ -34,7 +44,11 @@
" raise ImportError(\n",
" \"Browser dependencies are missing. Install them in this Jupyter kernel with \"\n",
" \"'%pip install undetected-chromedriver selenium', then restart the kernel.\"\n",
" ) from exc"
" ) from exc\n",
"\n",
"from chrome_runtime import detect_chrome_major_version\n",
"CHROME_EXECUTABLE_PATH = uc.find_chrome_executable()\n",
"CHROME_MAJOR_VERSION = detect_chrome_major_version(CHROME_EXECUTABLE_PATH)\n"
]
},
{
Expand All @@ -47,7 +61,6 @@
"matchday = 1 # Change this value to process another Bundesliga matchday.\n",
"\n",
"# Notebook constants\n",
"CHROME_MAJOR_VERSION = 150\n",
"# Set workflow configuration value: PAGE_LOAD_TIMEOUT_SECONDS.\n",
"PAGE_LOAD_TIMEOUT_SECONDS = 30\n",
"# Set workflow configuration value: WAIT_TIMEOUT_SECONDS.\n",
Expand Down Expand Up @@ -215,11 +228,7 @@
"driver = None\n",
"# Handle expected failures with a clear, actionable message.\n",
"try:\n",
" driver = uc.Chrome(\n",
" options=options,\n",
" version_main=CHROME_MAJOR_VERSION,\n",
" use_subprocess=True,\n",
" )\n",
" driver = uc.Chrome(options=options, use_subprocess=True, browser_executable_path=CHROME_EXECUTABLE_PATH, version_main=CHROME_MAJOR_VERSION)\n",
" driver.set_page_load_timeout(PAGE_LOAD_TIMEOUT_SECONDS)\n",
" driver.execute_cdp_cmd(\"Network.enable\", {})\n",
"except Exception as exc:\n",
Expand Down
Loading
Loading