Giter VIP home page Giter VIP logo

Comments (1)

prophile avatar prophile commented on August 15, 2024

I used this script to do this in production(!):

import random
import itertools
import jacquard.config

from jacquard.buckets import Bucket, NUM_BUCKETS
from jacquard.experiments.constraints import Constraints

EXPERIMENT_NAME = '<redacted>'
REMOVING_BRANCH = '<redacted>'
EXPERIMENT_CONSTRAINTS = Constraints()

REDISTRIBUTE_TO = (
    {
        'branch': '<redacted>',
        'settings': {'<redacted>': 2},
    },
    {
        'branch': 'control',
        'settings': {'<redacted>': 1},
    },
)

config = jacquard.config.load_config('/etc/jacquard/config.cfg')

redistributions = itertools.cycle(REDISTRIBUTE_TO)

removal_key = [EXPERIMENT_NAME, REMOVING_BRANCH]

with config.storage.transaction() as store:
    bucket_order = list(range(NUM_BUCKETS))
    # Permute buckets to avoid bias
    random.shuffle(bucket_order)

    for bucket_number in bucket_order:
        store_key = 'buckets/%s' % bucket_number
        bucket = Bucket.from_json(
            store.get(store_key, '{}'),
        )

        if not bucket.covers(removal_key):
            continue

        print("Modifying bucket %s" % bucket_number)

        bucket.remove(removal_key)

        new_settings = next(redistributions)
        bucket.add(
            [EXPERIMENT_NAME, new_settings['branch']],
            new_settings['settings'],
            EXPERIMENT_CONSTRAINTS,
        )

        store[store_key] = bucket.to_json()

from jacquard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.