TabPFN Common Utilities

0.2.19 · active · verified Fri Apr 17

TabPFN Common Utilities (tabpfn-common-utils) provides shared helper functions, primarily focusing on telemetry and logging, used across various TabPFN codebases. It is currently at version 0.2.19 and maintains a frequent release cadence, often with minor updates and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `TelemetryClient` and `TabPFNLogger`. The `TelemetryClient` is configured to use an environment variable for the PostHog API key, falling back to a dummy key for development. It then logs an informational message and captures a custom telemetry event.

import os
from tabpfn_common_utils.telemetry.client import TelemetryClient
from tabpfn_common_utils.telemetry.logger import TabPFNLogger

# Initialize TelemetryClient (API key can be passed directly or via POSTHOG_API_KEY env var)
# For local testing, set POSTHOG_API_KEY in your environment, or pass a dummy string.
# Data won't be sent if API key is invalid or not set in a production context.
telemetry_client = TelemetryClient(
    api_key=os.environ.get('POSTHOG_API_KEY', 'phc_dummy_key_for_dev'),
    project_group="quickstart",
    project_name="example"
)

# Initialize TabPFNLogger
logger = TabPFNLogger(telemetry_client=telemetry_client)

# Log a message
logger.info("Quickstart example executed.")

# Capture a custom event
telemetry_client.capture(
    event_name="quickstart_event",
    properties={
        "data_point_count": 100,
        "model_type": "test_model"
    }
)

print("Telemetry client and logger initialized and events captured (if API key is valid).")

view raw JSON →