Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Pausing an experiment #133

Open
jfilipe opened this issue Feb 27, 2018 · 1 comment
Open

Pausing an experiment #133

jfilipe opened this issue Feb 27, 2018 · 1 comment

Comments

@jfilipe
Copy link

jfilipe commented Feb 27, 2018

Just wanted to get your thoughts on how to pause a running experiment/namespace. For me, pausing would mean that if the primary_unit has already been exposed, subsequent calls would continue to return the same exposure. However if this is the first time we've seen this primary_unit, they would get the default experiment while we're paused.

This would need a database in order to record the primary_units allocation for a given experiment/namespace.

Here is some sample code to illustrate what I mean:

from planout.experiment import SimpleExperiment
from operator import itemgetter

class PauseableNamespace(SimpleNamespace):
  paused = False

  def get_segment(self):
    allocated_segment = super().get_segment()

    # this value can also be hashed to make persistence easier
    primary_unit = itemgetter(*self.primary_unit)(self.inputs))
 
    # assume we have a `find_by` method that will query our db
    recorded_segment = find_by(primary_unit=primary_unit, namespace=self, segment=allocated_segment)
 
    if recorded_segment is None and self.paused:
      # First time we've seen this `primary_unit`. Since namespace is paused ensure default experiment is assigned.
      return -1

    # assume we have a `create` method that will insert a record into our db
    # record allocation
    create(primary_unit=primary_unit, namespace=self, segment=allocated_segment)

    return allocated_segment

Then my concrete namespace classes would inherit from this PauseableNamespace class.

Thoughts?

@deaneckles
Copy link
Contributor

PlanOut is designed to have online, stateless assignments. Diverging from that can make things pretty complicates, especially in analysis, but you can certainly do something like that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants