Fix missing TeamId for DNS drivers (fix #809)#922
Conversation
Move the implementations of recursive_dict_get, to_datetime, and to_timedelta to fastf1.internals._utils, which is the appropriate location for internal utilities. Update all internal imports in events.py, _api.py, core.py, and livetiming/data.py to use the new internal module directly. The public API in fastf1.utils is now deprecated wrappers that: 1. Emit a DeprecationWarning when called 2. Delegate to the internal implementations 3. Maintain backward compatibility for external callers Fixes theOehrly#884 Co-Authored-By: Zippy AI <tomkinsbale@icloud.com>
When a driver DNSs (does not start) a session, Ergast may not have their entry, resulting in a missing TeamId even though TeamName is available from the F1 API. This fix looks up the TeamId from a teammate who has it, using TeamName as the linking key. Fixes theOehrly#809 Co-Authored-By: Zippy AI <tomkinsbale@icloud.com>
|
Your PR description is missing the required AI disclosure. Please review Fastf1's AI policy, and then update your PR to include a section titled AI Disclosure (verbatim). PRs without AI disclosures will not be reviewed. |
|
Diff overlaps with #921. In this case I will definitely urge keeping the utils submodule unchanged and PR with only the diffs relevant to the fix. |
|
Fair point — I'll strip the utils submodule changes from this PR and keep only the TeamId fix. Will update shortly. |
|
On second look, the two commits are tightly coupled — commit 1 changes import paths (utils → internals._utils) and commit 2's TeamId fix is built on top of those changed imports. Stripping commit 1 alone would break the build. Two options:
Which would you prefer? |
|
No problem with closing PR. New PR with minimized diff sounds good to me. |
Summary
When a driver DNSs (does not start) a session, Ergast may not have their entry in the results. This results in a missing
TeamIdeven thoughTeamNameis available from the F1 API.This fix looks up the
TeamIdfrom a teammate who has it, usingTeamNameas the linking key. This is applied after the join of F1 API and Ergast data is complete.Example: Bortoleto (BOR) crashed in the sprint race at 2025 São Paulo GP, missing qualifying. Ergast has no entry for him in qualifying, so his
TeamIdwasnanwhileTeamName("Kick Sauber") was correctly populated.Fix
After the F1 API / Ergast join, check for rows with missing
TeamIdbut validTeamName. For each such row, look up theTeamIdfrom another driver on the same team who has a validTeamId.Testing
Unable to test locally due to data fetching requirements and Python version constraints. The fix follows the existing code patterns and the reporter's suggested approach in the issue.
Checklist
AI Disclosure
AI was used as a coding assistant. I (the human author) reviewed all AI-generated code and changes.