Hypertune
  • Introduction
  • Getting Started
    • Set up Hypertune
    • Next.js (App Router) quickstart
    • Next.js (Pages Router) quickstart
    • React quickstart
    • Remix quickstart
    • Gatsby quickstart
    • Vue quickstart
    • Nuxt quickstart
    • Node.js quickstart
    • React Native quickstart
    • JavaScript quickstart
    • Python quickstart
    • Rust quickstart
    • Go quickstart
    • Web quickstart
    • GraphQL quickstart
  • Example apps
    • Next.js and Vercel example app
  • Concepts
    • Architecture
    • Project
    • Schema
    • Flag lifecycle
    • Logic
    • Variables
    • Splits
    • A/B tests
    • Staged rollouts
    • Multivariate tests
    • Machine learning loops
    • Events
    • Funnels
    • Hypertune Edge
    • Reduction
    • SDKs
    • GraphQL API
    • Git-style version control
    • App configuration
  • Use Cases
    • Feature flags and A/B testing
    • Landing page optimization
    • In-app content management
    • Pricing plan management
    • Permissions, rules and limits
    • Optimizing magic numbers
    • Backend configuration
    • Product analytics
  • Integrations
    • Vercel Edge Config integration
    • Google Analytics integration
    • Segment integration
    • Webhooks
      • Creating webhooks
      • Handling webhooks
  • SDK Reference
    • Installation
    • Type-safe client generation
    • Initialization
    • Build-time logic snapshot
    • Hard-coded fallbacks
    • Local-only, offline mode
    • Hydrate from your own server
    • Wait for server initialization
    • Provide targeting attributes
    • Local, synchronous evaluation
    • Remote logging
    • Getting flag updates
    • Serverless environments
    • Vercel Edge Config
    • Custom logging
    • Shutting down
Powered by GitBook
On this page
  • 1. Install hypertune-sdk
  • 2. Install the Hypertune CLI
  • 3. Generate the client
  • 4. Use the client
  • That's it
  1. Getting Started

Python quickstart

PreviousJavaScript quickstartNextRust quickstart

Last updated 2 months ago

1. Install hypertune-sdk

Once you have a Python application ready, install Hypertune's Python SDK:

pip install hypertune-sdk

2. Install the Hypertune CLI

Run the following command to install the CLI

curl -fsSL https://app.hypertune.com/install-cli.sh | sh

Alternatively, you can download the Hypertune CLI for your system:

Then:

  • Put it somewhere accessible via your PATH

  • Add execute permissions to it with chmod +x hypertune

  • Right-click to open it

3. Generate the client

Generate a type-safe client to access your flags by running:

hypertune generate --language python --output-file-dir generated --token <token> 

Replace <token> with your main project token which you can find in the Settings tab of your project.

4. Use the client

import generated.hypertune as hypertune

def main():
    root_node = hypertune.create_source().root({
        "context": {
            "environment": "development",
            "user": {
                "id": "test_id",
                "name": "Test",
                "email": "hi@test.com",
            }
        }
    })
    root_node.wait_for_initialization()
    
    example_flag = root_node.exampleFlag().get(False)


if __name__ == "__main__":
    main()

That's it

Now you can update the logic for exampleFlag from the Hypertune UI without updating your code or waiting for a new build, deployment, app release or service restart.

To add a new flag, create it in the Hypertune UI then regenerate the client.

Mac (x86_64)
Mac M1 / M2 (aarch64)
Linux (x86_64)
Windows (x86_64)