Metadata-Version: 2.4
Name: deployramp
Version: 0.1.7
Summary: DeployRamp SDK - Feature flag management for Python
Project-URL: Homepage, https://deployramp.com
Project-URL: Repository, https://github.com/deployramp/deployramp
License-Expression: MIT
License-File: LICENSE
Keywords: a/b testing,deployramp,feature flags,feature management,feature toggles,rollout
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: websockets>=12.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# DeployRamp Python SDK

[![PyPI version](https://img.shields.io/pypi/v/deployramp)](https://pypi.org/project/deployramp/)
[![PyPI downloads](https://img.shields.io/pypi/dm/deployramp)](https://pypi.org/project/deployramp/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Python SDK for [DeployRamp](https://deployramp.com) — AI-native feature flag management with gradual rollouts, real-time updates, and automatic error-monitored rollbacks.

## Installation

```bash
pip install deployramp
```

## Quick Start

```python
import deployramp

deployramp.init(deployramp.SdkConfig(
    public_token="drp_pub_your_token",
    traits={"plan": "pro", "region": "us-east"},
))

# Evaluate a feature flag
if deployramp.flag("new-checkout-flow"):
    process_new_checkout()
else:
    process_old_checkout()

# Report errors — DeployRamp uses these to auto-roll back bad deploys
try:
    process_checkout()
except Exception as e:
    deployramp.report(e, flag_name="new-checkout-flow")

deployramp.close()
```

## Trait-Based Targeting

```python
import deployramp

deployramp.init(deployramp.SdkConfig(public_token="drp_pub_your_token"))

# Update traits after login
deployramp.set_traits({"plan": "enterprise", "cohort": "beta"})

# Override traits for a single evaluation
enabled = deployramp.flag("beta-feature", trait_overrides={"cohort": "alpha"})
```

## Measure Performance

Track how each flag branch performs across your user population:

```python
import deployramp

result = deployramp.measure(
    "fast-algorithm",
    enabled_fn=lambda: new_algorithm(data),
    disabled_fn=lambda: old_algorithm(data),
)
```

## API Reference

### `init(config: SdkConfig) -> None`

Initialize the SDK. Fetches flags and opens a WebSocket for real-time updates.

### `flag(name: str, trait_overrides: dict | None = None) -> bool`

Evaluate a feature flag. Returns `False` if the SDK is not initialized or the flag is unknown/disabled.

### `set_traits(traits: dict[str, str]) -> None`

Replace the current traits used for flag evaluation.

### `measure(name: str, enabled_fn, disabled_fn, trait_overrides: dict | None = None)`

Run the appropriate branch and report execution time to DeployRamp.

### `report(error: Exception | str, flag_name: str | None = None, trait_overrides: dict | None = None) -> None`

Report an error to DeployRamp for automatic rollback monitoring.

### `close() -> None`

Flush pending evaluations and close connections.

### `SdkConfig`

```python
@dataclass
class SdkConfig:
    public_token: str                      # Required. Your public token from deployramp.com
    base_url: str = "https://flags.deployramp.com"
    traits: dict[str, str] = field(default_factory=dict)
```

## Requirements

- Python 3.10+
- `websockets >= 12.0`

## Links

- [deployramp.com](https://deployramp.com)
- [GitHub](https://github.com/deployramp/deployramp)
- [PyPI](https://pypi.org/project/deployramp/)

## License

MIT
