harness-featureflags


Nameharness-featureflags JSON
Version 1.7.1 PyPI version JSON
download
home_pagehttps://github.com/harness/ff-python-server-sdk
SummaryFeature flag server SDK for python
upload_time2025-01-23 14:26:24
maintainerNone
docs_urlNone
authorHarness
requires_python>=3.5
licenseApache Software License 2.0
keywords featureflags
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Python SDK For Harness Feature Flags
========================

[![pypi](https://img.shields.io/pypi/v/harness-featureflags.svg)](https://pypi.python.org/pypi/harness-featureflags)

## Table of Contents
**[Intro](#Intro)**<br>
**[Requirements](#Requirements)**<br>
**[Quickstart](#Quickstart)**<br>
**[Further Reading](docs/further_reading.md)**<br>
**[Build Instructions](docs/build.md)**<br>


## Intro

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](https://ngdocs.harness.io/article/hwoxb6x2oe-python-sdk-reference).

For a sample FF Python SDK project, see our test [test python project](examples/getting_started/getting_started.py).

![FeatureFlags](https://github.com/harness/ff-python-server-sdk/raw/main/docs/images/ff-gui.png)

## Requirements

[Python 3.7](https://www.python.org/downloads/) or newer (python --version)<br>
[pip](https://packaging.python.org/en/latest/tutorials/installing-packages/#id12)<br>
<br>
[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<br>


## Quickstart
To follow along with our test code sample, make sure you’ve:

- [Created a Feature Flag on the Harness Platform](https://ngdocs.harness.io/article/1j7pdkqh7j-create-a-feature-flag) called harnessappdemodarkmode
- [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)
- 
### Install the SDK
Install the python SDK using pip
```python
python -m pip install harness-featureflags
```

### Code Sample
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:
- Connect to the FF service.
- 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. 
- Close the SDK.

```python
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()
```

### Running the example

```bash
$ export FF_API_KEY=<your key here>
$ python3 examples/getting_started/getting_started.py
```

### Running the example with Docker
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

```bash
# 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
```

### Additional Reading

For further examples and config options, see the [Python SDK Reference](https://ngdocs.harness.io/article/hwoxb6x2oe-python-sdk-reference).

For more information about Feature Flags, see our [Feature Flags documentation](https://ngdocs.harness.io/article/0a2u2ppp8s-getting-started-with-feature-flags).

-------------------------
[Harness](https://www.harness.io/) is a feature management platform that helps teams to build better software and to
test features quicker.

-------------------------



=======
History
=======

1.0.1 (2021-07-07)
------------------

* First release on PyPI.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/harness/ff-python-server-sdk",
    "name": "harness-featureflags",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": null,
    "keywords": "featureflags",
    "author": "Harness",
    "author_email": "support@harness.io",
    "download_url": "https://files.pythonhosted.org/packages/10/de/641ecceeb0677965d31f02e472c36fed93a521b08239e21f8964f4951bea/harness_featureflags-1.7.1.tar.gz",
    "platform": null,
    "description": "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)**<br>\n**[Requirements](#Requirements)**<br>\n**[Quickstart](#Quickstart)**<br>\n**[Further Reading](docs/further_reading.md)**<br>\n**[Build Instructions](docs/build.md)**<br>\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\u2019t 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)<br>\n[pip](https://packaging.python.org/en/latest/tutorials/installing-packages/#id12)<br>\n<br>\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<br>\n\n\n## Quickstart\nTo follow along with our test code sample, make sure you\u2019ve:\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=<your key here>\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\n\n=======\nHistory\n=======\n\n1.0.1 (2021-07-07)\n------------------\n\n* First release on PyPI.\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Feature flag server SDK for python",
    "version": "1.7.1",
    "project_urls": {
        "Homepage": "https://github.com/harness/ff-python-server-sdk"
    },
    "split_keywords": [
        "featureflags"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f68dfd211aeaf0f102cfb89ba986d6231ce58bd4a05d5ece95c598717ba6b243",
                "md5": "3bf6e83a14db2195299d25682bee7cf5",
                "sha256": "e6a0b3ea15cae5f7ecf81e1d6b1344cd1461e57bb36c43704630d7fddc65fc76"
            },
            "downloads": -1,
            "filename": "harness_featureflags-1.7.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3bf6e83a14db2195299d25682bee7cf5",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.5",
            "size": 98390,
            "upload_time": "2025-01-23T14:26:22",
            "upload_time_iso_8601": "2025-01-23T14:26:22.011068Z",
            "url": "https://files.pythonhosted.org/packages/f6/8d/fd211aeaf0f102cfb89ba986d6231ce58bd4a05d5ece95c598717ba6b243/harness_featureflags-1.7.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "10de641ecceeb0677965d31f02e472c36fed93a521b08239e21f8964f4951bea",
                "md5": "2342cad552b95d625b021afce357aa4a",
                "sha256": "7622db1153c78eeb2b55eaf976109139d5824e00fabfda26de90d7079a333a7f"
            },
            "downloads": -1,
            "filename": "harness_featureflags-1.7.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2342cad552b95d625b021afce357aa4a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 195385,
            "upload_time": "2025-01-23T14:26:24",
            "upload_time_iso_8601": "2025-01-23T14:26:24.029346Z",
            "url": "https://files.pythonhosted.org/packages/10/de/641ecceeb0677965d31f02e472c36fed93a521b08239e21f8964f4951bea/harness_featureflags-1.7.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-23 14:26:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "harness",
    "github_project": "ff-python-server-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "harness-featureflags"
}
        
Elapsed time: 0.75755s