Unleash Provider for OpenFeature
This provider is designed to use Unleash.
Installation
pip install openfeature-provider-unleash
Requirements
- Python 3.9+
openfeature-sdk>=0.8.2UnleashClient>=6.3.0
Configuration and Usage
Instantiate a new UnleashProvider instance and configure the OpenFeature SDK to use it:
from openfeature import api
from openfeature.contrib.provider.unleash import UnleashProvider
# Initialize the provider with your Unleash configuration
provider = UnleashProvider(
url="https://my-unleash-instance.com",
app_name="my-python-app",
api_token="my-api-token",
)
# Initialize the provider (required before use)
provider.initialize()
api.set_provider(provider)
Configuration options
url: The URL of your Unleash serverapp_name: The name of your applicationapi_token: The API token for authentication
Evaluation context mapping
When evaluating flags, the OpenFeature EvaluationContext is mapped to the Unleash context as follows:
EvaluationContext.targeting_key→ UnleashuserIdEvaluationContext.attributes→ merged into the Unleash context as-is
Event handling
The Unleash provider supports OpenFeature events for monitoring provider state changes:
from openfeature.event import ProviderEvent
def on_provider_ready(event_details):
print(f"Provider {event_details['provider_name']} is ready")
def on_provider_error(event_details):
print(f"Provider error: {event_details['error_message']}")
def on_configuration_changed(event_details):
print(f"Configuration changed, flags: {event_details.get('flag_keys', [])}")
# Add event handlers
provider.add_handler(ProviderEvent.PROVIDER_READY, on_provider_ready)
provider.add_handler(ProviderEvent.PROVIDER_ERROR, on_provider_error)
provider.add_handler(
ProviderEvent.PROVIDER_CONFIGURATION_CHANGED, on_configuration_changed
)
# Remove event handlers
provider.remove_handler(ProviderEvent.PROVIDER_READY, on_provider_ready)
Supported events:
ProviderEvent.PROVIDER_READY: Emitted when the provider is ready to evaluate flagsProviderEvent.PROVIDER_ERROR: Emitted when the provider encounters an errorProviderEvent.PROVIDER_CONFIGURATION_CHANGED: Emitted when flag configurations are updated
Note: ProviderEvent.PROVIDER_STALE handlers can be registered but are not currently emitted by this provider.
Supported flag types
This provider supports resolving the following types via the OpenFeature client:
- Boolean (
get_boolean_value/details): usesUnleashClient.is_enabled - String (
get_string_value/details): from variant payload - Integer (
get_integer_value/details): from variant payload - Float (
get_float_value/details): from variant payload - Object (
get_object_value/details): from variant payload, JSON-parsed if needed
Example usage
from openfeature import api
from openfeature.contrib.provider.unleash import UnleashProvider
from openfeature.evaluation_context import EvaluationContext
# Initialize the provider
provider = UnleashProvider(
url="https://your-unleash-instance.com",
app_name="my-python-app",
api_token="my-token"
)
provider.initialize()
api.set_provider(provider)
# Get a client and evaluate flags
client = api.get_client()
# Boolean flag evaluation
is_enabled = client.get_boolean_value("my-feature", False)
print(f"Feature is enabled: {is_enabled}")
# String flag evaluation with context
context = EvaluationContext(targeting_key="user123", attributes={"sessionId": "session456"})
variant = client.get_string_value("my-variant-flag", "default", context)
print(f"Variant: {variant}")
# Shutdown when done
provider.shutdown()
Development
Running tests
uv run test --frozen
Integration tests require Docker to be installed and running. To run only integration tests:
uv run test -m integration --frozen
To skip integration tests:
uv run test -m "not integration" --frozen
Type checking
uv run mypy-check
Linting
Run Ruff checks:
uv run ruff check
License
Apache 2.0 - See LICENSE for more information.
Metadata
Release files for openfeature-provider-unleash 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openfeature_provider_unleash-0.1.2.tar.gz | 10.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openfeature_provider_unleash-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.6 kB
Release files / openfeature_provider_unleash-0.1.2.tar.gz
| Download URL | openfeature_provider_unleash-0.1.2.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb4698f7c0227fa222b4e4c7e030b8fbe7086c726ebe7aac5e3ffcdd2b746538
|
|
BLAKE2b-256 checksum How to use checksums |
5b85a1aaf9e86934c397d58111c999ca91c958d7febd886850bad457b7a6421e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency logRelease files / openfeature_provider_unleash-0.1.2-py3-none-any.whl
| Download URL | openfeature_provider_unleash-0.1.2-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5fc91ef907998e7518c6955b2d9a526c75d09cd14566dd12b5c79468bc061e55
|
|
BLAKE2b-256 checksum How to use checksums |
0187813d6c9bd50c5e5c9022d8fa392009b9712ef3d8e5e171855cf530dd5919
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 16, 2026.
Transparency log