Skip to content

Commit

Permalink
Tester: Only upload to Refazer when the fixed code has been changed
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhead committed Oct 25, 2016
1 parent 25d2451 commit a808bf3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions db/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ create table if not exists sessions (
);

create table if not exists queries (
id integer primary key,
session_id integer not null,
submission_id integer not null,
fix_suggested boolean not null,
Expand Down
35 changes: 25 additions & 10 deletions flaskr.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
logger.addHandler(handler)
handler.setFormatter(formatter)

# Silence default request logger except for errors, to keep the command line clean for the
# messages that we're logging for debugging purposes.
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)

# Configure the database endpoint
database_path = os.environ.get('FLASK_DATABASE_PATH', os.path.join(app.root_path, 'flaskr.db'))
app.config.update(dict(
Expand Down Expand Up @@ -740,16 +745,26 @@ def synthesize():
submission_id = request.form['submission_id']
code_before = request.form['code_before']
code_after = request.form['code_after']

thread_pool.submit(
upload_example,
REFAZER_ENDPOINT + "/ApplyFixFromExample", {
'CodeBefore': code_before,
'CodeAfter': code_after,
'SessionId': session_id,
'QuestionId': question_number,
'SubmissionId': submission_id,
})
fix_suggested = True if request.form['fix_suggested'] == 'true' else False
fix_used = True if request.form['fix_used'] == 'true' else False
fix_changed = True if request.form['fix_changed'] == 'true' else False

# If a fix was used unchanged, then we expect we won't find a very useful
# new transformation from this fix (it might be very similar to what
# the fix suggested for this submission). Only request Refazer
# to do new synthesis when the code has changed from the proposed fix.
if fix_suggested and fix_used and not fix_changed:
logger.info("Skipping call to Refazer. This fix is similar to the recommended fix.")
else:
thread_pool.submit(
upload_example,
REFAZER_ENDPOINT + "/ApplyFixFromExample", {
'CodeBefore': code_before,
'CodeAfter': code_after,
'SessionId': session_id,
'QuestionId': question_number,
'SubmissionId': submission_id,
})

return jsonify({
'success': True,
Expand Down
3 changes: 3 additions & 0 deletions templates/show_editors.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ <h3 class='submission_header'>Student error detected.</h3>
question_number: {{ question_number }},
code_before: originalCode,
code_after: debuggedCode,
fix_suggested: fixSuggested,
fix_used: fixUsed,
fix_changed: fixChanged,
});
});
});
Expand Down

0 comments on commit a808bf3

Please sign in to comment.