Skip to main content

GO Feature Flag Python Provider

GO Feature Flag provider allows you to connect to your GO Feature Flag instance.

GO Feature Flag believes in simplicity and offers a simple and lightweight solution to use feature flags.
Our focus is to avoid any complex infrastructure work to use GO Feature Flag.

This is a complete feature flagging solution with the possibility to target only a group of users, use any types of flags, store your configuration in various location and advanced rollout functionality. You can also collect usage data of your flags and be notified of configuration changes.

Python SDK usage

Install dependencies

The first things we will do is install the Open Feature SDK and the GO Feature Flag provider.

pip install gofeatureflag-python-provider

Evaluation modes

The provider supports two evaluation modes:

Mode Description
In-Process (default) Flag configuration is fetched and cached locally; evaluation runs via a WASM module — no per-evaluation network call.
Remote Each flag evaluation makes an HTTP request to the GO Feature Flag relay proxy using the OFREP API.

Initialize your Open Feature client

In-Process evaluation (default)

In-Process evaluation fetches the flag configuration from the relay proxy at startup and on a configurable polling interval. Flags are evaluated locally using a bundled WASM module, which gives you lower latency and no per-evaluation network dependency.

from gofeatureflag_python_provider.provider import GoFeatureFlagProvider
from gofeatureflag_python_provider.options import GoFeatureFlagOptions, EvaluationType
from openfeature import api
from openfeature.evaluation_context import EvaluationContext

goff_provider = GoFeatureFlagProvider(
    options=GoFeatureFlagOptions(
        endpoint="https://gofeatureflag.org/",
        evaluation_type=EvaluationType.INPROCESS,  # default
    )
)
api.set_provider(goff_provider)
client = api.get_client(domain="test-client")

Remote evaluation

Remote evaluation sends each flag evaluation as an HTTP request to the relay proxy.

from gofeatureflag_python_provider.provider import GoFeatureFlagProvider
from gofeatureflag_python_provider.options import GoFeatureFlagOptions, EvaluationType
from openfeature import api

goff_provider = GoFeatureFlagProvider(
    options=GoFeatureFlagOptions(
        endpoint="https://gofeatureflag.org/",
        evaluation_type=EvaluationType.REMOTE,
    )
)
api.set_provider(goff_provider)
client = api.get_client(domain="test-client")

Evaluate your flag

This code block explains how you can create an EvaluationContext and use it to evaluate your flag.

In this example we are evaluating a boolean flag, but other types are available.

Refer to the Open Feature documentation to know more about it.

# Context of your flag evaluation.
# With GO Feature Flag you MUST have a targetingKey that is a unique identifier of the user.
evaluation_ctx = EvaluationContext(
    targeting_key="d45e303a-38c2-11ed-a261-0242ac120002",
    attributes={
        "email": "john.doe@gofeatureflag.org",
        "firstname": "john",
        "lastname": "doe",
        "anonymous": False,
        "professional": True,
        "rate": 3.14,
        "age": 30,
        "company_info": {"name": "my_company", "size": 120},
        "labels": ["pro", "beta"],
    },
)

admin_flag = client.get_boolean_value(
    flag_key="flag-only-for-admin",
    default_value=False,
    evaluation_context=evaluation_ctx,
)

if admin_flag:
    # flag "flag-only-for-admin" is true for the user
    pass
else:
    # flag "flag-only-for-admin" is false for the user
    pass

Configuration options

