superposition_provider
Project description
Installation
pip install superposition_provider
Quick Start
Note: You will need to boot up Superposition before running the client code.
import asyncio
from superposition_provider.types import ExperimentationOptions, SuperpositionProviderOptions, PollingStrategy
from openfeature import api
from superposition_provider.provider import SuperpositionProvider
from openfeature.evaluation_context import EvaluationContext
async def test_config():
"""Integration test function - enhanced version of original test"""
print("Testing SuperpositionProvider integration...")
config_options = SuperpositionProviderOptions(
endpoint="http://localhost:8080", # or any valid superposition endpoint
token="token",
org_id="localorg",
workspace_id="test",
refresh_strategy=PollingStrategy(
interval=5, # Poll every 5 seconds
timeout=3 # Timeout after 3 seconds
),
fallback_config=None,
evaluation_cache_options=None,
experimentation_options=ExperimentationOptions(
refresh_strategy=PollingStrategy(
interval=5, # Poll every 5 seconds
timeout=3 # Timeout after 3 seconds
)
)
)
provider = SuperpositionProvider(provider_options=config_options)
ctx = EvaluationContext(
targeting_key="25", # Using a targeting key for experiment variant decider
attributes={'d1': 'd1'}
)
try:
# Initialize provider
await provider.initialize(context=ctx)
api.set_provider(provider)
client = api.get_client()
bool_val = client.get_boolean_details(
flag_key="bool",
default_value=True,
evaluation_context=ctx
)
# Note: If you want the whole config, you can directly use the provider itself
resp = provider.resolve_all_config_details({}, ctx)
print(f"Response for all config: {resp}")
print("Successfully resolved boolean flag details:", bool_val)
except Exception as e:
print(f"Test failed with error: {e}")
finally:
# Cleanup
if hasattr(provider, 'shutdown'):
await provider.shutdown()
if __name__ == "__main__":
asyncio.run(test_config())
Running the Python Example
python demo.py
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 superposition_provider-0.85.1-py3-none-any.whl.
File metadata
- Download URL: superposition_provider-0.85.1-py3-none-any.whl
- Upload date:
- Size: 4.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a288141867d17dc90c1da24fdf9775d6b886d606274c1b277b34a0e794e3573a
|
|
| MD5 |
22ba7f68cdb45d45c3082d4ce2a65cf8
|
|
| BLAKE2b-256 |
12af4ef5af23c89f983c358f8d363846ead4f52df650268bfde3cb0e0c204889
|