Skip to main content

FlagDrop Python SDK — evaluate feature flags from your cloud bucket

Project description

FlagDrop — Feature flags that run where your code runs

PyPI Python License

FlagDrop Python SDK

Feature flag management where evaluations run entirely inside your cloud. No vendor servers. No data leaving your infrastructure. No single point of failure.

FlagDrop pushes a lightweight JSON config to a storage bucket in your cloud account. The SDK reads that file and evaluates flags locally at runtime — zero network calls to external servers during evaluation.

Installation

pip install flagdrop-sdk

Quick Start

from flagdrop import FlagClient

client = FlagClient(
    bucket="my-app-flags",
    environment="production",
    provider="aws",
    region="us-east-1",
)
client.initialize()

# Boolean flag
enabled = client.get_bool("new-checkout", False)

# String flag with targeting context
theme = client.get_string("app-theme", "light", {"plan": "enterprise"})

# Number flag
max_items = client.get_number("max-items", 10)

# JSON flag
config = client.get_json("feature-config", {"limit": 5})

How It Works

  ┌──────────────────┐      ┌──────────────────────────────────────┐
  │  FlagDrop Cloud   │      │  Your Cloud (AWS / Azure / GCP)      │
  │                   │      │                                      │
  │  Dashboard ───────┼──────▶  S3 / Blob Storage / GCS Bucket     │
  │  (define flags)   │ push │  (JSON config file)                  │
  └──────────────────┘      │         │                             │
                             │         ▼                             │
                             │  ┌──────────────┐                    │
                             │  │  Your App     │                    │
                             │  │  + FlagDrop   │  ← evaluates      │
                             │  │    SDK        │    flags locally   │
                             │  └──────────────┘                    │
                             └──────────────────────────────────────┘
  1. Define flags in the FlagDrop dashboard — boolean, string, number, or JSON
  2. FlagDrop pushes a JSON config file to a storage bucket in your cloud account
  3. The SDK reads that file locally and evaluates flags at runtime

The critical difference: flag evaluation happens inside your infrastructure. User context never leaves your cloud. There are no network calls to FlagDrop servers at evaluation time.

Cloud Providers

Provider Status Storage
AWS GA Amazon S3
Azure GA Azure Blob Storage
GCP GA Google Cloud Storage

All three major cloud providers are fully supported. The provider parameter controls which cloud storage backend is used.

All Flag Types

Boolean

enabled = client.get_bool("dark-mode", False)

String

theme = client.get_string("color-theme", "light")

Number

rate_limit = client.get_number("api-rate-limit", 100)

JSON

plan_config = client.get_json("plan-features", {"max_seats": 5})

Each getter returns the flag's configured value when the flag is found and enabled, or the caller-provided default when the flag is missing, disabled, or the wrong type.

Targeting Rules

Pass user context to evaluate targeting rules. Rules are evaluated locally — context never leaves your infrastructure.

# Target by user attribute
ui = client.get_string("checkout-ui", "standard", {
    "plan": "enterprise",
    "country": "US",
    "email": "admin@acme.com",
})

# Target by segment membership
variant = client.get_string("landing-page", "control", {
    "segments": ["beta-testers"],
})

Supported Operators

Operator Description Example
eq Exact match plan == "enterprise"
neq Not equal role != "guest"
in Value in list country in ["US", "CA", "GB"]
notIn Value not in list email not in blocklist
lt Less than (numeric) age < 18
gt Greater than (numeric) requestCount > 1000
startsWith String prefix email starts with "admin"
endsWith String suffix email ends with "@acme.com"
contains String contains userAgent contains "Chrome"
segment Segment membership user in "beta-testers"

Rules are evaluated in order — first match wins. If no rule matches, the flag's default value is returned.

Percentage Rollouts

Gradually roll out features to a percentage of users with deterministic bucketing:

# Same userId always gets the same result
enabled = client.get_bool("new-search", False, {"userId": "user-123"})

Rollouts use FNV-1a hashing for deterministic bucketing — the same user always gets the same result across evaluations, restarts, and deployments.

Configuration Reference

client = FlagClient(
    bucket="my-flags",             # Storage bucket name (required)
    environment="production",       # Environment name (required)
    provider="aws",                 # Cloud provider: "aws", "azure", "gcp" (required)
    region="us-east-1",            # Cloud region (required)
    scope="backend",               # "backend" or "frontend" (default: "backend")
    refresh_interval_seconds=30,   # Auto-refresh interval (default: 30, 0 to disable)
)

Caching & Refresh

The SDK caches the config file in memory and automatically re-fetches it based on refresh_interval_seconds. Set to 0 to disable auto-refresh (the config is fetched once on initialize() and never refreshed).

Scopes

Flags can be scoped to backend, frontend, or both. The SDK only loads the config for its configured scope, so frontend-only flags won't be included in your backend config and vice versa.

Usage in AWS Lambda

The SDK works in Lambda without any special configuration. Lambda's built-in boto3 is used automatically — no need to bundle it.

from flagdrop import FlagClient

client = FlagClient(
    bucket="my-flags",
    environment="production",
    provider="aws",
    region="us-east-1",
    refresh_interval_seconds=0,  # fetch once per invocation
)

def handler(event, context):
    client.initialize()
    if client.get_bool("new-feature", False, {"userId": event["userId"]}):
        return new_feature_handler(event)
    return legacy_handler(event)

For warm Lambdas, you can initialize the client outside the handler and use the default refresh interval to pick up config changes.

Requirements

  • Python 3.9+
  • boto3 (AWS SDK) — included in AWS Lambda, install separately elsewhere
  • AWS credentials with s3:GetObject permission on your flag config bucket

Why FlagDrop?

Traditional Flag Services FlagDrop
Where flags evaluate Vendor's servers Your cloud
User context Sent to vendor Never leaves your infra
Vendor outage impact Flags stop working No impact (local file)
Latency Network round-trip Local file read
Data residency Vendor's region Your region
Lock-in Proprietary SDK Standard JSON + S3

Links

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

flagdrop_sdk-0.1.2.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

flagdrop_sdk-0.1.2-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file flagdrop_sdk-0.1.2.tar.gz.

File metadata

  • Download URL: flagdrop_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for flagdrop_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5524362a7377483d6e5c90667c4c3a429bcc0f0d11d90ab003ac689c62a225c3
MD5 35f3acc99b0d80de0d7f9301b184c666
BLAKE2b-256 97fd9bd52bd2f3fe22c6718e00e1f7e15bcc42bec0f3fa484ea8188d5620be2d

See more details on using hashes here.

File details

Details for the file flagdrop_sdk-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: flagdrop_sdk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for flagdrop_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2505a6cc2d8468f3ea3d6c1ba0204cf41133e70febdffdfc3e2c3202d03e42b8
MD5 3b6651a76ea505cc0375584f47d922da
BLAKE2b-256 e7f7bf61a169b3fbac5c70ed925666af354ad5ededf27e7d060224eb1423a3c1

See more details on using hashes here.

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