
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
harness-featureflags
Advanced tools
Intro
Requirements
Quickstart
Further Reading
Build Instructions
Use this README to get started with our Feature Flags (FF) SDK for Python. This guide outlines the basics of getting started with the SDK and provides a full code sample for you to try out. This sample doesn’t include configuration options, for in depth steps and configuring the SDK, for example, disabling streaming or using our Relay Proxy, see the Python SDK Reference.
For a sample FF Python SDK project, see our test test python project.
Python 3.7 or newer (python --version)
pip
For Mac users if you don't already have pyenv or something similar installed for managing python version
To follow along with our test code sample, make sure you’ve:
Install the python SDK using pip
python -m pip install harness-featureflags
The following is a complete code example that you can use to test the harnessappdemodarkmode
Flag you created on the Harness Platform. When you run the code it will:
from featureflags.client import CfClient
from featureflags.config import *
from featureflags.evaluations.auth_target import Target
from featureflags.util import log
import os
import time
# API Key
apiKey = os.getenv('FF_API_KEY', "changeme")
# Flag Name
flagName = os.getenv('FF_FLAG_NAME', "harnessappdemodarkmode")
def main():
# Create a Feature Flag Client
client = CfClient(apiKey)
# Create a target (different targets can get different results based on rules. This include a custom attribute 'location')
target = Target(identifier='HT_1', name="Harness_Target_1", attributes={"location": "emea"})
# Loop forever reporting the state of the flag
while True:
result = client.bool_variation(flagName, target, False)
log.info("Flag variation %s", result)
time.sleep(10)
if __name__ == "__main__":
main()
$ export FF_API_KEY=<your key here>
$ python3 examples/getting_started/getting_started.py
If you dont have the right version of python installed locally, or dont want to install the dependancies you can use docker to quickly get started
# Install the package
docker run -v $(pwd):/app -w /app python:3.7-slim python -m pip install -t ./local harness-featureflags
# Run the script
docker run -e PYTHONPATH=/app/local -e FF_API_KEY=$FF_API_KEY -v $(pwd):/app -w /app python:3.7-slim python examples/getting_started/getting_started.py
For further examples and config options, see the Python SDK Reference.
For more information about Feature Flags, see our Feature Flags documentation.
Harness is a feature management platform that helps teams to build better software and to test features quicker.
FAQs
Feature flag server SDK for python
We found that harness-featureflags demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.