Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: tools/variations/fieldtrial_to_struct.py

Issue 2319293006: Use Study and Experiment Terminology on the C++ Side For Fieldtrials (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import itertools 6 import itertools
7 import json 7 import json
8 import os.path 8 import os.path
9 import sys 9 import sys
10 import optparse 10 import optparse
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 iterates through all of the experiment_configs for |study_name| and picks out 54 iterates through all of the experiment_configs for |study_name| and picks out
55 the applicable experiments based off of the valid platforms. 55 the applicable experiments based off of the valid platforms.
56 """ 56 """
57 platform_experiment_lists = [ 57 platform_experiment_lists = [
58 config['experiments'] for config in experiment_configs 58 config['experiments'] for config in experiment_configs
59 if platform in config['platforms']] 59 if platform in config['platforms']]
60 platform_experiments = list(itertools.chain.from_iterable( 60 platform_experiments = list(itertools.chain.from_iterable(
61 platform_experiment_lists)) 61 platform_experiment_lists))
62 return { 62 return {
63 'name': study_name, 63 'name': study_name,
64 'groups': [_CreateExperiment(experiment) 64 'experiments': [_CreateExperiment(experiment)
65 for experiment in platform_experiments], 65 for experiment in platform_experiments],
66 } 66 }
67 67
68 def _GenerateTrials(config, platform): 68 def _GenerateTrials(config, platform):
69 for study_name in sorted(config.keys()): 69 for study_name in sorted(config.keys()):
70 study = _CreateTrial(study_name, config[study_name], platform) 70 study = _CreateTrial(study_name, config[study_name], platform)
71 # To avoid converting studies with empty groups (e.g. the study doesn't 71 # To avoid converting studies with empty experiments (e.g. the study doesn't
72 # apply to the target platform), this generator only yields studies that 72 # apply to the target platform), this generator only yields studies that
73 # have non-empty groups. 73 # have non-empty experiments.
74 if study['groups']: 74 if study['experiments']:
75 yield study 75 yield study
76 76
77 def _FieldTrialConfigToDescription(config, platform): 77 def _FieldTrialConfigToDescription(config, platform):
78 return { 78 return {
79 'elements': { 79 'elements': {
80 'kFieldTrialConfig': { 80 'kFieldTrialConfig': {
81 'trials': [study for study in _GenerateTrials(config, platform)] 81 'studies': [study for study in _GenerateTrials(config, platform)]
82 } 82 }
83 } 83 }
84 } 84 }
85 85
86 def main(arguments): 86 def main(arguments):
87 parser = optparse.OptionParser( 87 parser = optparse.OptionParser(
88 description='Generates a struct from a JSON description.', 88 description='Generates a struct from a JSON description.',
89 usage='usage: %prog [option] -s schema -p platform description') 89 usage='usage: %prog [option] -s schema -p platform description')
90 parser.add_option('-b', '--destbase', 90 parser.add_option('-b', '--destbase',
91 help='base directory of generated files.') 91 help='base directory of generated files.')
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 schema = _Load(opts.schema) 129 schema = _Load(opts.schema)
130 description = _LoadFieldTrialConfig(description_filename, opts.platform) 130 description = _LoadFieldTrialConfig(description_filename, opts.platform)
131 json_to_struct.GenerateStruct( 131 json_to_struct.GenerateStruct(
132 basepath, output_root, opts.namespace, schema, description, 132 basepath, output_root, opts.namespace, schema, description,
133 os.path.split(description_filename)[1], os.path.split(opts.schema)[1], 133 os.path.split(description_filename)[1], os.path.split(opts.schema)[1],
134 opts.year) 134 opts.year)
135 135
136 if __name__ == '__main__': 136 if __name__ == '__main__':
137 main(sys.argv[1:]) 137 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « chrome/common/variations/variations_util_unittest.cc ('k') | tools/variations/fieldtrial_to_struct_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698