gofeatureflag-python-provider


Namegofeatureflag-python-provider JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://gofeatureflag.org
SummaryGO Feature Flag provider for OpenFeature
upload_time2024-04-30 10:47:40
maintainerNone
docs_urlNone
authorThomas Poignant
requires_python<4.0,>=3.9
licenseApache-2.0
keywords feature flags feature toggles go-feature-flag gofeatureflag openfeature open-feature
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GO Feature Flag Python Provider

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

[GO Feature Flag](https://gofeatureflag.org) 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**.

```shell
pip install gofeatureflag-python-provider
```

## Initialize your Open Feature client

To evaluate the flags you need to have an Open Feature configured in you app.
This code block shows you how you can create a client that you can use in your application.

```python
from gofeatureflag_python_provider.provider import GoFeatureFlagProvider
from gofeatureflag_python_provider.options import GoFeatureFlagOptions
from openfeature import api
from openfeature.evaluation_context import EvaluationContext

# ...

goff_provider = GoFeatureFlagProvider(
    options=GoFeatureFlagOptions(endpoint="https://gofeatureflag.org/")
)
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](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api#basic-evaluation) to know more about it.**

```python
# 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_key,
          default_value=default_value,
          evaluation_context=ctx,
      )
      
if admin_flag:
  # flag "flag-only-for-admin" is true for the user
else:
  # flag "flag-only-for-admin" is false for the user
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://gofeatureflag.org",
    "name": "gofeatureflag-python-provider",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "feature flags, feature toggles, go-feature-flag, gofeatureflag, openfeature, open-feature",
    "author": "Thomas Poignant",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ab/ed/6d053186d46f774632d165e5509bb0b09f2ab42b7c5c3ca044175c8f9dca/gofeatureflag_python_provider-0.2.0.tar.gz",
    "platform": null,
    "description": "# GO Feature Flag Python Provider\n\nGO Feature Flag provider allows you to connect to your GO Feature Flag instance.  \n\n[GO Feature Flag](https://gofeatureflag.org) believes in simplicity and offers a simple and lightweight solution to use feature flags.  \nOur focus is to avoid any complex infrastructure work to use GO Feature Flag.\n\nThis 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.\n\n# Python SDK usage\n\n## Install dependencies\n\nThe first things we will do is install the **Open Feature SDK** and the **GO Feature Flag provider**.\n\n```shell\npip install gofeatureflag-python-provider\n```\n\n## Initialize your Open Feature client\n\nTo evaluate the flags you need to have an Open Feature configured in you app.\nThis code block shows you how you can create a client that you can use in your application.\n\n```python\nfrom gofeatureflag_python_provider.provider import GoFeatureFlagProvider\nfrom gofeatureflag_python_provider.options import GoFeatureFlagOptions\nfrom openfeature import api\nfrom openfeature.evaluation_context import EvaluationContext\n\n# ...\n\ngoff_provider = GoFeatureFlagProvider(\n    options=GoFeatureFlagOptions(endpoint=\"https://gofeatureflag.org/\")\n)\napi.set_provider(goff_provider)\nclient = api.get_client(domain=\"test-client\")\n```\n\n## Evaluate your flag\n\nThis code block explains how you can create an `EvaluationContext` and use it to evaluate your flag.\n\n\n> In this example we are evaluating a `boolean` flag, but other types are available.\n> \n> **Refer to the [Open Feature documentation](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api#basic-evaluation) to know more about it.**\n\n```python\n# Context of your flag evaluation.\n# With GO Feature Flag you MUST have a targetingKey that is a unique identifier of the user.\nevaluation_ctx = EvaluationContext(\n    targeting_key=\"d45e303a-38c2-11ed-a261-0242ac120002\",\n    attributes={\n        \"email\": \"john.doe@gofeatureflag.org\",\n        \"firstname\": \"john\",\n        \"lastname\": \"doe\",\n        \"anonymous\": False,\n        \"professional\": True,\n        \"rate\": 3.14,\n        \"age\": 30,\n        \"company_info\": {\"name\": \"my_company\", \"size\": 120},\n        \"labels\": [\"pro\", \"beta\"],\n    },\n)\n\nadmin_flag = client.get_boolean_value(\n          flag_key=flag_key,\n          default_value=default_value,\n          evaluation_context=ctx,\n      )\n      \nif admin_flag:\n  # flag \"flag-only-for-admin\" is true for the user\nelse:\n  # flag \"flag-only-for-admin\" is false for the user\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "GO Feature Flag provider for OpenFeature",
    "version": "0.2.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/thomaspoignant/go-feature-flag/issues",
        "Documentation": "https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider",
        "Homepage": "https://gofeatureflag.org",
        "Repository": "https://github.com/thomaspoignant/go-feature-flag",
        "Source Code": "https://github.com/thomaspoignant/go-feature-flag/tree/main/openfeature/providers/python-provider"
    },
    "split_keywords": [
        "feature flags",
        " feature toggles",
        " go-feature-flag",
        " gofeatureflag",
        " openfeature",
        " open-feature"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c0389b00f7461f2bfff0aa39960acb4d5debf8ce61555cc9972fabd1b5e1e064",
                "md5": "7012385a3928e01bff61bf39c4d80c40",
                "sha256": "00aa9d5a5ffd1f7b5a3cf9d3afdf71d66e49d18cc7acf3689fa6db940fa05d23"
            },
            "downloads": -1,
            "filename": "gofeatureflag_python_provider-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7012385a3928e01bff61bf39c4d80c40",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 10917,
            "upload_time": "2024-04-30T10:47:39",
            "upload_time_iso_8601": "2024-04-30T10:47:39.333338Z",
            "url": "https://files.pythonhosted.org/packages/c0/38/9b00f7461f2bfff0aa39960acb4d5debf8ce61555cc9972fabd1b5e1e064/gofeatureflag_python_provider-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "abed6d053186d46f774632d165e5509bb0b09f2ab42b7c5c3ca044175c8f9dca",
                "md5": "bfd6c58cbd517802cd17a9ffc3986e67",
                "sha256": "d311cb7a53956bf58208939eb23d675ab4c73e0684ad5584b6709f7f11dc27a8"
            },
            "downloads": -1,
            "filename": "gofeatureflag_python_provider-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bfd6c58cbd517802cd17a9ffc3986e67",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 8825,
            "upload_time": "2024-04-30T10:47:40",
            "upload_time_iso_8601": "2024-04-30T10:47:40.840652Z",
            "url": "https://files.pythonhosted.org/packages/ab/ed/6d053186d46f774632d165e5509bb0b09f2ab42b7c5c3ca044175c8f9dca/gofeatureflag_python_provider-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-30 10:47:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "thomaspoignant",
    "github_project": "go-feature-flag",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "gofeatureflag-python-provider"
}
        
Elapsed time: 0.28497s