summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-10-15 15:47:47 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-10-15 15:47:47 +0200
commitca8dcfdf819dae2aed6c864a3a11f1e30c632e96 (patch)
treec5dbc06099c417eac2422d9ebd7bfc9ada74e8b8 /monkey
parentcbc096f9cb44a7d26b4fa01a40dbba594ab339ca (diff)
Store identifiers instead of IDs in Problem model
Diffstat (limited to 'monkey')
-rw-r--r--monkey/edits.py4
-rwxr-xr-xmonkey/test.py25
2 files changed, 14 insertions, 15 deletions
diff --git a/monkey/edits.py b/monkey/edits.py
index 8412f8a..5d07bfd 100644
--- a/monkey/edits.py
+++ b/monkey/edits.py
@@ -257,10 +257,10 @@ if __name__ == '__main__':
solutions = Solution.filter(problem_id=pid, done=True)
traces = [s.trace for s in solutions if s.codeq_user_id not in ignored_users]
if not traces:
- print('No traces for {}'.format(problem.name))
+ print('No traces for {}'.format(problem.identifier))
continue
- print('Analyzing traces for {}… '.format(problem.name), end='', flush=True)
+ print('Analyzing traces for {}… '.format(problem.identifier), end='', flush=True)
try:
edits[pid], submissions[pid], queries[pid], names[pid] = get_edits_from_traces(traces)
print('{} edits, {} submissions, {} queries, {} names'.format(
diff --git a/monkey/test.py b/monkey/test.py
index 9936cdc..03f3571 100755
--- a/monkey/test.py
+++ b/monkey/test.py
@@ -18,30 +18,29 @@ from .util import indent
if len(sys.argv) < 2:
print('usage: ' + sys.argv[0] + ' <pid>')
sys.exit(1)
-pid = int(sys.argv[1])
-language, problem_group, problem = Problem.get_identifier(pid)
+problem = Problem.get(id=sys.argv[1])
-solved_problems = [p for p in CodeqUser.solved_problems(1, language)
- if p != (problem_group, problem)]
-other_solutions = server.problems.solutions_for_problems(language, solved_problems)
-problem_module = server.problems.load_problem(language, problem_group, problem, 'common')
-name = server.problems.load_problem(language, problem_group, problem, 'en').name
+solved_problems = [p for p in CodeqUser.solved_problems(1, problem.language)
+ if p != (problem.group, problem.identifier)]
+other_solutions = server.problems.solutions_for_problems(problem.language, solved_problems)
+problem_module = server.problems.load_problem(problem.language, problem.group, problem.identifier, 'common')
+name = server.problems.load_problem(problem.language, problem.group, problem.identifier, 'en').name
# Testing function.
def test(code):
correct, hints = problem_module.test(code, solved_problems)
return correct
-traces = [s.trace for s in Solution.filter(problem_id=pid)]
+traces = [s.trace for s in Solution.filter(problem_id=problem.id)]
# Load hint database stored in edits.pickle.
edits, submissions, queries, names = pickle.load(open('edits.pickle', 'rb'))
-edits, submissions, queries, names = edits[pid], submissions[pid], queries[pid], names[pid]
+edits, submissions, queries, names = edits[problem.id], submissions[problem.id], queries[problem.id], names[problem.id]
# Load current status (programs for which a hint was found).
try:
- done = pickle.load(open('status-'+str(problem.pk)+'.pickle', 'rb'))
+ done = pickle.load(open('status-'+str(problem.id)+'.pickle', 'rb'))
except:
done = []
@@ -106,7 +105,7 @@ elif sys.argv[2] == 'test':
print_hint(program, solution, steps, fix_time, n_tested)
print()
- pickle.dump(done, open('status-'+str(problem.pk)+'.pickle', 'wb'))
+ pickle.dump(done, open('status-'+str(problem.id)+'.pickle', 'wb'))
print('Found hints for ' + str(len(done)) + ' of ' + str(len(incorrect)) + ' incorrect programs')
@@ -115,7 +114,7 @@ elif sys.argv[2] == 'info':
# With no additional arguments, print some stats.
if len(sys.argv) == 3:
print('Problem {} ({}): {} edits and {} unique submissions in {} traces'.format(
- pid, colored(name, 'yellow'),
+ problem.id, colored(name, 'yellow'),
colored(str(len(edits)), 'yellow'),
colored(str(len(submissions)), 'yellow'),
colored(str(len(traces)), 'yellow')))
@@ -146,7 +145,7 @@ elif sys.argv[2] == 'info':
# Print the edit graph in graphviz dot syntax.
elif sys.argv[2] == 'graph' and len(sys.argv) == 4:
uid = int(sys.argv[3])
- solution = Solution.get(problem_id=pid, codeq_user_id=uid)
+ solution = Solution.get(problem_id=problem.id, codeq_user_id=uid)
nodes, submissions, queries = trace_graph(solution.trace)