|
21 | 21 | from lib.db import DB
|
22 | 22 | from lib.global_config import GlobalConfig
|
23 | 23 |
|
| 24 | +def create_and_replace_tmp_usage_scenario(folder, placeholder, content): |
| 25 | + with open(f"templates/{folder}/usage_scenario.yml", mode='r', encoding='utf-8') as f: |
| 26 | + usage_scenario = f.read() |
| 27 | + data = usage_scenario.replace(placeholder, content) |
| 28 | + usage_scenario_tmp = f"templates/{folder}/usage_scenario.yml.tmp" |
| 29 | + with open(usage_scenario_tmp, mode='w+', encoding='utf-8') as f: |
| 30 | + f.write(data) |
| 31 | + |
| 32 | + return usage_scenario_tmp |
| 33 | + |
24 | 34 | if __name__ == '__main__':
|
25 | 35 | import argparse
|
26 | 36 |
|
|
74 | 84 | error_helpers.log_error('--branch or --filename are not allowed in website mode. Please remove or use run mode with a repository')
|
75 | 85 | sys.exit(1)
|
76 | 86 |
|
| 87 | + args.filename = create_and_replace_tmp_usage_scenario('website', '__GMT_PLACEHOLDER_WEBSITE__', args.page) |
77 | 88 | args.uri = GMT_ROOT_DIR
|
78 |
| - with open('templates/website/usage_scenario.yml', mode='r', encoding='utf-8') as f: |
79 |
| - usage_scenario = f.read() |
80 |
| - usage_scenario = usage_scenario.replace('__GMT_PLACEHOLDER_WEBSITE__', args.page) |
81 |
| - with open('templates/website/usage_scenario.yml.tmp', mode='w+', encoding='utf-8') as f: |
82 |
| - f.write(usage_scenario) |
83 |
| - args.filename = 'templates/website/usage_scenario.yml.tmp' |
84 | 89 | run_type = 'folder'
|
85 | 90 | commit_hash_folder = 'templates/website/'
|
86 | 91 |
|
|
95 | 100 | error_helpers.log_error('--branch or --filename are not allowed in website mode. Please remove or use run mode with a repository')
|
96 | 101 | sys.exit(1)
|
97 | 102 |
|
| 103 | + args.filename = create_and_replace_tmp_usage_scenario('ai', '__GMT_PLACEHOLDER_PROMPT__', args.prompt) |
98 | 104 | args.uri = GMT_ROOT_DIR
|
99 |
| - args.filename = 'templates/ai/usage_scenario.yml' |
100 | 105 | run_type = 'folder'
|
101 | 106 | commit_hash_folder = 'templates/ai/'
|
102 | 107 |
|
|
187 | 192 |
|
188 | 193 |
|
189 | 194 | if args.print_phase_stats:
|
190 |
| - data = DB().fetch_all('SELECT metric, detail_name, value, type, unit FROM phase_stats WHERE run_id = %s and phase LIKE %s ', params=(runner._run_id, f"%{args.print_phase_stats}")) |
| 195 | + phase_stats = DB().fetch_all('SELECT metric, detail_name, value, type, unit FROM phase_stats WHERE run_id = %s and phase LIKE %s ', params=(runner._run_id, f"%{args.print_phase_stats}")) |
191 | 196 | print(f"Data for phase {args.print_phase_stats}")
|
192 |
| - for el in data: |
| 197 | + for el in phase_stats: |
193 | 198 | print(el)
|
194 | 199 | print('')
|
195 | 200 |
|
|
0 commit comments