Fast-F1 icon indicating copy to clipboard operation
Fast-F1 copied to clipboard

[BUG] ff1.get_session not working

Open lalutir opened this issue 1 year ago • 3 comments

Describe the issue:

I tried loading data using the get_session function, however, it gives me an error saying failed to load any schedule data.

Reproduce the code example:

fp1 = ff1.get_session(2021, 1, 'FP1')

Error message:

logger      WARNING 	Failed to load schedule from FastF1 backend!
req            INFO 	No cached data found for season_schedule. Loading data...
_api           INFO 	Fetching season schedule...
logger      WARNING 	Failed to load schedule from F1 API backend!
logger      WARNING 	Failed to load schedule from Ergast API backend!

{
	"name": "ValueError",
	"message": "Failed to load any schedule data.",
	"stack": "---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[35], line 1
----> 1 fp1 = ff1.get_session(2021, 1, 'FP1')

File c:\\Users\\larsl\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\fastf1\\events.py:308, in get_session(year, gp, identifier, backend, force_ergast)
    240 def get_session(
    241         year: int,
    242         gp: Union[str, int],
   (...)
    246         force_ergast: bool = False,
    247 ) -> Session:
    248     \"\"\"Create a :class:`~fastf1.core.Session` object based on year, event name
    249     and session identifier.
    250 
   (...)
    306             from the ergast database to create the event schedule
    307     \"\"\"
--> 308     event = get_event(year, gp, force_ergast=force_ergast, backend=backend)
    309     return event.get_session(identifier)

File c:\\Users\\larsl\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\fastf1\\events.py:403, in get_event(year, gp, backend, force_ergast, strict_search, exact_match)
    348 def get_event(
    349         year: int,
    350         gp: Union[int, str],
   (...)
    355         exact_match: bool = False
    356 ) -> \"Event\":
    357     \"\"\"Create an :class:`~fastf1.events.Event` object for a specific
    358     season and gp.
    359 
   (...)
    401     .. versionadded:: 2.2
    402     \"\"\"
--> 403     schedule = get_event_schedule(year=year, include_testing=False,
    404                                   force_ergast=force_ergast,
    405                                   backend=backend)
    407     if isinstance(gp, str):
    408         event = schedule.get_event_by_name(
    409             gp, strict_search=strict_search, exact_match=exact_match)

File c:\\Users\\larsl\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\fastf1\\events.py:520, in get_event_schedule(year, include_testing, backend, force_ergast)
    517         break
    519 if schedule is None:  # raise Error if fallback failed as well
--> 520     raise ValueError(\"Failed to load any schedule data.\")
    522 if not include_testing:
    523     schedule = schedule[~schedule.is_testing()]

ValueError: Failed to load any schedule data."
}

lalutir avatar Jul 28 '24 06:07 lalutir

I think that clearing the content of your FastF1 cache directory should fix the problem. Apart from that, have you updated to the latest version?

theOehrly avatar Jul 28 '24 12:07 theOehrly

I already cleared the cache (just deleted the files, found out later there's a function for it) and I am updated to the latest version.

lalutir avatar Jul 28 '24 13:07 lalutir

Interesting. Can you post the output with log level set to "DEBUG"?

See https://docs.fastf1.dev/fastf1.html#fastf1.set_log_level

theOehrly avatar Jul 28 '24 13:07 theOehrly

Yep, I get the same errror. When you're getting all FP, Q, and R data for each event in schedule for multiple years, after the first year, you get the same error. Is it an API limit error? To continue, I need to restart my vs code

abrohit avatar Nov 29 '24 17:11 abrohit