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
-
Setup Environment:
python3 -m venv venv . venv/bin/activate pip install -e .[dev]
-
Run Tests:
pytest
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file figchain-0.1.0.post0.tar.gz.
File metadata
- Download URL: figchain-0.1.0.post0.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7c89372703d0afcabd3914dd74107c78d5678ca89f93466893b659f68b42fc8
|
|
| MD5 |
4a34825f79378d54381d01539f28c0d1
|
|
| BLAKE2b-256 |
b5c5912f6f8f435a4b22bf20ff813909965c0163df2b74b267010cedd7742d9b
|
File details
Details for the file figchain-0.1.0.post0-py3-none-any.whl.
File metadata
- Download URL: figchain-0.1.0.post0-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca36ba2355ddc47cd7318d3f608312d4dbbc2d82ed8390ef6ebcb699a438ac5f
|
|
| MD5 |
cffd1657de03f35e7161c757ef68fc38
|
|
| BLAKE2b-256 |
f2b6b50c38370a246a0ba293f4fc0b10b54bb66d09e644c0065786d47ca39fae
|