Skip to main content

Flipt Client Evaluation SDK

Project description

Flipt Client Python

The flipt-client-python directory contains the Python source code for the Flipt client-side evaluation client.

Installation

Currently, to use this client, you'll need to build the dynamic library and the package locally and install it. This is a temporary solution until we can figure out a better way to package and distribute the libraries.

The dynamic library will contain the functionality necessary for the client to make calls to the Flipt engine via FFI. See flipt-engine for more information on the Flipt engine and FFI.

Prerequisites

Automated Build

  1. Build and copy the dynamic library to the flipt-client-python/ext directory for your platform. This will also build and install the flipt-client Python package. You can do this by running the following command from the root of the repository:

    make python
    

Manual Build

  1. Build the Rust dynamic library

    cargo build --release
    

This should generate a target/ directory in the root of this repository, which contains the dynamically linked library built for your platform.

  1. You'll need to copy the dynamic library to the flipt-client-python/ext/$OS_$ARCH/ directory. This is a temporary solution until we can figure out a better way to package the libraries with the package.

The path/to/lib will be the path to the dynamic library which will have the following paths depending on your platform.

  • Linux: {REPO_ROOT}/target/release/libfliptengine.so
  • Windows: {REPO_ROOT}/target/release/libfliptengine.dll
  • MacOS: {REPO_ROOT}/target/release/libfliptengine.dylib
  1. You can then build the package and install it locally. You can do this by running the following command from the flipt-client-python directory:

    poetry install
    

Usage

In your Python code you can import this client and use it as so:

from flipt_client import FliptEvaluationClient

# "namespace" and "engine_opts" are two keyword arguments that this constructor accepts
# namespace: which namespace to fetch flag state from
# engine_opts: follows the model EngineOpts in the models.py file. Configures the url of the upstream Flipt instance, the interval in which to fetch new flag state, and the auth token if your upstream Flipt instance requires it
flipt_evaluation_client = FliptEvaluationClient()

variant_result = flipt_evaluation_client.evaluate_variant(flag_key="flag1", entity_id="entity", context={"fizz": "buzz"})

print(variant_result)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flipt_client-0.0.1.tar.gz (21.3 MB view details)

Uploaded Source

Built Distribution

flipt_client-0.0.1-py3-none-any.whl (21.4 MB view details)

Uploaded Python 3

File details

Details for the file flipt_client-0.0.1.tar.gz.

File metadata

  • Download URL: flipt_client-0.0.1.tar.gz
  • Upload date:
  • Size: 21.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.7 Linux/5.15.49-linuxkit-pr

File hashes

Hashes for flipt_client-0.0.1.tar.gz
Algorithm Hash digest
SHA256 175a4bfe5347163a61e1f3536c76276f25c4da238932cd0f7a6332ed62d845d1
MD5 64015a4ce27b4fe3cb0354df2296262e
BLAKE2b-256 39c6c8ad0f72a365f5326983737c9422eb34cbb484032194a34d21407091ee41

See more details on using hashes here.

File details

Details for the file flipt_client-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: flipt_client-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.7 Linux/5.15.49-linuxkit-pr

File hashes

Hashes for flipt_client-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a745bb0798083c62f115b522a84896b40fc85873937f669ba063e011ab2c48e
MD5 1ddac57c1003f2993e7be9a15e261a28
BLAKE2b-256 6fbf2b28738c894a4c6096f85848f51370bc5f32a5b3e80a84c93d537bf79358

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page