Skip to content

PhyTrace Python SDK

PyPI Python

The PhyTrace Python SDK provides a comprehensive toolkit for integrating autonomous systems with the PhyWare data platform.

Installation

pip install phytrace-sdk

With optional transports:

# MQTT support
pip install phytrace-sdk[mqtt]

# gRPC support
pip install phytrace-sdk[grpc]

# All extras
pip install phytrace-sdk[mqtt,grpc]

Features

  • UDM Models — Strongly-typed Pydantic models for all 23 UDM domains
  • Event Builders — Fluent builder pattern for constructing UDM events
  • Validation — Schema validation before transmission
  • Transport — HTTP, gRPC, MQTT, WebSocket transports
  • Reliability — Edge buffering, retry logic, circuit breaker, batching
  • Provenance — Cryptographic signing and chain-of-custody tagging
  • Mock Endpoints — Built-in mock transport for testing without PhyCloud

Quick Example

import asyncio
from phytrace import (
    PhyTraceAgent,
    UDMEventBuilder,
    EventType,
    SourceType,
)

async def main():
    agent = PhyTraceAgent.from_config("phytrace-agent.yaml")
    await agent.start()

    event = (
        UDMEventBuilder(source_id="robot-001", source_type=SourceType.AMR)
        .with_event_type(EventType.TELEMETRY_PERIODIC)
        .with_location(latitude=41.8781, longitude=-87.6298, heading_deg=45.0)
        .with_motion(speed_mps=1.2)
        .with_power(battery_soc_pct=78.5, is_charging=False)
        .build()
    )

    await agent.emit(event)
    await agent.stop()

asyncio.run(main())

Contents

Requirements

  • Python 3.11+
  • Dependencies: pydantic>=2.0, aiohttp>=3.9, pyyaml>=6.0