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

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

Issue 2861493002: Revert of Fix perfbotnot feature param setting from trial testing config.
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | tools/variations/fieldtrial_util_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import sys 6 import sys
7 7
8 import fieldtrial_to_struct 8 import fieldtrial_to_struct
9 9
10 def _hex(ch): 10 def _hex(ch):
(...skipping 14 matching lines...) Expand all
25 seen = set() 25 seen = set()
26 duplicates = set() 26 duplicates = set()
27 for entry in entries: 27 for entry in entries:
28 if entry in seen: 28 if entry in seen:
29 duplicates.add(entry) 29 duplicates.add(entry)
30 else: 30 else:
31 seen.add(entry) 31 seen.add(entry)
32 return duplicates 32 return duplicates
33 33
34 def _CheckForDuplicateFeatures(enable_features, disable_features): 34 def _CheckForDuplicateFeatures(enable_features, disable_features):
35 enable_features = [f.split('<')[0] for f in enable_features]
36 enable_features_set = set(enable_features) 35 enable_features_set = set(enable_features)
37 if len(enable_features_set) != len(enable_features): 36 if len(enable_features_set) != len(enable_features):
38 raise Exception('Duplicate feature(s) in enable_features: ' + 37 raise Exception('Duplicate feature(s) in enable_features: ' +
39 ', '.join(_FindDuplicates(enable_features))) 38 ', '.join(_FindDuplicates(enable_features)))
40
41 disable_features = [f.split('<')[0] for f in disable_features]
42 disable_features_set = set(disable_features) 39 disable_features_set = set(disable_features)
43 if len(disable_features_set) != len(disable_features): 40 if len(disable_features_set) != len(disable_features):
44 raise Exception('Duplicate feature(s) in disable_features: ' + 41 raise Exception('Duplicate feature(s) in disable_features: ' +
45 ', '.join(_FindDuplicates(disable_features))) 42 ', '.join(_FindDuplicates(disable_features)))
46
47 features_in_both = enable_features_set.intersection(disable_features_set) 43 features_in_both = enable_features_set.intersection(disable_features_set)
48 if len(features_in_both) > 0: 44 if len(features_in_both) > 0:
49 raise Exception('Conflicting features set as both enabled and disabled: ' + 45 raise Exception('Conflicting features set as both enabled and disabled: ' +
50 ', '.join(features_in_both)) 46 ', '.join(features_in_both))
51 47
52 # Generate a list of command-line switches to enable field trials for the 48 # Generate a list of command-line switches to enable field trials for the
53 # provided config_path and platform. 49 # provided config_path and platform.
54 def GenerateArgs(config_path, platform): 50 def GenerateArgs(config_path, platform):
55 try: 51 try:
56 with open(config_path, 'r') as config_file: 52 with open(config_path, 'r') as config_file:
(...skipping 19 matching lines...) Expand all
76 if 'params' in experiment: 72 if 'params' in experiment:
77 for param in experiment['params']: 73 for param in experiment['params']:
78 param_list.append(param['key']) 74 param_list.append(param['key'])
79 param_list.append(param['value']) 75 param_list.append(param['value'])
80 if len(param_list): 76 if len(param_list):
81 # Escape the variables for the command-line. 77 # Escape the variables for the command-line.
82 selected_study = [_escape(x) for x in selected_study] 78 selected_study = [_escape(x) for x in selected_study]
83 param_list = [_escape(x) for x in param_list] 79 param_list = [_escape(x) for x in param_list]
84 param = '%s:%s' % ('.'.join(selected_study), '/'.join(param_list)) 80 param = '%s:%s' % ('.'.join(selected_study), '/'.join(param_list))
85 params.append(param) 81 params.append(param)
86 for feature in experiment.get('enable_features', []): 82 if 'enable_features' in experiment:
87 enable_features.append(feature + '<' + study_name) 83 enable_features.extend(experiment['enable_features'])
88 for feature in experiment.get('disable_features', []): 84 if 'disable_features' in experiment:
89 disable_features.append(feature + '<' + study_name) 85 disable_features.extend(experiment['disable_features'])
90 86
91 if not len(studies): 87 if not len(studies):
92 return [] 88 return []
93 _CheckForDuplicateFeatures(enable_features, disable_features) 89 _CheckForDuplicateFeatures(enable_features, disable_features)
94 args = ['--force-fieldtrials=%s' % '/'.join(studies)] 90 args = ['--force-fieldtrials=%s' % '/'.join(studies)]
95 if len(params): 91 if len(params):
96 args.append('--force-fieldtrial-params=%s' % ','.join(params)) 92 args.append('--force-fieldtrial-params=%s' % ','.join(params))
97 if len(enable_features): 93 if len(enable_features):
98 args.append('--enable-features="%s"' % ','.join(enable_features)) 94 args.append('--enable-features=%s' % ','.join(enable_features))
99 if len(disable_features): 95 if len(disable_features):
100 args.append('--disable-features="%s"' % ','.join(disable_features)) 96 args.append('--disable-features=%s' % ','.join(disable_features))
101 return args 97 return args
102 98
103 def main(): 99 def main():
104 if len(sys.argv) < 3: 100 if len(sys.argv) < 3:
105 print 'Usage: fieldtrial_util.py [config_path] [platform]' 101 print 'Usage: fieldtrial_util.py [config_path] [platform]'
106 exit(-1) 102 exit(-1)
107 103
108 supported_platforms = ['android', 'chromeos', 'ios', 'linux', 'mac', 'win'] 104 supported_platforms = ['android', 'chromeos', 'ios', 'linux', 'mac', 'win']
109 if sys.argv[2] not in supported_platforms: 105 if sys.argv[2] not in supported_platforms:
110 print ('\'%s\' is an unknown platform. Supported platforms: %s' % 106 print ('\'%s\' is an unknown platform. Supported platforms: %s' %
111 (sys.argv[2], supported_platforms)) 107 (sys.argv[2], supported_platforms))
112 exit(-1) 108 exit(-1)
113 109
114 print GenerateArgs(sys.argv[1], sys.argv[2]) 110 print GenerateArgs(sys.argv[1], sys.argv[2])
115 111
116 if __name__ == '__main__': 112 if __name__ == '__main__':
117 main() 113 main()
OLDNEW
« no previous file with comments | « no previous file | tools/variations/fieldtrial_util_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698