theOehrly / Fast-F1

FastF1 is a python package for accessing and analyzing Formula 1 results, schedules, timing data and telemetry
https://docs.fastf1.dev
MIT License
2.41k stars 255 forks source link

[BUG] 2022 session data not available #615

Closed MattJC7 closed 1 month ago

MattJC7 commented 1 month ago

Describe the issue:

I'm able to load an event schedule for 2022, however I'm not able to load any session data from this season.

I am able to load data from every other year I've tried (I probably haven't tried them all).

(Please note I'm a newbie from CS50x using your API for my final project, so I'm sorry if I've missed something)

Reproduce the code example:

@app.route("/results")
def results():
    year = request.args.get('year')
    session_name = request.args.get('session')
    event = request.args.get('event')
    try:
        session = fastf1.get_session(int(year), event, session_name)
        session.load()
    except (ValueError, KeyError):
        return render_template("error.html", error='Session data not found.')
    df = session.results
    return render_template("results.html", tables=[df.to_html(classes='table table-striped table-dark table-hover table-responsive', header="true", index=False, justify='center')])

Error message:

DEBUG:requests_cache.policy.actions:Cache directives from request headers: CacheDirectives()
DEBUG:requests_cache.policy.actions:Pre-read cache checks: Passed
DEBUG:requests_cache.policy.actions:Post-read cache actions: CacheActions(expire_after=datetime.timedelta(seconds=43200))
core           INFO     Loading data for Bahrain Grand Prix - Race [v3.3.9]
INFO:fastf1.fastf1.core:Loading data for Bahrain Grand Prix - Race [v3.3.9]
req            INFO     No cached data found for session_info. Loading data...
INFO:fastf1.fastf1.req:No cached data found for session_info. Loading data...
_api           INFO     Fetching session info data...
INFO:fastf1.api:Fetching session info data...
DEBUG:requests_cache.policy.actions:Cache directives from request headers: CacheDirectives()
DEBUG:requests_cache.policy.actions:Pre-read cache checks: Passed
DEBUG:requests_cache.policy.actions:Post-read cache actions: CacheActions(expire_after=datetime.timedelta(seconds=43200), send_request=True)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): livetiming.formula1.com:443
DEBUG:urllib3.connectionpool:https://livetiming.formula1.com:443 "GET /static/2022/2022-03-20_Bahrain_Grand_Prix/2022-03-20_Race/SessionInfo.jsonStream HTTP/11" 403 None
DEBUG:requests_cache.policy.actions:Cache directives from response headers: CacheDirectives(max_age=3600)
DEBUG:charset_normalizer:Encoding detection: utf_8 is most likely the one.
DEBUG:requests_cache.policy.actions:Pre-write cache checks: disabled status
DEBUG:requests_cache.session:Skipping cache write for URL: https://livetiming.formula1.com/static/2022/2022-03-20_Bahrain_Grand_Prix/2022-03-20_Race/SessionInfo.jsonStream
DEBUG:charset_normalizer:Encoding detection: utf_8 is most likely the one.
logger      WARNING     Failed to load session info data!
WARNING:fastf1.fastf1.core:Failed to load session info data!
DEBUG:fastf1.fastf1.core:Traceback for failure in session info data
Traceback (most recent call last):
  File "/home/matt7/Documents/coding/Projects/cs50_final_project/.venv/lib/python3.10/site-packages/fastf1/logger.py", line 151, in __wrapped
    return func(*args, **kwargs)
  File "/home/matt7/Documents/coding/Projects/cs50_final_project/.venv/lib/python3.10/site-packages/fastf1/core.py", line 1462, in _load_session_info
    self._session_info = api.session_info(self.api_path,
  File "/home/matt7/Documents/coding/Projects/cs50_final_project/.venv/lib/python3.10/site-packages/fastf1/req.py", line 445, in _cached_api_request
    data = func(api_path, **func_kwargs)
  File "/home/matt7/Documents/coding/Projects/cs50_final_project/.venv/lib/python3.10/site-packages/fastf1/_api.py", line 1665, in session_info
    raise SessionNotAvailableError(
fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.
req            INFO     No cached data found for driver_info. Loading data...
INFO:fastf1.fastf1.req:No cached data found for driver_info. Loading data...
_api           INFO     Fetching driver list...
INFO:fastf1.api:Fetching driver list...
DEBUG:requests_cache.policy.actions:Cache directives from request headers: CacheDirectives()
DEBUG:requests_cache.policy.actions:Pre-read cache checks: Passed
DEBUG:requests_cache.policy.actions:Post-read cache actions: CacheActions(expire_after=datetime.timedelta(seconds=43200), send_request=True)
DEBUG:urllib3.connectionpool:Resetting dropped connection: livetiming.formula1.com
DEBUG:urllib3.connectionpool:https://livetiming.formula1.com:443 "GET /static/2022/2022-03-20_Bahrain_Grand_Prix/2022-03-20_Race/DriverList.jsonStream HTTP/11" 403 None
DEBUG:requests_cache.policy.actions:Cache directives from response headers: CacheDirectives(max_age=3600)
DEBUG:charset_normalizer:Encoding detection: utf_8 is most likely the one.
DEBUG:requests_cache.policy.actions:Pre-write cache checks: disabled status
DEBUG:requests_cache.session:Skipping cache write for URL: https://livetiming.formula1.com/static/2022/2022-03-20_Bahrain_Grand_Prix/2022-03-20_Race/DriverList.jsonStream
DEBUG:charset_normalizer:Encoding detection: utf_8 is most likely the one.
core        WARNING     Failed to load extended driver information!
WARNING:fastf1.fastf1.core:Failed to load extended driver information!
DEBUG:fastf1.fastf1.core:Exception while loading driver list
Traceback (most recent call last):
  File "/home/matt7/Documents/coding/Projects/cs50_final_project/.venv/lib/python3.10/site-packages/fastf1/core.py", line 2252, in _drivers_from_f1_api
    f1di = api.driver_info(self.api_path, livedata=livedata)
  File "/home/matt7/Documents/coding/Projects/cs50_final_project/.venv/lib/python3.10/site-packages/fastf1/req.py", line 445, in _cached_api_request
    data = func(api_path, **func_kwargs)
  File "/home/matt7/Documents/coding/Projects/cs50_final_project/.venv/lib/python3.10/site-packages/fastf1/_api.py", line 1513, in driver_info
    raise SessionNotAvailableError(
fastf1._api.SessionNotAvailableError: No data for this session! If this session only finished recently, please try again in a few minutes.
INFO:werkzeug:127.0.0.1 - - [15/Jul/2024 18:48:15] "GET /results?year=2022&session=Race&event=Bahrain%20Grand%20Prix HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [15/Jul/2024 18:48:15] "GET /static/styles.css HTTP/1.1" 304 -
MattJC7 commented 1 month ago

I've just noticed that I'm able to load Bahrain 2022 qualifying with the same code. Of the other sessions I've tried, none of the race or sprint sessions load.

Casper-Guo commented 1 month ago

This has been reported in #603 and #606 as well. Seems to be an upstream issue in FOM's end so not much we can do here

MattJC7 commented 1 month ago

This has been reported in #603 and #606 as well. Seems to be an upstream issue in FOM's end so not much we can do here

Apologies, I skimmed the issues so should have checked more thoroughly! Thanks.

theOehrly commented 1 month ago

Fixed now by providing a mirror server as a fallback for the problematic seasons. More info here https://github.com/theOehrly/Fast-F1/issues/607#issuecomment-2252323988