Skip to main content

- ReadME updated.

Project description

🚗 Analytics Ingest Client

A lightweight Python library to batch and send automotive telemetry — like signals, DTCs, GPS, and network stats — to a GraphQL backend.


🔧 Features

  • Python 3.11+ support
  • Clean, single-class interface: IcsAnalytics
  • In-memory caching for resolved IDs
  • Smart batching (by time, count, or signal limit)
  • Async-safe request queuing (1 request at a time)
  • Minimal dependencies
  • Easy to integrate and test
  • Supports Signals, DTCs, GPS, and Network Stats ingestion

📦 Installation

pip install analytics-ingest

🚀 Quick Usage

from analytics_ingest import IcsAnalytics

client = IcsAnalytics(
    device_id=123,
    vehicle_id=456,
    fleet_id=789,
    org_id=1011,
    graphql_endpoint="https://your-backend/graphql",
    batch_size=100,
    batch_interval_seconds=10,
    max_signal_count=100
)

# Add a signal
client.add_signal({'name': 'VehicleIdentificationNumber', 'unit': '', 'messageName': 'BusQuery_IDDecoding_F190_VSSAL', 'networkName': 'Cluster_6_TestTool', 'ecuName': '', 'arbId': '', 'fileId': '1234', 'paramType': 'TEXT', 'signalType': 'DID', 'messageDate': '2025-07-15T01:40:00.000000', 'paramId': 'F190', 'data': [{'value': 0.04, 'time': '1970-01-07T18:28:54Z'}]})

# Add DTCs
client.add_dtc({'messageName': 'DTC Message99B049', 'name': 'DTC Message99B049', 'networkName': 'Cluster_6_TestTool', 'ecuName': 'VCU_Android_GAS', 'ecuId': '14DA80F1', 'messageDate': '2025-07-15T01:42:20.385429', 'fileId': '1234', 'data': [{'dtcId': 'B19B0-49', 'description': 'Head-Up Display - Internal Electronic Failure', 'status': '2F', 'time': '2025-07-15T01:42:15.979524'})

# Add GPS
client.add_gps({"time": "2025-07-28T12:34:56.789Z", "latitude": 37.7749, "longitude": -122.4194, "accuracy": 10.5, "altitude": 120.3, "speed": 45.2, "bearing": 75.0, "available": {"accuracy": True, "altitude": True, "bearing": False, "speed": True, "time": True}})

# Add Network Stats
client.add_network_stats({
    "name": "CAN1",
    "vehicleId": 456,
    "uploadId": 1,
    "totalMessages": 1000,
    "matchedMessages": 950,
    "unmatchedMessages": 50,
    "errorMessages": 0,
    "longMessageParts": 0,
    "rate": 500.0
})

# Flush remaining data before exit
client.close()
client.flush()

⚙️ Config Options

Set through constructor or environment variables.

Param Description Default
device_id Device ID (required)
vehicle_id Vehicle ID (required)
fleet_id Fleet ID (required)
org_id Org ID (required)
graphql_endpoint GraphQL endpoint
batch_size Max items per batch 100
batch_interval_seconds Time-based flush interval 10
max_signal_count Max signals before flush 100

🛠️ Error Handling & Logging

  • Raises exceptions for bad input or backend failures
  • Use logging instead of print in production
  • Automatically retries failed batches on next interval

🧪 Testing

Run all tests:

PYTHONPATH=src python3 -m unittest discover -s tests -v

Build and publish:

rm -rf dist/
python3 -m build
python -m twine upload dist/*

💡 Improvements & Roadmap

  • Full async API support
  • Runtime config updates
  • More usage examples
  • Metrics & monitoring hooks
  • Linting/type-checking in CI

🤝 Contributing

We welcome PRs and issues! Please follow PEP8 and include tests with any changes.

One-Time Setup

pip install pre-commit
pre-commit install

🏁 Dev Quick Start

git clone http://lustra.intrepidcs.corp/ics/wivi/ipa-py-library.git
cd analytics-ingest

# Setup virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Test ingestion logic:

PYTHONPATH=src python3 test_auto_flush_by_signal_count.py

📄 License

MIT License Readme.txt 4 KB

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

analytics_ingest-0.1.71.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

analytics_ingest-0.1.71-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file analytics_ingest-0.1.71.tar.gz.

File metadata

  • Download URL: analytics_ingest-0.1.71.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for analytics_ingest-0.1.71.tar.gz
Algorithm Hash digest
SHA256 604609c189dfd77394efc2a6338bc6cc832906b204508bc3149207fcea6d465f
MD5 ffc9754c86a4b5dce702d76197b6117e
BLAKE2b-256 d47501ebfd56ec222aabcc10a4296fbcd696906998a5c6877aefe72ba775a4a6

See more details on using hashes here.

File details

Details for the file analytics_ingest-0.1.71-py3-none-any.whl.

File metadata

File hashes

Hashes for analytics_ingest-0.1.71-py3-none-any.whl
Algorithm Hash digest
SHA256 d505ea103139edb5fd470b83f9ffab4fcd995b32cb1ac4f87dc6b9a84862c76a
MD5 e76118bedc411f24d2e3088128e9217b
BLAKE2b-256 f18423fcf196a92bf142c78b104df586322a1088fcb12096a75e3bba69331363

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page