Skip to main content

DeployRamp SDK - Feature flag management for Python

Project description

DeployRamp Python SDK

PyPI version PyPI downloads License: MIT

Python SDK for DeployRamp — AI-native feature flag management with gradual rollouts, real-time updates, and automatic error-monitored rollbacks.

Installation

pip install deployramp

Quick Start

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

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:

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

@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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deployramp-0.1.7.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deployramp-0.1.7-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file deployramp-0.1.7.tar.gz.

File metadata

  • Download URL: deployramp-0.1.7.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deployramp-0.1.7.tar.gz
Algorithm Hash digest
SHA256 3838f466d9210a1af36f045ddf14709d636b38b543747f09e55a30ffc51bc0f0
MD5 9eb558bea347a01a6b50cc7287265c02
BLAKE2b-256 e4f5135e2be02a0318d8c22607a284fc5381c710ddc1a65e0cacc198debae4c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for deployramp-0.1.7.tar.gz:

Publisher: sdk-release-python.yml on deployramp/deployramp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deployramp-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: deployramp-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for deployramp-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a6b857e93743ac1d687a8210d7b613e5bf6a7148a4046b203626681f01ef450e
MD5 85fa6791923128196914768d05b95393
BLAKE2b-256 e01e3f4655538bfbbea9fa93c1e0cb52319fa395ba699408ae3185fbb0e46dfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for deployramp-0.1.7-py3-none-any.whl:

Publisher: sdk-release-python.yml on deployramp/deployramp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page