now += timedelta(hours=1)

    return exp_results


if __name__ == '__main__':

    # ############################################### Keys and Authentication #######################################
    gbq_key = os.environ.get('GOOGLE_APPLICATION_CREDENTIALS')

    directory = str(os.path.abspath(os.path.dirname(__file__)))
    # directory = os.getcwd()

    ############################################### Instantiating Popelines #######################################
    pope = popelines.popeline(dataset_id='optimizely',
                              service_key_file_loc=gbq_key,
                              directory='.',
                              verbose=False)

    # Optimizely parameters
    headers = {
        'Authorization':
        'Bearer 2:EWAWmaXb4TgtYVU2VvwoEF-9UbJxBahkiFh1633_Oc9nmju7iJis',
    }

    params = (('per_page', 100), )

    query = open(f'{directory}/existing_experiments.sql').read()
    results = pope.bq_query(query)

    # a little clean up before sending hourly calls
    all_exp = []
Exemplo n.º 2
0
import json
import requests
import popelines
import os
from datetime import datetime, timedelta
from main import fix_values, populating_vals, flatten, flatten_dupe_vals
from generate_original_with_timeseries import read_endpoint, generate_projects, generate_experiments

if __name__ == '__main__':

    directory = str(os.path.abspath(os.path.dirname(__file__)))

    pope = popelines.popeline(
        dataset_id='optimizely',
        service_key_file_loc=f'{directory}/../optimizely_svcacc.json',
        directory='.',
        verbose=False)

    headers = {
        'Authorization':
        'Bearer 2:EWAWmaXb4TgtYVU2VvwoEF-9UbJxBahkiFh1633_Oc9nmju7iJis',
    }

    experiment_endpoint = 'https://api.optimizely.com/v2/experiments'

    ######################### updating experiments #########################
    experiment_query = open(f'{directory}/existing_experiments.sql').read()
    existing_experiments = []
    for result in pope.bq_query(experiment_query):
        existing_experiments.append(
            (result[0], datetime.strftime(result[2], '%Y-%m-%dT%H:%M:%S.%fz')))