Skip to main content

FigChain Python Client

Project description

FigChain Python Client

Official Python client library for FigChain configuration management.

Features

  • Real-time configuration updates - Subscribe to configuration changes with background polling
  • Rule-based rollouts - Evaluate feature flags and configurations based on user context
  • Type-safe models - Avro-based serialization for efficient data transfer with Python dataclasses
  • Flexible storage - Thread-safe in-memory storage
  • Python 3.7+ - Support for modern Python versions

Installation

Install using pip:

pip install figchain

Quick Start

from figchain import FigChainClient, Context

# Your generated config class (see "Generating Models")
from my_app.models import MyConfig 

# Initialize the client
client = FigChainClient(
    base_url="https://api.figchain.io",
    client_secret="your-client-secret",
    environment_id="your-environment-id",
    namespaces={"default"}
)

# Define context for evaluation (e.g., user properties for traffic splitting)
context: Context = {
    "userId": "user123",
    "plan": "premium"
}

# Fetch configuration safely
# returns Optional[MyConfig]
config = client.get_fig("your-fig-key", MyConfig, context=context)

if config:
    if config.enabled:
        print(f"Feature enabled with color: {config.backgroundColor}")
    else:
        print("Feature disabled")

# Clean up resources when done
client.close()

Generating Models

The Python client uses Avro schemas to generate type-safe dataclasses. You can use the included script to generate these models from your .avsc files:

# If installed from source in venv:
python3 scripts/generate_models.py path/to/schema.avsc path/to/output_models.py

Development

  1. Setup Environment:

    python3 -m venv venv
    . venv/bin/activate
    pip install -e .[dev]
    
  2. Run Tests:

    pytest
    

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Support

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

figchain-0.2.1.dev0.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

figchain-0.2.1.dev0-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file figchain-0.2.1.dev0.tar.gz.

File metadata

  • Download URL: figchain-0.2.1.dev0.tar.gz
  • Upload date:
  • Size: 35.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for figchain-0.2.1.dev0.tar.gz
Algorithm Hash digest
SHA256 4c9ffefcb65f71db6c127cc2db78243e09984c2ff8431e76ded84ab41cbe5f33
MD5 83a972c4dcb8538b6f9bb22091de52ec
BLAKE2b-256 c40eb3f18b28bee8df26c91ebeddd41948181ce15f1b3e91a4044b585f6da1a2

See more details on using hashes here.

File details

Details for the file figchain-0.2.1.dev0-py3-none-any.whl.

File metadata

  • Download URL: figchain-0.2.1.dev0-py3-none-any.whl
  • Upload date:
  • Size: 32.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for figchain-0.2.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 f626fdbc87da4ef656c862ecd7f2025e6ddb17f6d6f13d8f79f16a02898d1efe
MD5 43dbb9a8be8ba3e4bd64d50a57e245e5
BLAKE2b-256 798cc975f24af0f1237a7ab510da01dcf705f7f4701d3a2ddfddc2e69bd531bc

See more details on using hashes here.

Supported by

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