Skip to main content

railflag-openfeature

Railflag's OpenFeature provider for Python 3.10+. It downloads your environment's flag config once, evaluates every flag check in process (about 15 µs, no network call), and picks up changes within a second over Server-Sent Events. If the stream drops it polls every 30 s, and if Railflag can't be reached it keeps serving the last config it had. The only dependency is openfeature-sdk.

import os
from openfeature import api
from openfeature.evaluation_context import EvaluationContext
from railflag import RailflagProvider

api.set_provider_and_wait(RailflagProvider(
    sdk_key=os.environ["RAILFLAG_SERVER_KEY"],          # a server key: Environments → keys
    base_url="https://relay.railflag.com",  # required: your Railflag relay
))
client = api.get_client()

if client.get_boolean_value("new-checkout", False, EvaluationContext("user-42", {"plan": "pro", "country": "GR"})):
    ...
  • get_boolean_value, get_string_value, get_integer_value, get_float_value and get_object_value work as in any OpenFeature provider. A wrong type or unknown flag returns your default with an error code.
  • datetime and date attributes are compared as instants, so before/after rules work with them.
  • api.add_handler(ProviderEvent.PROVIDER_CONFIGURATION_CHANGED, fn) tells you when flags change; details.flags_changed lists them.
  • Server keys can read every rule. Keep them on the server; browsers use the JavaScript SDK with a client key.
  • Once a minute the provider sends how many times each flag returned each variation, for Release Watch. It sends counts only, such as {"new-checkout": {"1": 42}}, and never contexts or user ids. Sending runs on a background thread and never delays a flag check. Turn it off with send_exposures=False.

Experiments

Start an experiment on a flag in the Railflag dashboard, then record the conversions it measures:

from openfeature.track import TrackingEventDetails

client.track("purchase", EvaluationContext("user-42"), TrackingEventDetails(value=49.9))
  • Exposures are sent automatically: while an experiment runs on a flag, the provider sends which variation each user was randomized into, once per user and variation. Users served by a target or a fixed rule aren't part of the experiment and aren't sent.
  • track() events are sent only for events a running experiment counts; a missing value counts as 0. With no experiment running, nothing is sent.
  • This sends user keys (the targeting key, or the key attribute), which Railflag hashes before storing them. Never contexts or other attributes.
  • Data goes out every 10 s (events_interval) on a background thread and never delays a flag check or track(). Turn it off with send_events=False.

Same answers as every other SDK

railflag/evaluate.py is a port of packages/eval. The tests run it against packages/eval/vectors/eval-vectors.json (hashes, buckets and thousands of evaluations generated by the TypeScript evaluator), so a user lands in the same variation whichever SDK evaluates the flag. Context values follow JavaScript rules: 1 and True are different, numbers print as JavaScript prints them, and strings sort by UTF-16 code units.

Known differences: regexes in matches rules run on Python's re (with ASCII \d/\w), and a date-time without a time zone is read as UTC.

Development

uv sync
uv run pytest
SY_EMAIL=... SY_PASSWORD=... uv run python examples/live_check.py   # against production; rotates the Development server key

Metadata

Release files for railflag-openfeature 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for railflag-openfeature 0.4.0
File Size Uploaded Provenance Actions
railflag_openfeature-0.4.0.tar.gz 21.7 kB With provenance Details for railflag_openfeature-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for railflag-openfeature 0.4.0
File Interpreter ABI Platform Actions
railflag_openfeature-0.4.0-py3-none-any.whl Python 3 none any Details for railflag_openfeature-0.4.0-py3-none-any.whl

Total release size: 41.8 kB

Release files / railflag_openfeature-0.4.0.tar.gz

Download URL railflag_openfeature-0.4.0.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e510517f3511cea1be43cc54e335b5775e8659a0a9bd3f6e84966f4bd340aeb3
BLAKE2b-256 checksum
How to use checksums
ea8dead5d28d7e845f54fbddf1daa407f016da5279497465179662e99802c20e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / railflag_openfeature-0.4.0-py3-none-any.whl

Download URL railflag_openfeature-0.4.0-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a190554a004b69931f1f2e9f4da8d436c352a27ce48460c4d61e81ae53baaf52
BLAKE2b-256 checksum
How to use checksums
9da04c82c8f7dbe64132652407db9458e4ee3b4f6a08e7e46768df0199b310a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for railflag-openfeature 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for railflag_openfeature-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page