tessl install tessl/pypi-influxdb-client@1.49.0Comprehensive Python client library for InfluxDB 2.x with sync/async APIs for writing, querying, and managing time series data.
Agent Success
Agent success rate when using this tile
82%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.19x
Baseline
Agent success rate without this tile
69%
Build a system that ingests sensor data from multiple sources and writes it to InfluxDB using appropriate data structures for each source type.
You need to implement a data ingestion module that handles three different sensor data sources:
Temperature sensors provide readings as Python dictionaries with the following structure:
{
"sensor_id": "temp_001",
"temperature": 23.5,
"humidity": 65,
"pressure": 1013,
"timestamp": 1609459200000000000 # nanoseconds
}The pressure field should be stored as an unsigned integer, while temperature and humidity should be stored as floats.
Location trackers provide data as NamedTuples:
LocationData = namedtuple('LocationData', ['device_id', 'latitude', 'longitude', 'altitude', 'timestamp'])Environmental monitors use Python dataclasses:
@dataclass
class EnvironmentalData:
monitor_id: str
co2_level: int
noise_level: float
light_intensity: int
timestamp: intCreate a function ingest_temperature_data(client, bucket, data_dict) that writes temperature sensor dictionaries to InfluxDB with:
Create a function ingest_location_data(client, bucket, location_tuple) that writes location tracker NamedTuples to InfluxDB with:
Create a function ingest_environmental_data(client, bucket, env_data) that writes environmental monitor dataclasses to InfluxDB with:
@generates
from influxdb_client import InfluxDBClient
from typing import Dict, NamedTuple
from dataclasses import dataclass
def ingest_temperature_data(client: InfluxDBClient, bucket: str, data_dict: Dict) -> None:
"""
Ingest temperature sensor data from dictionary format.
Args:
client: InfluxDBClient instance
bucket: Target bucket name
data_dict: Dictionary containing sensor data
"""
pass
def ingest_location_data(client: InfluxDBClient, bucket: str, location_tuple: NamedTuple) -> None:
"""
Ingest location tracker data from NamedTuple format.
Args:
client: InfluxDBClient instance
bucket: Target bucket name
location_tuple: NamedTuple containing location data
"""
pass
def ingest_environmental_data(client: InfluxDBClient, bucket: str, env_data: dataclass) -> None:
"""
Ingest environmental monitor data from dataclass format.
Args:
client: InfluxDBClient instance
bucket: Target bucket name
env_data: Dataclass containing environmental data
"""
passGiven a temperature dictionary with sensor_id="temp_001", temperature=23.5, humidity=65, pressure=1013, and timestamp, when ingested, the data is written to InfluxDB with pressure as unsigned int @test
Given a LocationData NamedTuple with device_id="tracker_01", latitude=37.7749, longitude=-122.4194, altitude=10, and timestamp, when ingested, the data is written to InfluxDB correctly @test
Given an EnvironmentalData dataclass with monitor_id="env_monitor_001", co2_level=400, noise_level=45.5, light_intensity=750, and timestamp, when ingested, the data is written to InfluxDB correctly @test
Provides InfluxDB client functionality for writing time-series data with support for custom data type serialization.
@satisfied-by