Ctrl + K
DocumentationLog inGet started

tessl/pypi-influxdb-client

tessl install tessl/pypi-influxdb-client@1.49.0

Comprehensive 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%

task.mdevals/scenario-4/

Sensor Data Logger

Build a system that reads sensor data from multiple sources and writes it to a time-series database with appropriate numeric field types to avoid type conflicts.

Background

Different sensors produce numeric values in different formats. Some sensors return signed integers (temperature in Celsius), others return unsigned integers (counts, IDs), and some return floating-point values (pressure in atmospheres). When writing this data to a time-series database, it's important to specify the correct numeric type for each field to prevent schema conflicts and ensure data integrity.

Requirements

Create a Python module that:

  1. Accepts sensor readings with mixed numeric types (signed integers, unsigned integers, and floats)
  2. Writes the sensor data to a time-series database with explicit field type specifications
  3. Handles at least three different sensor types:
    • Temperature sensor: produces signed integer values (range: -50 to 50)
    • Counter sensor: produces unsigned integer values (range: 0 to 4294967295)
    • Pressure sensor: produces floating-point values (range: 0.0 to 2.0)

Test Cases

  • Given a temperature reading of -15 degrees, the system writes it as a signed integer field to the database @test
  • Given a counter value of 1000000, the system writes it as an unsigned integer field to the database @test
  • Given a pressure reading of 1.013 atmospheres, the system writes it as a float field to the database @test
  • Given multiple sensor readings in a dictionary format, the system correctly writes all fields with their appropriate types @test

Implementation

@generates

API

def write_sensor_data(client, bucket: str, measurement: str, sensor_data: dict, timestamp=None):
    """
    Write sensor data to the time-series database with appropriate field types.

    Args:
        client: Database client instance
        bucket: Target bucket name
        measurement: Measurement name for the data point
        sensor_data: Dictionary containing sensor readings with keys:
                    - 'temperature': signed integer (Celsius)
                    - 'counter': unsigned integer
                    - 'pressure': float (atmospheres)
        timestamp: Optional timestamp for the data point (defaults to current time)

    Returns:
        None
    """
    pass

Dependencies { .dependencies }

influxdb-client { .dependency }

Provides time-series data writing capabilities with field type customization support.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/influxdb-client@1.49.x
tile.json