SDK for Deleashes feature flag management service
Project description
Deleashes SDK for Python
A Python client for the Deleashes feature flag service.
Installation
pip install deleashes-sdk
Or from source:
git clone https://github.com/explrms/DeleashesSDK-python.git
cd deleashes-sdk-python
pip install -e .
Quick Start
from deleashes import Deleashes
from deleashes.logging import get_logger
import logging
# Configure logging (optional)
logger = get_logger()
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO) # Set to DEBUG for verbose logging
# Initialize the client
client = Deleashes(
api_key="YOUR_PROJECT_API_KEY",
base_url="https://your-deleashes-url.com", # Required: URL of your Deleashes instance
environment="development" # Or "staging", "production"
)
# Check if a feature flag is enabled
if client.is_enabled("new-feature"):
# Feature flag is enabled
print("Feature is enabled!")
# Get the value of a feature flag
feature_value = client.get_value("feature-with-config", default_value="default")
print(f"Feature value: {feature_value}")
# With user context
user_context = {
"user_id": "user-123",
"context": {
"country": "US",
"plan": "premium"
}
}
if client.is_enabled("premium-feature", context=user_context):
print("Premium feature is enabled for this user!")
Configuration
Environments
Valid environments:
developmentstagingproduction
Logging
The SDK uses Python's built-in logging system. You can configure the logger to suit your needs:
from deleashes.logging import get_logger
import logging
logger = get_logger()
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
# Set the log level
logger.setLevel(logging.INFO) # Or DEBUG, WARNING, ERROR, etc.
Error Handling
The SDK is designed to fail gracefully. If a flag cannot be evaluated (e.g., network issues, invalid flag key):
is_enabled()returnsFalseget_value()returns the provided default value
These failures are logged at the appropriate level (warning or error).
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 deleashes_sdk-0.1.2.tar.gz.
File metadata
- Download URL: deleashes_sdk-0.1.2.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a149f68dc54e430c0418f16bdd08b51749fd15449b7cfeeb4978ff9996fc824d
|
|
| MD5 |
786ecdb19e473978920f2cbb7efd529d
|
|
| BLAKE2b-256 |
0ac86e93b4c23c9c2cf28fee98401e42ad2af1fa6ac3057e4894a7736c81dca9
|
File details
Details for the file deleashes_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: deleashes_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
741b52b241140fe5b9358aef7f789495663e00b8db18ffb3dd2662654684d376
|
|
| MD5 |
ac748bdfbacee883fac39cc17d670e29
|
|
| BLAKE2b-256 |
6cae794e420b3a378fb0ab538db303a6e05610da7896afa4738aa38063ff7457
|