Skip to content
/ planout Public

Food52 port of Facebook's Planout for online field experimentation.

License

Notifications You must be signed in to change notification settings

food52/planout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PlanOut

Overview

This is a project to attempt the completion of a Ruby port of Facebook's PlanOut experiment framework. There was a rough implementation but hadn't been updated in a while and Food52 has decided it would be beneficial to take this port a little further.

This is a line-by-line port and should produce identical results to the Python reference design. Additional features ported by Food52 are:

  • Namespace Support
  • Additional Testing
  • Breakout of gem from planout to plan_out

Initial Ruby Port

Much credit is due to users @mohnish, @eytan, and @felixonmars for a lot of work on the initial port.

Installation

Add this line to your application's Gemfile:

gem 'planout'

And then execute:

$ bundle

Or install it yourself as:

$ gem install planout

How it works

This defines a simple experiment that randomly assigns three variables, foo, bar, and baz. foo and baz use userid as input, while bar uses a pair, namely userid combined with the value of foo from the prior step.

module PlanOut
  class VotingExperiment < SimpleExperiment
    # Experiment#assign takes params and an input array
    def assign(params, **inputs)
      userid = inputs[:userid]

      params[:button_color] = UniformChoice.new({
        choices: ['ff0000', '#00ff00'],
        unit: userid
      })

      params[:button_text] = UniformChoice.new({
        choices: ["I'm voting", "I'm a voter"],
        unit: userid,
        salt:'x'
      })
    end
  end
end

Then, we can examine the assignments produced for a few input userids. Note that since exposure logging is enabled by default, all of the experiments' inputs, configuration information, timestamp, and parameter assignments are pooped out via the Logger class.

my_exp = PlanOut::VotingExperiment.new(userid: 14)
my_button_color = my_exp.get(:button_color)
button_text = my_exp.get(:button_text)
puts "button color is #{my_button_color} and button text is #{button_text}."

The output of the Ruby script looks something like this:

logged data: {"name":"PlanOut::VotingExperiment","time":1404944726,"salt":"PlanOut::VotingExperiment","inputs":{"userid":14},"params":{"button_color":"ff0000","button_text":"I'm a voter"},"event":"exposure"}

button color is ff0000 and button text is I'm a voter.

Examples

For examples please refer to the examples directory.

Running the tests

Make sure you're in the ruby implementation directory of PlanOut and run

rake or rake test

to run the entire test suite.

If you wish to run a specific test, run

rake test TEST=test/testname.rb or even better ruby test/testname.rb

About

Food52 port of Facebook's Planout for online field experimentation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages