Skip to main content

Python provider for Unleash and OpenFeature.

Project description

Unleash OpenFeature Python Provider

Python project scaffold managed with uv.

Prerequisites

  • Python 3.10+
  • uv

Install

uv add unleash-openfeature-python-provider

For local development, sync the project environment:

uv sync --dev

Test Harness

This repository includes the OpenFeature provider verifier as a git submodule. After cloning, initialize it before running the full test suite:

git submodule update --init --recursive

If the verifier submodule is intentionally updated, refresh it and commit the new submodule pointer:

git submodule update --remote --merge verifier
git status

Use

from openfeature import api
from openfeature.evaluation_context import EvaluationContext
from UnleashClient import UnleashClient

from unleash_openfeature_python_provider import UnleashFlagProvider

unleash_client = UnleashClient(
    url="https://app.unleash-hosted.com/demo/api",
    app_name="my-app",
    custom_headers={"Authorization": "<client-api-key>"},
)

api.set_provider_and_wait(UnleashFlagProvider(unleash_client))

client = api.get_client()
enabled = client.get_boolean_value(
    "my-feature",
    False,
    EvaluationContext(targeting_key="user-123"),
)

Example

uv run python examples/boolean_flag.py \
  --url https://app.unleash-hosted.com/demo/api \
  --api-key "$UNLEASH_API_KEY" \
  --flag-key my-feature \
  --targeting-key user-123

Build

uv build

Build artifacts are written to dist/.

Test

uv run pytest

Lint, Format, And Type Check

uv run ruff check
uv run ruff format
uv run basedpyright

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

Built Distribution

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

File details

Details for the file unleash_openfeature_python_provider-0.1.0a1.tar.gz.

File metadata

File hashes

Hashes for unleash_openfeature_python_provider-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 c500ab21fb908ae25c941079cbe815830d6c1233d24af80d323f462ed79f3f68
MD5 a43b80a12b85b5d197fca0d57b8b4584
BLAKE2b-256 8e69de0af81e643e39c63f503e8b4f45956cd76468336a9fa114e617635cdfee

See more details on using hashes here.

File details

Details for the file unleash_openfeature_python_provider-0.1.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for unleash_openfeature_python_provider-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 549d2c56233c159c10e392bdf11ab33495041c84b2cd777897302eca55bcf866
MD5 9fce1b0f92709a35ddb5da0c5abace2e
BLAKE2b-256 8b5f74dd152a6d371590760f5ea652e9e96d5d9aa75cb6dc50ba4cb97457ebd8

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