PhyTrace Python SDK¶
The PhyTrace Python SDK provides a comprehensive toolkit for integrating autonomous systems with the PhyWare data platform.
Installation¶
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¶
- Quickstart — Get up and running in 5 minutes
- API Reference — Full API documentation
- UDM Models — Domain model reference
- Transport Layer — HTTP and mock transports
- Reliability — Buffering, retry, circuit breaker
- Agent Configuration — YAML configuration reference
- Testing — Mock transports and test utilities
- Changelog — Version history
Requirements¶
- Python 3.11+
- Dependencies:
pydantic>=2.0,aiohttp>=3.9,pyyaml>=6.0