Пример #1
0
def test_clone_into_cfr_control(MOCK_CFR_DATA):
    cfr_remote = CFRRemoteSettings()
    cfr_remote.clone_to_cfr_control(MOCK_CFR_DATA)

    actual = cfr_remote._test_read_cfr_control()

    actual_ids = set([obj['id'] for obj in actual])
    expected_ids = set([obj['id'] for obj in MOCK_CFR_DATA])

    diff = actual_ids.difference(expected_ids)
    assert ('panel_local_testing' in diff and len(diff) == 1) or (len(diff)
                                                                  == 0)
Пример #2
0
def test_clone_into_cfr_experiment(MOCK_CFR_DATA):
    cfr_remote = CFRRemoteSettings()
    cfr_remote.clone_to_cfr_experiment(MOCK_CFR_DATA)

    actual = cfr_remote._test_read_cfr_experimental()

    actual_ids = set([obj['id'] for obj in actual])
    expected_ids = set([obj['id'] for obj in MOCK_CFR_DATA])

    diff = actual_ids.difference(expected_ids)

    # Check that we have targetting added
    assert 'targetting' in actual_ids
    diff.remove('targetting')

    assert ('panel_local_testing' in diff and len(diff) == 1) or (len(diff)
                                                                  == 0)
Пример #3
0
def main():
    # The DataprocFacade will manage cluster creation
    # and destruction once the context exits
    with DataprocFacade(settings.GCP_PROJECT_ID, settings.DATAPROC_CLUSTER,
                        settings.GCP_ZONE) as dataproc:
        # Upload the script from the cfretl.scripts directory

        # TODO: this should just pass in a filename - a cluster
        # is only going to run a single job anyway
        dataproc.upload_sparkjob(settings.GCS_BUCKET_NAME,
                                 settings.DATAPROC_SCRIPT)

        # TODO: should probably pass a token in here so that we
        # can verify that results were successfully computed
        dataproc.run_job(settings.GCS_BUCKET_NAME, settings.DATAPROC_SCRIPT)

        remote_settings = CFRRemoteSettings()
        remote_settings.create_user_in_test()

        # TODO: do something to test that we have results we're looking for
        # and transform the bq result table
        # into a final model
        model = load_mock_model()
        remote_settings.write_models(model)
Пример #4
0
"""
This script installs fixture test data into a kinto server
"""

from cfretl.remote_settings import CFRRemoteSettings
from cfretl.remote_settings import FEATURES_LIST
from cfretl.models import CFRModel
import random
from datetime import datetime
import time

random.seed(time.time())

remote_settings = CFRRemoteSettings()

version_code = int(datetime.utcnow().strftime("%Y%m%d%H%m%S"))

CFRS = remote_settings.debug_load_cfr()
CFR_ID_LIST = [r["id"] for r in CFRS]


def generate_cfr_cfgdata(version_code):
    """
    This function will need to be rewritten to parse the
    BQ output table and coerce it into values for RemoteSettings JSON
    blob
    """
    model = CFRModel()

    data = []
    for idx, cfr_id in enumerate(CFR_ID_LIST):
Пример #5
0
def test_update_weights(WEIGHT_VECTOR):
    cfr_remote = CFRRemoteSettings()
    assert cfr_remote.write_models(WEIGHT_VECTOR)

    actual = cfr_remote._test_read_models()
    assert actual == WEIGHT_VECTOR
Пример #6
0
def test_write_weights(WEIGHT_VECTOR):
    cfr_remote = CFRRemoteSettings()
    assert cfr_remote.write_models(WEIGHT_VECTOR)
    actual = cfr_remote._test_read_models()
    _compare_weights(WEIGHT_VECTOR, actual)
Пример #7
0
def MOCK_CFR_DATA():
    cfr_remote = CFRRemoteSettings()
    return cfr_remote.debug_read_cfr()