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.46k stars 259 forks source link

[BUG] 2022 Race 1 (Bahrain) Race session crashes on `session.load()` #606

Closed pbulsink closed 2 months ago

pbulsink commented 3 months ago

Describe the issue:

Discovered via f1dataR R package - our randomly selected race that is used for unit testing crashes when loaded (including with new caches). We get a failure when loading 2022 Bahrain Race (here).

Reproduce the code example:

>>> import fastf1
>>> fastf1.set_log_level('WARNING')
>>> fastf1.Cache.enable_cache('~/Documents/f1dataR/cache')
>>> session=fastf1.get_session(2022, "Bahrain", "R")
>>> session.load()

Error message:

KeyError: 'DriverNumber'
Cell In[6], line 1
----> 1 session.load()
Hide Traceback
File ~/.virtualenvs/f1dataRp311/lib/python3.11/site-packages/fastf1/core.py:1424, in Session.load(self, laps, telemetry, weather, messages, livedata)
   1419 _logger.info(f"Loading data for "
   1420              f"{self.event['EventName']} - {self.name}"
   1421              f" [v{fastf1.__version__}]")
   1423 self._load_session_info(livedata=livedata)
-> 1424 self._load_drivers_results(livedata=livedata)
   1426 if self.f1_api_support:
   1427     if laps:

File ~/.virtualenvs/f1dataRp311/lib/python3.11/site-packages/fastf1/core.py:2189, in Session._load_drivers_results(self, livedata)
   2185 # try loading from both sources if they are supported
   2186 # data is joined afterwards depending on availability
   2187 if self.f1_api_support:
   2188     # load driver info from f1 api
-> 2189     driver_info_f1 = self._drivers_from_f1_api(livedata=livedata)
   2190 if not self.event.is_testing():
   2191     # load driver info from ergast
   2192     driver_info_ergast = self._drivers_results_from_ergast(
   2193         load_drivers=True, load_results=True
   2194     )

File ~/.virtualenvs/f1dataRp311/lib/python3.11/site-packages/fastf1/core.py:2273, in Session._drivers_from_f1_api(self, livedata)
   2270         for first, last in zip(driver_info['FirstName'],
   2271                                driver_info['LastName']):
   2272             driver_info['FullName'].append(f"{first} {last}")
-> 2273 return pd.DataFrame(driver_info, index=driver_info['DriverNumber'])
Casper-Guo commented 3 months ago

Same as reported in #603

theOehrly commented 3 months ago

Yes, I was hoping that this problem would go away faster. Nothing that we can do right now, sadly.

SwanAG12 commented 2 months ago

Having the same issue with all 2022 sessions, 2021 and 2023 working though. Any estimates on how long this will take to fix?

theOehrly commented 2 months ago

Having the same issue with all 2022 sessions, 2021 and 2023 working though. Any estimates on how long this will take to fix?

Not really, after all I don't know what F1 are doing. So there's no way to estimate how long this issue might persist. But there have been some improvements already, so I guess they are working on it.

theOehrly commented 2 months 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