The following are prerequisites for installing the Python SDK:
A Rollout account. See Signup Page to create an account.
An Application created in the Rollout dashboard.
- The first time you log into your account, click the Create New App button to create a new app.
- An environment key.
- Get the key from App Settings > Environment > Key
$ pip install rox
# Import Rollout SDK from rox.server.rox_server import Rox from rox.server.flags.rox_flag import RoxFlag from rox.server.flags.rox_variant import RoxVariant # Create Roxflags in the Flags container class class Flags: def __init__(self): #Define the feature flags self.enableTutorial = RoxFlag(False) self.titleColors = RoxVariant('White', ['White', 'Blue', 'Green', 'Yellow']) flags = Flags() # Register the flags container with Rollout Rox.register("", flags) # Setup the Rollout environment key cancel_event = Rox.setup("<ROLLOUT-ENV-KEY>").result(); # Boolean flag example print('enableTutorial is %s' % flags.enableTutorial.is_enabled()) # Multivariate flag example print('color is %s' % flags.titleColors.get_value())
Container class registration and environment key setup
- You can not call Rox.setup() twice in the same runtime.
Running the application
The Flag name is automatically added to the Rollout dashboard after running the application.
After creating feature flags and running your feature code, you can find your flags in the Rollout dashboard.
To find your flags in the Rollout dashboard:
Find your app in the Rollout dashboard
To switch between apps, click on the app name in the top-left corner of the screen and select the app you want from the pulldown.
Click on Flags on the left side of the navigation panel.
Confirm that your flag is listed in the flag view.
- Go to Rollout's dashboard.
- Click on Experiments on the left panel.
- Click the Create Experiment button to create a new experiment.
- In the New Experiment window:
- Find the Flag name from the menu, choose it.
- Click the Set Audience button to continue. The Experiment Details view appears.
- Select either True, False, Split or Scheduled. Split allows you to select the percentage of the target group that you want to deploy. Scheduled allows you to schedule a deployment date.
- Click Update Audience.
- You can not delete the default condition.
- You can click the Reset link to go back to the state from before you started making changes. Reset only appears when you've made saved modifications.
See Audience for more detailed information.
Updated 19 days ago