Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/TracingInsights/tif1/llms.txt

Use this file to discover all available pages before exploring further.

Function Signature

def get_sessions(year: int, event: str) -> list[str]

Description

Get the list of available session names for a specific event in a given season. This function returns the actual session structure for the event, which may vary based on the weekend format (conventional, sprint, etc.). The returned list is ordered as the sessions occur during the weekend.

Parameters

year
int
required
Championship year. Must be 2018 or later.
event
str
required
Event name. Must be the full event name (e.g., "Monaco Grand Prix", "British Grand Prix").This should match the EventName from the event schedule. Partial names or abbreviations may not work reliably.

Returns

sessions
list[str]
Ordered list of session names available for the event. Common session names include:Conventional Weekend:
  • "Practice 1"
  • "Practice 2"
  • "Practice 3"
  • "Qualifying"
  • "Race"
Sprint Weekend (2023+):
  • "Practice 1"
  • "Qualifying"
  • "Sprint Shootout"
  • "Sprint"
  • "Race"
Sprint Weekend (2021-2022):
  • "Practice 1"
  • "Qualifying"
  • "Practice 2"
  • "Sprint"
  • "Race"
The exact session structure depends on the event format for that year.

Examples

Get Sessions for a Conventional Weekend

import tif1

# Get sessions for Monaco (conventional format)
sessions = tif1.get_sessions(2025, "Monaco Grand Prix")
print(sessions)
# Output: ['Practice 1', 'Practice 2', 'Practice 3', 'Qualifying', 'Race']

Get Sessions for a Sprint Weekend

# Get sessions for a sprint weekend event
sessions = tif1.get_sessions(2024, "Austrian Grand Prix")
print(sessions)
# Output (2024 sprint format):
# ['Practice 1', 'Qualifying', 'Sprint Shootout', 'Sprint', 'Race']

Iterate Through All Sessions

sessions = tif1.get_sessions(2025, "British Grand Prix")

# Access each session
for i, session_name in enumerate(sessions, 1):
    print(f"Session {i}: {session_name}")
    
# Create session objects
for session_name in sessions:
    session = tif1.get_session(2025, "British Grand Prix", session_name)
    print(f"Loading {session_name}...")
    session.load()

Check if Specific Session Exists

sessions = tif1.get_sessions(2025, "Monaco Grand Prix")

# Check for sprint
has_sprint = "Sprint" in sessions
print(f"Has sprint: {has_sprint}")

# Check for Practice 3
has_fp3 = "Practice 3" in sessions
print(f"Has Practice 3: {has_fp3}")

Get Sessions for All Events

events = tif1.get_events(2025)

# Get sessions for each event
for idx, event in events.iterrows():
    if event['RoundNumber'] > 0:  # Skip testing
        event_name = event['EventName']
        sessions = tif1.get_sessions(2025, event_name)
        print(f"{event_name}: {len(sessions)} sessions")
        print(f"  Sessions: {', '.join(sessions)}")

Using Event Object Method

# Alternative: Use Event object's helper method
events = tif1.get_events(2025)
event = events.get_event("Silverstone")

# Get session name (resolves abbreviations and numbers)
session_name = event.get_session_name("FP1")  # Returns "Practice 1"
session_name = event.get_session_name(1)      # Returns first session
session_name = event.get_session_name("Q")    # Returns "Qualifying"

Dynamic Session Loading

event_name = "Monaco Grand Prix"
sessions = tif1.get_sessions(2025, event_name)

# Load all sessions dynamically
session_data = {}
for session_name in sessions:
    try:
        session = tif1.get_session(2025, event_name, session_name)
        session.load()
        session_data[session_name] = session
        print(f"✓ Loaded {session_name}")
    except Exception as e:
        print(f"✗ Failed to load {session_name}: {e}")

Notes

  • The event name must match exactly as it appears in the event schedule
  • Session lists are cached internally for performance
  • If event metadata is unavailable, returns a standard conventional weekend session list: ["Practice 1", "Practice 2", "Practice 3", "Qualifying", "Race"]
  • Sprint weekend formats changed between 2021-2022 and 2023+:
    • 2021-2022: Sprint Qualifying was called “Sprint”
    • 2023+: Separate “Sprint Shootout” and “Sprint” sessions

Error Handling

# Handle missing/invalid events
try:
    sessions = tif1.get_sessions(2025, "Invalid Event Name")
except Exception as e:
    print(f"Event not found: {e}")
    # Falls back to default session list
    sessions = ["Practice 1", "Practice 2", "Practice 3", "Qualifying", "Race"]

See Also

Build docs developers (and LLMs) love