Metadata-Version: 2.4
Name: pontem
Version: 0.0.5
Summary: Pontem SDK — logs, metrics, and config
License: Apache-2.0
License-File: LICENSE
Keywords: edge,telemetry,metrics,logging,iot
Author: Pontem AI
Author-email: support@pontemai.com
Requires-Python: >=3.9
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Monitoring
Classifier: Typing :: Typed
Project-URL: Repository, https://github.com/pontemai/pontem-python
Description-Content-Type: text/markdown

# Pontem Python SDK

Pontem Python SDK for logs, metrics, and config on Pontem-managed edge devices. Zero runtime dependencies.

## Installation

```bash
pip install pontem
```

## Quick Start

```python
import pontem

pontem.init(service_name="my-service")

pontem.logger.info("model loaded", model="scoring_v3")

pontem.metrics.count("detections", class_name="apple")

with pontem.metrics.timer("model.inference"):
    result = model.predict(frame)

pontem.shutdown()
```

## Usage

### Logging

Structured logs with OTel-aligned severity levels. Each log is written to `logs.jsonl` in the emit directory.

```python
pontem.logger.info("model loaded", model="scoring_v3")
pontem.logger.warn("high latency", latency_ms=120)
pontem.logger.error("inference failed", error=str(e))
```

Available levels: `trace`, `debug`, `info`, `warn`, `error`, `fatal`.

### Metrics

Metrics are aggregated in memory and flushed periodically to `metrics.jsonl`. No I/O on the caller's thread.

```python
# Counters — incremented, flushed as a single sum
pontem.metrics.count("detections", class_name="apple")
pontem.metrics.count("bytes_sent", len(payload))

# Histograms — records min/max/sum/count summary
pontem.metrics.record("payload_size", len(data), unit="bytes")

# Gauges — last value wins
pontem.metrics.set_gauge("gpu_temp", 72.0, unit="celsius", gpu="0")

# Timers — context manager or decorator, records to histogram
with pontem.metrics.timer("model.inference"):
    result = model.predict(frame)

@pontem.metrics.timer("preprocessing")
def preprocess(frame):
    ...
```

### Config

Reads agent-managed config from `/opt/pontem/config/config.json` (or `$PONTEM_CONFIG_DIR`).

```python
threshold = pontem.config("my_namespace", "model_threshold", default=0.85)

# Reload after agent signals a config update
pontem.config.reload()
```

### Shutdown

Flushes remaining metrics and logs. Also registered via `atexit`.

```python
pontem.shutdown()
```

## Documentation

See [docs/getting-started.md](docs/getting-started.md) for a comprehensive guide including full API reference, configuration options, and troubleshooting.

## License

Apache 2.0 — see [LICENSE](LICENSE).

