Skip to main content

Feature Toggles

This repo provides functionality for feature toggles in python code.

What does this package do?

  1. It allows to access the configured toggles like toggles.feature1
  2. It logs all uses of the toggle
  3. It logs a warning when toggles have exceeded their maximum lifetime

How to use

Configure the toggles

The toggles are configured in yaml.

feature1:
    value: true
    name: New Thing Toggler
    description: This toggles the new thing on
    jira: DAN-123
    creation_date: 2020-10-12
    max_lifetime: 14

Required fields:

  • value: a boolean setting the value of the toggle
  • name: a human readable name for the toggle
  • jira: the JIRA ticket that this toggle is linked to.
  • creation_date: the date this toggle is introduced.

Optional fields:

  • description: A description of the purpose and use of the toggle
  • max_lifetime: The number of days this toggle is supposed to be in the code. A warning will be logged when this lifetime is exceeded. The default is 14 days.

Declare the toggles

To use the configured toggles they need to be declared in the code like this:

from featuretoggles import TogglesList

class ReleaseToggles(TogglesList):
    feature1: bool
    feature2: bool


toggles = ReleaseToggles('toggles.yaml')

The toggle can be used to gate particular bits of code like this:

if toggles.feature1:
    print("Feature One Activated")
else:
    print("Feature One Deactivated")

Demo

See demo for a working example

Metadata

Release files for featuretoggles 1.0.2

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

Source distribution (sdist)

Source distribution for featuretoggles 1.0.2
File Size Uploaded
featuretoggles-1.0.2.tar.gz 15.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for featuretoggles 1.0.2
File Interpreter ABI Platform
featuretoggles-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 31.6 kB

Release files / featuretoggles-1.0.2.tar.gz

Download URL featuretoggles-1.0.2.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
69a5fa818ea646a4fa18cd19e82cc242467fbcf31b189f9e4a5ea260220cf715
BLAKE2b-256 checksum
How to use checksums
0382ccab72117a6a38a6bdeccc30125d981b3110283653e7c5f05745ce19f6c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.5

Release files / featuretoggles-1.0.2-py3-none-any.whl

Download URL featuretoggles-1.0.2-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
624f6d2b13f3520027bef7323e0a3c76224821f7f78d4d69969f9db147e0d00a
BLAKE2b-256 checksum
How to use checksums
16fd046d8a16fd33c6f1d233c0ef183cd3ab194aceacb9a87a728d3229db201b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.5

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

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