From 193168c7ebad0ae934fd2de53537a3f649f16e98 Mon Sep 17 00:00:00 2001 From: theOehrly <23384863+theOehrly@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:04:10 +0200 Subject: [PATCH] FIX: session results for Sprint Quali in 2024 not calculated (#597) --- fastf1/core.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/fastf1/core.py b/fastf1/core.py index c49f7a091..44bbace46 100644 --- a/fastf1/core.py +++ b/fastf1/core.py @@ -2293,16 +2293,23 @@ def _get_data(): return self._ergast.get_race_results( self.event.year, self.event.RoundNumber ) + elif session_name == 'Qualifying': return self._ergast.get_qualifying_results( self.event.year, self.event.RoundNumber ) - elif session_name in ('Sprint', 'Sprint Qualifying'): + + # double condition because of reuse of the "Sprint Qualifying" name + # for a race-like session in 2018 and a quali-like session in 2024+ + # Ergast only supports the race-like sprint results. + elif ('Sprint' in session_name + and session_name in self._RACE_LIKE_SESSIONS): return self._ergast.get_sprint_results( self.event.year, self.event.RoundNumber ) + else: - # TODO: Use Ergast when/if it supports sprint shootout sessions + # TODO: Use Ergast when it supports quali-like sprint results # return self._ergast.get_sprint_shootout_results( # self.event.year, self.event.RoundNumber # ) @@ -2311,8 +2318,15 @@ def _get_data(): response = _get_data() if not response or not response.content: - _logger.warning("No result data for this session available on " - "Ergast! (This is expected for recent sessions)") + if (('Sprint' in session_name) + and (session_name in self._QUALI_LIKE_SESSIONS)): + _logger.warning(f"{session_name} is not supported by " + f"Ergast! Limited results are calculated from " + f"timing data.") + else: + _logger.warning("No result data for this session available on " + "Ergast! (This is expected for recent " + "sessions)") return None data = response.content[0]