Skip to content

javierjsa/stats-api

Repository files navigation

Python application Pylint

Channel stats API

Fastapi application that works with parquet files containing meteorological data from different sensors:

  • Upload a file, there is a sample in resources folder.
  • Request available channels, providing a file identifier and optionally, a type of channel.
  • Request statistics for certains channels within a date range.

Endpoints

  • /channels/{file_id}

    Retrieve available channel identifiers per type.

    • Allowed channel types are: vel, std, std_dtr, temp, hum, press, dir, sdir.
    • Requesting a channel type outside allowed values will raise an error.
    • Duplicated channel types are filtered before processing.

    Receives: ChannelRequest model with a file identifier and an optional list of channel_type values.
    Returns: Channels model with dictionary of available channels sorted by channel type.

  • /stats/{file_id}

    Retrieve stats (mean and standard deviation) for requested file identifier and channel identifiers.

    • In case no channel is specified, stats for all channels are returned.
    • A date range may be provided, otherwise stats are computed for the whole time series.
    • Should only start_date be specified, end_date is set to now.
    • Providing any nonexistent channel identifier will raise an error

    Receives: StatsRequest model with a file identifier and optionally, a list of channels and a date range.
    Returns: Dictionary of Stats models including dictionary of dictionaries with stats sorted by channel.

  • /upload

    Upload a parquet file to an object storage backend. Files can only be uploaded once and are assigned an identifier based on the file hash.

    Receives: Parquet file.
    Returns: FileId model containing file_id and stored values. If an identical file has been uploaded before, stored is false, meaning file was not re-uploaded.

Docker image

  • Download image:

    docker pull javierjsa/statsapi:latest
    
  • Run docker compose:

    docker-compose -f docker-compose.yaml up
    
  • Access documentation:

    http://0.0.0.0/docs
    

About

Sample Fastapi app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published