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 Generally Available Amazon S3
Azure Coming Soon Azure Blob Storage
GCP Coming Soon Google Cloud Storage

The SDK is designed to be multi-cloud from the ground up. 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" (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.1.tar.gz (14.9 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.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flagdrop_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 14.9 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.1.tar.gz
Algorithm Hash digest
SHA256 24515e457be9615b2911411a1b8fb6eca8a79b8b8f006fdc82c0bf52672ef96e
MD5 4414e4bc7f77cecf89ea5ee2fcd8ce0d
BLAKE2b-256 3c4297ad6308388cdad1134a9aeffd26dec952f83851137dc863f4538c7db3f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flagdrop_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f8fe22e737160288d45fa35c501de0860c0f03544458f5a5628814c8ba8a4874
MD5 b8ddd1055bc3ee2b73773e05b8bfc3ca
BLAKE2b-256 ee8872872b531012882b7c34084b3629007feaf790289696a82f189e412c5145

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