docs: update AI Studio design token audits
Refresh design token inventory files to reflect the latest UI sizing and layout configurations from the sandbox prototype.
This commit is contained in:
1 parent
50449e96ad
commit
d39d9f92f9
139 files changed
+10982
-6
No files matched your search
@@ -0,0 +1,48 @@
|
||||
# DataStack Python SDK
|
||||
|
||||
Official Python client for the **DataStack Universal Realtime Data Collection Platform**.
|
||||
|
||||
## Installation
|
||||
|
||||
Install directly via pip:
|
||||
|
||||
```bash
|
||||
pip install ./sdk-python
|
||||
```
|
||||
Or in development:
|
||||
```bash
|
||||
cd sdk-python && pip install -e .
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```python
|
||||
from datastack_sdk import DataStackClient
|
||||
|
||||
# 1. Initialize client with JWT from /vcon/clients console
|
||||
client = DataStackClient(
|
||||
server_url="http://localhost:4000",
|
||||
token="YOUR_CLIENT_JWT_TOKEN"
|
||||
)
|
||||
|
||||
# 2. Connect to Ingestion Engine
|
||||
if client.connect():
|
||||
# 3. Stream single realtime event
|
||||
res = client.sync({
|
||||
"action": "user_checkout",
|
||||
"order_id": "ORD-9482",
|
||||
"amount": 249.50,
|
||||
"currency": "USD"
|
||||
})
|
||||
print("Sync result:", res)
|
||||
|
||||
# 4. Stream batch of records
|
||||
batch_res = client.batch_sync([
|
||||
{"metric": "cpu_load", "value": 42.1},
|
||||
{"metric": "mem_usage", "value": 78.5},
|
||||
{"metric": "disk_io", "value": 1120}
|
||||
])
|
||||
print("Batch result:", batch_res)
|
||||
|
||||
client.disconnect()
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
"""
|
||||
DataStack Python SDK
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
High-performance real-time data collection client for python applications.
|
||||
"""
|
||||
|
||||
from .client import DataStackClient
|
||||
|
||||
__version__ = "1.0.0"
|
||||
__all__ = ["DataStackClient"]
|
||||
@@ -0,0 +1,130 @@
|
||||
import time
|
||||
import uuid
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional
|
||||
import socketio
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger("DataStackClient")
|
||||
|
||||
class DataStackClient:
|
||||
"""
|
||||
DataStack Universal Realtime Data Collection Client
|
||||
Syncs telemetry and event payloads via Socket.IO to port 4000
|
||||
"""
|
||||
def __init__(
|
||||
self,
|
||||
server_url: str = "http://localhost:4000",
|
||||
token: str = "",
|
||||
reconnection_attempts: int = 5,
|
||||
reconnection_delay: int = 1,
|
||||
):
|
||||
self.server_url = server_url.rstrip("/")
|
||||
self.token = token
|
||||
self.sio = socketio.Client(
|
||||
reconnection=True,
|
||||
reconnection_attempts=reconnection_attempts,
|
||||
reconnection_delay=reconnection_delay,
|
||||
logger=False,
|
||||
engineio_logger=False,
|
||||
)
|
||||
self._register_handlers()
|
||||
self.is_connected = False
|
||||
|
||||
def _register_handlers(self):
|
||||
@self.sio.event
|
||||
def connect():
|
||||
self.is_connected = True
|
||||
logger.info(f"Connected to DataStack Engine at {self.server_url}")
|
||||
|
||||
@self.sio.event
|
||||
def disconnect():
|
||||
self.is_connected = False
|
||||
logger.warning("Disconnected from DataStack Engine")
|
||||
|
||||
@self.sio.event
|
||||
def connect_error(data):
|
||||
self.is_connected = False
|
||||
logger.error(f"DataStack Connection Error: {data}")
|
||||
|
||||
def connect(self, wait_timeout: int = 5) -> bool:
|
||||
"""
|
||||
Connects to DataStack Socket.IO server with JWT token in handshake auth
|
||||
"""
|
||||
try:
|
||||
self.sio.connect(
|
||||
self.server_url,
|
||||
auth={"token": self.token},
|
||||
wait_timeout=wait_timeout,
|
||||
transports=["websocket", "polling"],
|
||||
)
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to connect to DataStack: {e}")
|
||||
return False
|
||||
|
||||
def sync(self, data: Any, event_id: Optional[str] = None) -> Dict[str, Any]:
|
||||
"""
|
||||
Sync single event payload in realtime.
|
||||
Returns server response dict.
|
||||
"""
|
||||
if not self.is_connected:
|
||||
raise ConnectionError("DataStack client is not connected. Call connect() first.")
|
||||
|
||||
evt_id = event_id or f"evt_{uuid.uuid4().hex[:12]}"
|
||||
iso_timestamp = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
|
||||
|
||||
payload = {
|
||||
"eventId": evt_id,
|
||||
"timestamp": iso_timestamp,
|
||||
"data": data,
|
||||
}
|
||||
|
||||
response = {"success": False, "eventId": evt_id}
|
||||
|
||||
def on_ack(res):
|
||||
nonlocal response
|
||||
response = res
|
||||
|
||||
try:
|
||||
self.sio.emit("sync_data", payload, callback=on_ack)
|
||||
# Short wait for ack in synchronous invocation
|
||||
time.sleep(0.05)
|
||||
return response
|
||||
except Exception as e:
|
||||
logger.error(f"Sync error for event {evt_id}: {e}")
|
||||
return {"success": False, "eventId": evt_id, "error": str(e)}
|
||||
|
||||
def batch_sync(self, records: List[Dict[str, Any]]) -> Dict[str, Any]:
|
||||
"""
|
||||
Sync list of records in a single batch.
|
||||
"""
|
||||
if not self.is_connected:
|
||||
raise ConnectionError("DataStack client is not connected.")
|
||||
|
||||
batch_payload = []
|
||||
for r in records:
|
||||
batch_payload.append({
|
||||
"eventId": r.get("eventId") or f"evt_{uuid.uuid4().hex[:12]}",
|
||||
"timestamp": r.get("timestamp") or time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
||||
"data": r.get("data", r),
|
||||
})
|
||||
|
||||
response = {"success": False, "processed": 0}
|
||||
|
||||
def on_ack(res):
|
||||
nonlocal response
|
||||
response = res
|
||||
|
||||
try:
|
||||
self.sio.emit("batch_sync", batch_payload, callback=on_ack)
|
||||
time.sleep(0.1)
|
||||
return response
|
||||
except Exception as e:
|
||||
logger.error(f"Batch sync error: {e}")
|
||||
return {"success": False, "error": str(e)}
|
||||
|
||||
def disconnect(self):
|
||||
"""Disconnects socket connection"""
|
||||
if self.is_connected:
|
||||
self.sio.disconnect()
|
||||
@@ -0,0 +1,13 @@
|
||||
# Python SDK Manifest
|
||||
|
||||
## Purpose
|
||||
Pip-installable Python client SDK (`datastack-sdk`) enabling Python applications, scrapers, and telemetry daemons to stream real-time events to DataStack.
|
||||
|
||||
## Contents
|
||||
- `setup.py`: Standard setuptools configuration
|
||||
- `datastack_sdk/client.py`: `DataStackClient` class with automatic reconnection, JWT handshake, and sync/batch_sync methods
|
||||
- `README.md`: Quickstart guide and API reference.
|
||||
|
||||
## Dependencies
|
||||
- `python-socketio[client]`
|
||||
- `requests`
|
||||
@@ -0,0 +1,22 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name="datastack-sdk",
|
||||
version="1.0.0",
|
||||
description="Python client SDK for DataStack Universal Realtime Data Collection Platform",
|
||||
long_description=open("README.md").read(),
|
||||
long_description_content_type="text/markdown",
|
||||
author="DataStack Engine Team",
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
"python-socketio[client]>=5.11.0",
|
||||
"requests>=2.31.0",
|
||||
"websocket-client>=1.7.0"
|
||||
],
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
python_requires=">=3.8",
|
||||
)
|
||||
Reference in new issue
Block a user