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.54k stars 264 forks source link

[BUG] ff1.get_session not working #625

Open lalutir opened 3 months ago

lalutir commented 3 months ago

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."
}
theOehrly commented 3 months ago

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?

lalutir commented 3 months ago

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.

theOehrly commented 3 months ago

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

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