Simon Sorg commited on
Commit
24e19ba
·
1 Parent(s): cc82312

fix: execute single query

Browse files
Files changed (1) hide show
  1. valid_efficiency_score.py +6 -8
valid_efficiency_score.py CHANGED
@@ -42,8 +42,8 @@ Args:
42
  should be a string with tokens separated by spaces.
43
  references: list of reference for each prediction. Each
44
  reference should be a string with tokens separated by spaces.
45
- execute: function that takes a list of sql queries and returns a list of results, one for each query.
46
- Results should be a list of tuples, each tuple containing the values of a row.
47
  filter_func: function that takes a string and returns a boolean.
48
  If True, the string is kept, otherwise it is dropped.
49
  num_executions: number of times to execute each sql query to get the execution time.
@@ -107,21 +107,19 @@ class ValidEfficiencyScore(evaluate.Metric):
107
  elif filter_func(reference):
108
  passing_reference_only += 1
109
 
110
- # Execute ground truth sql queries to get the ground truth results and the time it takes to execute them
111
- ground_results = execute(filtered_references)
112
  reference_times = np.zeros(num_executions)
113
  for i in range(num_executions):
114
  start_time = time()
115
- execute(filtered_references)
116
  end_time = time()
117
  reference_times[i] = end_time - start_time
118
 
119
- # Execute predicted sql queries to get the predicted results and the time it takes to execute them
120
- predicted_results = execute(filtered_predictions)
121
  prediction_times = np.zeros(num_executions)
122
  for i in range(num_executions):
123
  start_time = time()
124
- execute(filtered_predictions)
125
  end_time = time()
126
  prediction_times[i] = end_time - start_time
127
 
 
42
  should be a string with tokens separated by spaces.
43
  references: list of reference for each prediction. Each
44
  reference should be a string with tokens separated by spaces.
45
+ execute: function that takes a sql query and returns a result.
46
+ The result should be a list of tuples, each tuple containing the values of a row.
47
  filter_func: function that takes a string and returns a boolean.
48
  If True, the string is kept, otherwise it is dropped.
49
  num_executions: number of times to execute each sql query to get the execution time.
 
107
  elif filter_func(reference):
108
  passing_reference_only += 1
109
 
110
+ # Execute ground truth sql queries to get the time it takes to execute them
 
111
  reference_times = np.zeros(num_executions)
112
  for i in range(num_executions):
113
  start_time = time()
114
+ [execute(i) for i in filtered_references]
115
  end_time = time()
116
  reference_times[i] = end_time - start_time
117
 
118
+ # Execute predicted sql queries to get the time it takes to execute them
 
119
  prediction_times = np.zeros(num_executions)
120
  for i in range(num_executions):
121
  start_time = time()
122
+ [execute(i) for i in filtered_predictions]
123
  end_time = time()
124
  prediction_times[i] = end_time - start_time
125