Skip to main content

OpenFeature Python Environment Variable Provider

Project description

A OpenFeature Python Environment Variable Provider

This provider loads flag values from environment variables. If a flag with some key is evaluated when no env var named after this key exists, it will throw a FlagNotFoundError. Otherwise it will attempt to parse the string value of the env var to the appropriate type (str,int,float, or object). Errors during this parsing are forwarded to the user.

Installation

pip install openfeature-provider-env-var

Usage

Create a new instance of the EnvVarProvider:

provider = EnvVarProvider()

Configure the OpenFeature API to use the EnvVarProvider and retrieve the client:

from openfeature import api
from openfeature.contrib.provider.envvar import EnvVarProvider

api.set_provider(EnvVarProvider())
client = api.get_client()
result = client.get_boolean_value("<your feature flag key>", True)

The EnvVarProvider will attempt to read values from the present environment variables. If no values is present for a flag key, it will throw a FlagNotFoundError. Otherwise, it will attempt to parse the value associated with the key to the requested type (e.g. float in the case of provider.resolve_float_details(key, 0.0, None)) and forward any error that is raised during parsing to the user. Note that any such errors will be caught by the OpenFeature API and translated into appropriate error codes.

Build setup

This provider uses uv as build tool.

Building

uv build

Executing tests

uv run pytest

pre commit hooks

Install the pre commit hooks that ensure proper formatting:

uvx pre-commit install

License

Apache 2.0 - See LICENSE for more information.

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

openfeature_provider_env_var-0.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

openfeature_provider_env_var-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for openfeature_provider_env_var-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6d254aa221dd1585a645ee836919c1e00cc2a2e8b287018f3275e2efc895d093
MD5 a066e0db53827d37b2beeb14ae1b470a
BLAKE2b-256 72cc0d3c74178b1ea74f21af8c90ca9680e77dcc2b162b7d636990051431bd03

See more details on using hashes here.

Provenance

The following attestation bundles were made for openfeature_provider_env_var-0.1.1.tar.gz:

Publisher: release.yml on open-feature/python-sdk-contrib

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

File details

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

File metadata

File hashes

Hashes for openfeature_provider_env_var-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 96990a3784c2d2d9718942a3e85fb9574e5085f510686e7c9ff68f57c93c67a6
MD5 f6094175ae07dc052174a7d6cee16beb
BLAKE2b-256 20b77cdf90ee9f3085539e7ed8dfd0377a2db519638afc57f05baafbe0c86082

See more details on using hashes here.

Provenance

The following attestation bundles were made for openfeature_provider_env_var-0.1.1-py3-none-any.whl:

Publisher: release.yml on open-feature/python-sdk-contrib

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