Python Client - Getting Started

Python Client - Getting Started

The EFF Python client is a tool designed to manage feature flags in your python applications. It provides an interface to check if a feature flag is enabled for a given discriminator. The client is designed to be instantiated once and reused throughout the application.

Table of Contents

Installation

Install the latest version of the EFF Python client in your projects chosen dependency management tool. The full list of available versions can be found in Artifactory. If you’re using uv, see the https://asudev.jira.com/wiki/spaces/ARTF/pages/4130996331guide. You can use any tool (pip, poetry, etc.) but the Artifactory configuration will differ slightly.

Assuming you use uv, install with

uv add asu-eff-client

Configuration

The client is configured with sensible defaults. Most people won't need to change them, but you can override them with environment variables.

Environment Variable

Description

Default

Environment Variable

Description

Default

FEATURE_FLAGS_ENVIRONMENT

Environment to evaluate feature flags against

prod

FEATURE_FLAGS_STATE_URL

URL to fetch feature flag state from

https://state.appss-eff.services.asu.edu/state.json

STALE_CACHE_THRESHOLD_SECONDS

Duration (in seconds) after which cache is considered stale

900

STATE_FETCH_TIMEOUT

Timeout (in seconds) for fetching feature flag state

2

FAIL_ON_INITIAL_FETCH_FAILURE

Raise error if first fetch fails and cache is empty

True

FAIL_ON_STALE_CACHE

Raise error if cache is stale

False

Example: Checking Feature Flags

To check if a feature flag, call the .is_enabled(…) method on the feature flags client. This method returns a boolean and takes 2 parameters:

  1. Feature Flag ID - the ID of the feature flag, which can be copied from the EFF UI (ie. SOME_GREAT_FEATURE_123456).

  2. Discriminator - some kind of value used to differentiate users and bucket requests into different allocations, most commonly a user ID of some kind. See Feature Flags Primer | Discriminator for more details. This value must be a non-empty string.

from asu_eff_client import EffClient eff_client = EffClient() if eff_client.is_enabled("SOME_GREAT_FEATURE_123456", "user_123"): print("Feature flag is enabled!") else: print("Feature flag is disabled.")