Пример #1
0
    def participate_in_doppleganger_on_new_instance(self):
        """Simulate participating in a new experiment on a "new" instance.
        
        This test works by loading memcache with a copy of all gae/bingo
        experiments before the doppleganger test exists.

        After the doppleganger test has been created once, all future calls to
        this function simulate being run on machines that haven't yet cleared
        their instance cache and loaded the newly created doppleganger yet. We
        do this by replacing the instance cache'd state of BingoCache with the
        deep copy that we made before doppleganger was created.

        A correctly functioning test will still only create one copy of the
        experiment even though multiple clients attempted to create a new
        experiment.
        """
        # First, make a deep copy of the current state of bingo's experiments
        bingo_clone = memcache.get("bingo_clone")

        if not bingo_clone:
            # Set the clone by copying the current bingo cache state
            memcache.set("bingo_clone", copy.deepcopy(BingoCache.get()))
        else:
            # Set the current bingo cache state to the cloned state
            gae_bingo.instance_cache.set(BingoCache.CACHE_KEY, bingo_clone)

        return ab_test("doppleganger")
Пример #2
0
 def count_participants_in(self):
     return sum(
         map(
             lambda alternative: alternative.latest_participants_count(),
             BingoCache.get().get_alternatives(self.request.get("experiment_name")),
         )
     )
Пример #3
0
    def get_experiments(self, archives=False):
        if archives:
            bingo_cache = BingoCache.load_from_datastore(archives=True)
        else:
            bingo_cache = BingoCache.get()

        return str(bingo_cache.experiments)
Пример #4
0
 def count_participants_in(self):
     return reduce(
         lambda a, b: a + b,
         map(
             lambda alternative: alternative.participants,
             BingoCache.get().get_alternatives(
                 self.request.get("experiment_name"))))
Пример #5
0
    def count_conversions_in(self):
        dict_conversions = {}

        for alternative in BingoCache.get().get_alternatives(self.request.get("experiment_name")):
            dict_conversions[alternative.content] = alternative.latest_conversions_count()

        return dict_conversions
Пример #6
0
    def flush_hippo_counts_memcache(self):
        experiments, alternative_lists = BingoCache.get().experiments_and_alternatives_from_canonical_name("hippos")

        for experiment in experiments:
            experiment.reset_counters()

        return True
Пример #7
0
    def delete_all_experiments(self):
        bingo_cache = BingoCache.get()
        
        for experiment_name in bingo_cache.experiments.keys():
            bingo_cache.delete_experiment_and_alternatives(bingo_cache.get_experiment(experiment_name))

        return len(bingo_cache.experiments)
Пример #8
0
    def flush_hippo_counts_memcache(self):
        experiments, alternative_lists = BingoCache.get().experiments_and_alternatives_from_canonical_name("hippos")

        for alternatives in alternative_lists:
            for alternative in alternatives:
                memcache.delete("%s:conversions" % alternative.key_for_self())
                memcache.delete("%s:participants" % alternative.key_for_self())

        return True
Пример #9
0
    def delete_all_experiments(self):
        bingo_cache = BingoCache.get()
        for experiment_name in bingo_cache.experiments.keys():
            bingo_cache.delete_experiment_and_alternatives(bingo_cache.get_experiment(experiment_name))

        bingo_cache_archives = BingoCache.load_from_datastore(archives=True)
        for experiment_name in bingo_cache_archives.experiments.keys():
            bingo_cache_archives.delete_experiment_and_alternatives(
                bingo_cache_archives.get_experiment(experiment_name)
            )

        return len(bingo_cache.experiments) + len(bingo_cache_archives.experiments)
Пример #10
0
    def delete_all_experiments(self):
        bingo_cache = BingoCache.get()
        for experiment_name in bingo_cache.experiments.keys():
            bingo_cache.delete_experiment_and_alternatives(
                    bingo_cache.get_experiment(experiment_name))

        bingo_cache_archives = BingoCache.load_from_datastore(archives=True)
        for experiment_name in bingo_cache_archives.experiments.keys():
            bingo_cache_archives.delete_experiment_and_alternatives(
                    bingo_cache_archives.get_experiment(experiment_name))

        return (len(bingo_cache.experiments) +
                len(bingo_cache_archives.experiments))
Пример #11
0
 def count_experiments(self):
     return len(BingoCache.get().experiments)
Пример #12
0
 def count_participants_in(self):
     return sum(
             map(lambda alternative: alternative.latest_participants_count(),
                 BingoCache.get().get_alternatives(self.request.get("experiment_name"))
                 )
             )
Пример #13
0
 def get_experiments(self):
     return str(BingoCache.get().experiments)
Пример #14
0
 def end_and_choose(self):
     with ExperimentController() as dummy:
         bingo_cache = BingoCache.get()
         choose_alternative(
                 self.request.get("canonical_name"),
                 int(self.request.get("alternative_number")))
Пример #15
0
 def try_this_bad(self):
     cache = BingoCache.get()
     return len(cache.get_experiment_names_by_canonical_name("hippos"))
Пример #16
0
 def end_and_choose(self):
     bingo_cache = BingoCache.get()
     choose_alternative(self.request.get("canonical_name"), int(self.request.get("alternative_number")))
Пример #17
0
 def persist(self):
     BingoCache.get().persist_to_datastore()
     BingoIdentityCache.persist_buckets_to_datastore()
     return True
Пример #18
0
 def get_experiments(self):
     return str(BingoCache.get().experiments)
Пример #19
0
 def archive_monkeys(self):
     bingo_cache = BingoCache.get()
     bingo_cache.archive_experiment_and_alternatives(bingo_cache.get_experiment("monkeys"))
     return True
Пример #20
0
 def count_participants_in(self):
     return reduce(lambda a, b: a + b, 
             map(lambda alternative: alternative.participants, 
                 BingoCache.get().get_alternatives(self.request.get("experiment_name"))
                 )
             )