{"id":19149805,"url":"https://github.com/harness/ff-python-server-sdk","last_synced_at":"2025-04-09T14:09:51.239Z","repository":{"id":37765538,"uuid":"344597565","full_name":"harness/ff-python-server-sdk","owner":"harness","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-19T11:32:28.000Z","size":494,"stargazers_count":5,"open_issues_count":0,"forks_count":15,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-02T07:43:46.238Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harness.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-04T20:14:04.000Z","updated_at":"2025-03-19T11:31:00.000Z","dependencies_parsed_at":"2023-01-31T01:45:38.110Z","dependency_job_id":"6e0dda99-672a-4cd8-a0db-b44b26c73259","html_url":"https://github.com/harness/ff-python-server-sdk","commit_stats":{"total_commits":121,"total_committers":13,"mean_commits":9.307692307692308,"dds":0.5702479338842975,"last_synced_commit":"ff3993f3dc26c43c159a074e7179253ac962d4bd"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-python-server-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-python-server-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-python-server-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fff-python-server-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harness","download_url":"https://codeload.github.com/harness/ff-python-server-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054194,"owners_count":21039952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:09:45.031Z","updated_at":"2025-04-09T14:09:51.221Z","avatar_url":"https://github.com/harness.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Python SDK For Harness Feature Flags\n========================\n\n[![pypi](https://img.shields.io/pypi/v/harness-featureflags.svg)](https://pypi.python.org/pypi/harness-featureflags)\n\n## Table of Contents\n**[Intro](#Intro)**\u003cbr\u003e\n**[Requirements](#Requirements)**\u003cbr\u003e\n**[Quickstart](#Quickstart)**\u003cbr\u003e\n**[Further Reading](docs/further_reading.md)**\u003cbr\u003e\n**[Build Instructions](docs/build.md)**\u003cbr\u003e\n\n\n## Intro\n\nUse 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. \nThis 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](https://ngdocs.harness.io/article/hwoxb6x2oe-python-sdk-reference).\n\nFor a sample FF Python SDK project, see our test [test python project](examples/getting_started/getting_started.py).\n\n![FeatureFlags](https://github.com/harness/ff-python-server-sdk/raw/main/docs/images/ff-gui.png)\n\n## Requirements\n\n[Python 3.7](https://www.python.org/downloads/) or newer (python --version)\u003cbr\u003e\n[pip](https://packaging.python.org/en/latest/tutorials/installing-packages/#id12)\u003cbr\u003e\n\u003cbr\u003e\n[For Mac users](https://opensource.com/article/19/5/python-3-default-mac) if you don't already have pyenv or something similar installed for managing python version\u003cbr\u003e\n\n\n## Quickstart\nTo follow along with our test code sample, make sure you’ve:\n\n- [Created a Feature Flag on the Harness Platform](https://ngdocs.harness.io/article/1j7pdkqh7j-create-a-feature-flag) called harnessappdemodarkmode\n- [Created a server SDK key and made a copy of it](https://ngdocs.harness.io/article/1j7pdkqh7j-create-a-feature-flag#step_3_create_an_sdk_key)\n- \n### Install the SDK\nInstall the python SDK using pip\n```python\npython -m pip install harness-featureflags\n```\n\n### Code Sample\nThe 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:\n- Connect to the FF service.\n- Report the value of the Flag every 10 seconds until the connection is closed. Every time the harnessappdemodarkmode Flag is toggled on or off on the Harness Platform, the updated value is reported. \n- Close the SDK.\n\n```python\nfrom featureflags.client import CfClient\nfrom featureflags.config import *\nfrom featureflags.evaluations.auth_target import Target\nfrom featureflags.util import log\nimport os\nimport time\n\n# API Key\napiKey = os.getenv('FF_API_KEY', \"changeme\")\n\n# Flag Name\nflagName = os.getenv('FF_FLAG_NAME', \"harnessappdemodarkmode\")\n\ndef main():    \n    # Create a Feature Flag Client\n    client = CfClient(apiKey)\n\n    # Create a target (different targets can get different results based on rules.  This include a custom attribute 'location')\n    target = Target(identifier='HT_1', name=\"Harness_Target_1\", attributes={\"location\": \"emea\"})\n\n    # Loop forever reporting the state of the flag\n    while True:\n        result = client.bool_variation(flagName, target, False)\n        log.info(\"Flag variation %s\", result)\n        time.sleep(10)\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Running the example\n\n```bash\n$ export FF_API_KEY=\u003cyour key here\u003e\n$ python3 examples/getting_started/getting_started.py\n```\n\n### Running the example with Docker\nIf you dont have the right version of python installed locally, or dont want to install the dependancies you can\nuse docker to quickly get started\n\n```bash\n# Install the package\ndocker run -v $(pwd):/app -w /app python:3.7-slim python -m pip install -t ./local  harness-featureflags\n\n# Run the script\ndocker 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\n```\n\n### Additional Reading\n\nFor further examples and config options, see the [Python SDK Reference](https://ngdocs.harness.io/article/hwoxb6x2oe-python-sdk-reference).\n\nFor more information about Feature Flags, see our [Feature Flags documentation](https://ngdocs.harness.io/article/0a2u2ppp8s-getting-started-with-feature-flags).\n\n-------------------------\n[Harness](https://www.harness.io/) is a feature management platform that helps teams to build better software and to\ntest features quicker.\n\n-------------------------\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharness%2Fff-python-server-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharness%2Fff-python-server-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharness%2Fff-python-server-sdk/lists"}