Option Type Default Description
endpoint str (required) URL of the GO Feature Flag relay proxy
evaluation_type EvaluationType INPROCESS Evaluation mode: INPROCESS or REMOTE
data_collector_base_url str endpoint Base URL of the data collector only. Replaces the whole base — scheme, host, port and path prefix. Flag configuration and evaluation keep using endpoint
timeout int 10000 Timeout (ms) for flag configuration, remote evaluation and data collection requests. Carried by the HTTP client the provider builds, so a custom urllib3_pool_manager replaces it with its own
data_flush_interval int 60000 Interval (ms) to flush usage data to the relay proxy
disable_data_collection bool False Set to True to disable usage analytics
flag_config_poll_interval_seconds int 120 Polling interval (seconds) for flag configuration (in-process mode)
api_key str None API key for authenticated relay proxy requests, sent as Authorization: Bearer
exporter_metadata dict {} Static metadata attached to evaluation events. Values must be str, bool, int or float. The reserved keys provider and openfeature are always added and win over your values
max_pending_events int 10000 Buffered events that trigger an immediate flush. The buffer holds up to twice this many, above which the oldest are dropped
wasm_file_path str None Path to a custom WASM/WASI evaluation binary (in-process mode, uses bundled binary by default)
wasm_pool_size int CPU core count Pool size for concurrent WASM evaluation instances (in-process mode)
evaluation_flag_list list[str] None Restrict the fetched flag configuration to these keys. Unset or empty means all flags (in-process mode)
custom_headers dict[str, str] None Extra headers on every relay proxy request, for deployments behind a gateway with its own authentication. Applied before the provider's own headers, so a configured api_key wins over a custom Authorization
log_level str|int "WARNING" Logging level ("DEBUG", "INFO", "WARNING", "ERROR"). Applied only if your application has not configured the gofeatureflag_python_provider logger itself — see Logging
urllib3_pool_manager urllib3.PoolManager None Custom HTTP client for flag configuration and data collection. Remote evaluation uses the OFREP client, which builds its own

Usage analytics are collected only while the provider is running — between initialize() (called for you by set_provider) and shutdown(). Evaluations outside that window are not recorded: no flush runs to deliver them, and a buffer left to fill would post to the collector after shutdown() reported it was done. Each such period logs one warning, and the number of events dropped is reported if the provider is started again.

Logging

Every module logs through the standard library under the gofeatureflag_python_provider logger, with one child logger per module (gofeatureflag_python_provider.wasm.evaluate_wasm, gofeatureflag_python_provider.services.event_publisher, and so on). Attach your handler to the package logger to capture all of it:

import logging

logging.getLogger("gofeatureflag_python_provider").setLevel(logging.INFO)
logging.getLogger("gofeatureflag_python_provider").addHandler(logging.StreamHandler())

The provider ships a NullHandler on that logger, so it stays silent until your application configures logging.

Two things worth knowing:

  • log_level yields to your configuration. The provider applies it to the package logger only when nothing has set a level there yet, because that level is process-wide state. If you configure the logger yourself (directly or through logging.config.dictConfig), your setting wins. If several providers are created with different log_level values, the first one applies.
  • Exceptions raised inside hooks are logged by the OpenFeature SDK, under its own openfeature logger, not this one. log_level does not affect them — configure logging.getLogger("openfeature") if you need to see them.

Conformance

This provider targets version 1.0 of the GO Feature Flag Provider Specification, exposed as gofeatureflag_python_provider.__specification_version__.

The evaluation engine it is pinned to is recorded in gofeatureflag_python_provider/wasm/_wasi_version.txt, which is the single source of truth for the bundled WASI binary version.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gofeatureflag_python_provider-1.3.0.tar.gz (426.9 kB view details)

Uploaded Source

Built Distribution

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

gofeatureflag_python_provider-1.3.0-py3-none-any.whl (333.1 kB view details)

Uploaded Python 3

File details

Details for the file gofeatureflag_python_provider-1.3.0.tar.gz.

File metadata

  • Download URL: gofeatureflag_python_provider-1.3.0.tar.gz
  • Upload date:
  • Size: 426.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gofeatureflag_python_provider-1.3.0.tar.gz
Algorithm Hash digest
SHA256 5851fc0584a82a98ae4e76fd2e41ec634e44dd5993c3270eea6347df383e2a0b
MD5 e8b27887d0074e7a8d70c016525165a0
BLAKE2b-256 7e767af65081215aaf724946193d58a81cf299654722c401e299b0219bb6fea5

See more details on using hashes here.

File details

Details for the file gofeatureflag_python_provider-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: gofeatureflag_python_provider-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 333.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gofeatureflag_python_provider-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e747a3534ffa0acd0756e4d300a5284439926d0ba443af55f2fd882506d91a9
MD5 e5869655d2b4247b8703d0e89a208ba9
BLAKE2b-256 cf29175a8bc8618f2032d9a93b195dcea6a42ca9ed3dda5a0a8c8118198836ca

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.5.0

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page