Permalink
Browse files

Run lichen plagiarism as submitty daemon job and some interface chang…

…es (#2423)

* add rerun plagiarism button

* plagiarism interface changes 1

* plagiarism interface changes 2

* plagiarism interface changes 3

* plagiarism interface changes 4

* add script which will run lichen plagiarism

* lichen run by submitty daemon

* modified plagiarism provided code path

* empty provided code for gradeable if edit configuration to no provided code

* user exist check fix

* lichen run by daemon 2

* add delete plagiarism result job

* add Trash Can functionality

* add delete plagiarism form and resolved bugs

* update lichen version
  • Loading branch information...
tushargr authored and bmcutler committed Jul 27, 2018
1 parent 0c07076 commit fe7128093e69b809e53b93ae97c33dbee8c14612
@@ -68,7 +68,7 @@ chmod 550 ${SUBMITTY_INSTALL_DIR}/sbin/authentication.py
chmod 555 ${SUBMITTY_INSTALL_DIR}/sbin/killall.py

# DAEMON_USER only things
array=( build_config_upload.py submitty_autograding_shipper.py submitty_autograding_worker.py submitty_daemon_jobs autograder )
array=( build_config_upload.py run_lichen_plagiarism.py submitty_autograding_shipper.py submitty_autograding_worker.py submitty_daemon_jobs autograder )
for i in "${array[@]}"; do
chown -R root:"${DAEMON_GROUP}" ${SUBMITTY_INSTALL_DIR}/sbin/${i}
chmod -R 750 ${SUBMITTY_INSTALL_DIR}/sbin/${i}
@@ -26,7 +26,7 @@ SUBMITTY_INSTALL_DIR=/usr/local/submitty
# dependencies between versions.

min_AnalysisTools_version=v.18.06.00
min_Lichen_version=v.18.07.00
min_Lichen_version=v.18.07.01
min_RainbowGrades_version=v.18.07.00
min_Tutorial_version=v.18.06.00

@@ -0,0 +1,81 @@
#!/usr/bin/env python3
#
# This script is run by a cron job as the DAEMON_USER
#
# Runs lichen plagiarism detector for saved configuration
#

import os
import sys
import pwd
import time
import subprocess
from submitty_utils import glob
import json


# ------------------------------------------------------------------------
def run_lichen_plagiarism(data):
semester = data["semester"]
course = data["course"]
gradeable = data["gradeable"]
language = data["language"]
window = data["sequence_length"]
threshold = data["threshold"]
regrex = None
instructor_provided_code_path = None
prior_term_gradeables = None
ignore_submissions = None

# construct the command line agruments
if data["file_option"] == "matching_regrex":
regrex = data["regrex"]

if data["instructor_provided_code"]:
instructor_provided_code_path = data["instructor_provided_code_path"]

if len(data["prev_term_gradeables"]) != 0:
prior_term_gradeables = []
for prior_term_gradeable in data["prev_term_gradeables"]:
prior_term_gradeables.append(prior_term_gradeable)

if len(data["ignore_submissions"]) != 0:
ignore_submissions = []
for submission in data["ignore_submissions"]:
ignore_submissions.append(submission)

subprocess.call(['/usr/local/submitty/Lichen/bin/concatenate_all.py', semester, course, gradeable ])
subprocess.call(['/usr/local/submitty/Lichen/bin/tokenize_all.py', semester, course, gradeable, '--{}'.format(language) ])
subprocess.call(['/usr/local/submitty/Lichen/bin/hash_all.py', semester, course, gradeable, '--window', window, '--{}'.format(language) ])
subprocess.call(['/usr/local/submitty/Lichen/bin/compare_hashes.out', semester, course, gradeable, '--window', window ])


# ------------------------------------------------------------------------
# MAIN LOOP

# ------------------------------------------------------------------------
# this script is intended to be run only from the cron job of DAEMON_USER
def main():
username = pwd.getpwuid(os.getuid()).pw_name
if username != "submitty_daemon":
raise SystemError("ERROR! This script must be run by submitty_daemon")

if len(sys.argv) != 4:
raise SystemError("ERROR! This script must be given 3 argument which should be path of lichen config")

semester = sys.argv[1];
course = sys.argv[2];
gradeable = sys.argv[3];

config_path = "/var/local/submitty/courses/"+ semester + "/" +course+ "/lichen/config/lichen_"+ semester+"_"+ course+ "_" +gradeable+".json"
with open(config_path) as saved_config:
data = json.load(saved_config)

run_lichen_plagiarism(data)
print("finished running lichen plagiarism for " + config_path)


# ------------------------------------------------------------------------

if __name__ == "__main__":
main()
@@ -30,4 +30,35 @@ def run_job(self):
build_output = os.path.join(DATA_DIR, 'courses', semester, course, 'build_script_output.txt')

with open(build_output, "w") as output_file:
subprocess.call([build_script, gradeable], stdout=output_file, stderr=output_file)
subprocess.call([build_script, semester, course, gradeable], stdout=output_file, stderr=output_file)

class RunLichen(AbstractJob):
def run_job(self):
semester = self.job_details['semester']
course = self.job_details['course']
gradeable = self.job_details['gradeable']

lichen_script = '/usr/local/submitty/sbin/run_lichen_plagiarism.py'
lichen_output = os.path.join(DATA_DIR, 'courses', semester, course, 'lichen', 'lichen_job_output.txt')

with open(lichen_output, "w") as output_file:
subprocess.call([lichen_script, semester, course, gradeable], stdout=output_file, stderr=output_file)

class DeleteLichenResult(AbstractJob):
def run_job(self):
semester = self.job_details['semester']
course = self.job_details['course']
gradeable = self.job_details['gradeable']

lichen_output = os.path.join(DATA_DIR, 'courses', semester, course, 'lichen', 'lichen_job_output.txt')

with open(lichen_output, "w") as output_file:
subprocess.call("rm"+ " /var/local/submitty/courses/" +semester+"/"+course+ "/lichen/config/lichen_"+semester+"_"+course+"_"+gradeable+".json", stdout=output_file, stderr=output_file, shell=True)
subprocess.call("rm"+ " /var/local/submitty/courses/" +semester+"/"+course+ "/lichen/ranking/"+gradeable+".txt", stdout=output_file, stderr=output_file, shell=True)
subprocess.call("rm"+ " -rf /var/local/submitty/courses/" +semester+"/"+course+ "/lichen/provided_code/"+gradeable, stdout=output_file, stderr=output_file, shell=True)
subprocess.call("rm"+ " -rf /var/local/submitty/courses/" +semester+"/"+course+ "/lichen/tokenized/"+gradeable, stdout=output_file, stderr=output_file, shell=True)
subprocess.call("rm"+ " -rf /var/local/submitty/courses/" +semester+"/"+course+ "/lichen/concatenated/"+gradeable, stdout=output_file, stderr=output_file, shell=True)
subprocess.call("rm"+ " -rf /var/local/submitty/courses/" +semester+"/"+course+ "/lichen/hashes/"+gradeable, stdout=output_file, stderr=output_file, shell=True)
subprocess.call("rm"+ " -rf /var/local/submitty/courses/" +semester+"/"+course+ "/lichen/matches/"+gradeable, stdout=output_file, stderr=output_file, shell=True)
subprocess.call("echo"+ " Deleted lichen plagiarism results and saved config for "+gradeable, stdout=op, stderr=op,shell=True)

Oops, something went wrong.

0 comments on commit fe71280

Please sign in to comment.