tif1 can be configured via a .tif1rc file, environment variables, or programmatically using the Config object. Configuration is loaded in this order (later sources override earlier ones):
- Default values
.tif1rcfile in home directory (~/.tif1rc)- Environment variables (prefixed with
TIF1_) - Programmatic
config.set()calls
get_config
- Global
Configobject
Config Methods
get(key, default=None)
Get the value for a configuration key.
key: Configuration key namedefault: Default value if key doesn’t exist
- Configuration value or default
set(key, value)
Update a configuration value in memory for the current session.
key: Configuration key namevalue: New value to set
Changes made with
set() only affect the current Python session. Use save() to persist changes to disk.save(path=None)
Save the current configuration to a JSON file.
path: Path to save config file. IfNone, saves to~/.tif1rc
Configuration Keys
Core Settings
Default DataFrame lib (
"pandas" or "polars").Enable or disable the multi-layer caching system (memory + SQLite).
Path where the SQLite cache database is stored.
Enable Pydantic validation of incoming JSON data.
Validation adds overhead. Disabled by default for performance.
Enable ultra-low latency mode for first-time loads. Skips loading full session data when only specific data is needed.
Network Settings
Network request timeout in seconds.
Number of times to retry a failed CDN request.
Maximum number of concurrent workers for parallel requests.
Maximum number of concurrent HTTP requests.
HTTP Session Settings
Enable HTTP/2 multiplexing for multiple requests over a single connection.
Disable HTTP/3 support.
Number of connection pools to maintain. If not set, automatically calculated as
max(256, max_workers, max_concurrent_requests, telemetry_prefetch_max_concurrent_requests).Most users should rely on automatic sizing. Only set explicitly for specific performance tuning.
Maximum connections per pool. If not set, automatically calculated as
max(512, pool_connections * 4) to handle burst traffic.Automatically sized to 4x pool_connections with a minimum of 512. Only override for specific use cases.
Keep-alive timeout in seconds.
Maximum requests per keep-alive connection.
User-Agent header for HTTP requests.
DNS resolvers with DoH fallback.
Telemetry Settings
Maximum concurrent requests for telemetry prefetching.
Logging Settings
Interval in seconds for logging connection pool statistics.
Advanced Configuration
These settings are for advanced users and performance tuning. Most users should use the defaults.
Cache Internals
Cache Internals
Number of cache operations before committing to SQLite.
Maximum items in the in-memory cache layer.
Maximum telemetry items in the in-memory cache.
SQLite connection timeout in seconds.
CDN Configuration
CDN Configuration
Retry & Circuit Breaker
Retry & Circuit Breaker
Exponential backoff multiplier for retries. Must be >= 1.0.
Add random jitter to retry delays to prevent thundering herd.
Maximum jitter amount in seconds. Must be > 0 to have effect.
Maximum delay between retries in seconds.
Number of consecutive failures before circuit breaker opens.
Seconds to wait before attempting to close circuit breaker.
HTTP/2 Configuration
HTTP/2 Configuration
Connection Pool Exhaustion
Connection Pool Exhaustion
Base backoff delay when connection pool is exhausted (seconds).
Maximum backoff delay for pool exhaustion (seconds).
Jitter amount for pool exhaustion backoff (seconds).
Data Validation
Data Validation
Prefetch Strategies
Prefetch Strategies
Automatically prefetch lap data when accessing a driver.
Prefetch all telemetry data on first lap telemetry request.
Prefetch all telemetry data immediately after loading laps.
Fill cache in background during ultra cold start mode.
Skip retries in ultra cold start mode for faster initial load.
Other Advanced Settings
Other Advanced Settings
Default logging level. Use
setup_logging() to change at runtime.Enable offline mode (cache-only, no network requests).
Enable CI mode (optimized for continuous integration environments).
Use categorical types for string columns in polars DataFrames.
Number of worker processes for parallel JSON parsing. 0 disables multiprocessing.
Configuration file format
The.tif1rc file is a JSON file with key-value pairs:
- Default:
~/.tif1rc - Custom: Specify path with
TIF1_CONFIG_PATHenvironment variable
Environment Variables
All configuration keys can be set via environment variables with theTIF1_ prefix:
Configuration Precedence
Configuration is loaded in this order (later overrides earlier):- Default values (hardcoded in library)
.tif1rcfile (~/.tif1rcorTIF1_CONFIG_PATH)- Environment variables (
TIF1_*) - Programmatic calls (
config.set())
Common configuration patterns
High-Performance Setup
Low-Latency Setup
Development Setup
Production Setup
Setting Log Level
While not part of theConfig object, you can set the log level using setup_logging:
Best Practices
- Use config files for persistent settings: Store common settings in
~/.tif1rc - Use environment variables for deployment: Configure per-environment settings
- Use programmatic API for runtime changes: Adjust settings based on workload
- Save after making changes: Call
config.save()to persist changes - Test configuration changes: Verify performance impact before deploying
- Monitor connection stats: Track connection reuse rate to optimize pooling
- Let pool sizing auto-calculate: Only override
pool_connectionsandpool_maxsizefor specific tuning needs - Keep validation disabled in production: Enable only for debugging or data quality checks
Summary
The configuration system provides:- Multiple configuration sources (file, env, API)
- Clear precedence rules
- Runtime configuration changes
- Persistent configuration storage
- Comprehensive settings for all aspects of the library
- Performance tuning capabilities
tif1 for your specific use case and environment.
Related Pages
Environment Variables
Env var reference
Installation
Setup guide
Best Practices
Configuration tips