From 170628455f4300ddb275b12d024115099337e52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=20Vinh=20LUONG=20=28L=C6=AF=C6=A0NG=20Th=E1=BA=BF=20Vi?= =?UTF-8?q?nh=29?= Date: Thu, 18 Aug 2022 21:20:30 -0700 Subject: [PATCH 1/9] minor fixes to deps & setup --- requirements/production.txt | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements/production.txt b/requirements/production.txt index 0ace125..c528d34 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -4,7 +4,7 @@ # # make upgrade # --e git+https://github.com/edx/codejail.git@4127fc4bd5775cc72aee8d7f0a70e31405e22439#egg=codejail +EdX-CodeJail >= 3.2.0 # via -r requirements/base.txt certifi==2022.6.15 # via @@ -20,7 +20,7 @@ idna==3.3 # via # -r requirements/base.txt # requests -newrelic==7.16.0.178 +# newrelic==7.16.0.178 # TODO: fix installation error # via -r requirements/base.txt path==16.4.0 # via diff --git a/setup.py b/setup.py index a4c14f6..d4ac4a7 100644 --- a/setup.py +++ b/setup.py @@ -7,5 +7,5 @@ packages=[ 'xqueue_watcher', ], - install_requires=open('requirements/production.txt', 'rb').readlines() + install_requires=open('requirements/production.txt', 'rt').readlines() ) From 542a80604c9d5f5d5ce94e3aee0d0ce4bb697a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=20Vinh=20LUONG=20=28L=C6=AF=C6=A0NG=20Th=E1=BA=BF=20Vi?= =?UTF-8?q?nh=29?= Date: Thu, 18 Aug 2022 21:31:04 -0700 Subject: [PATCH 2/9] minor fixes to xqueue_watcher.jailedgrader.main(...) --- xqueue_watcher/jailedgrader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xqueue_watcher/jailedgrader.py b/xqueue_watcher/jailedgrader.py index b9c4f45..e44d136 100644 --- a/xqueue_watcher/jailedgrader.py +++ b/xqueue_watcher/jailedgrader.py @@ -275,10 +275,10 @@ def main(args): # pragma: no cover (grader_path, submission_path) = args with open(submission_path) as f: - submission = f.read().decode('utf-8') + submission = f.read() # .decode('utf-8') grader_config = {"lang": "eo"} - grader_path = path(grader_path).abspath() + grader_path = Path(grader_path).abspath() g = JailedGrader(grader_root=grader_path.dirname().parent.parent) pprint(g.grade(grader_path, grader_config, submission)) From bfa3fbbe1067da86972c596a0ebea4a5b6cc7013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=20Vinh=20LUONG=20=28L=C6=AF=C6=A0NG=20Th=E1=BA=BF=20Vi?= =?UTF-8?q?nh=29?= Date: Thu, 18 Aug 2022 22:21:32 -0700 Subject: [PATCH 3/9] allow graders with only input checks & no tests --- xqueue_watcher/jailedgrader.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xqueue_watcher/jailedgrader.py b/xqueue_watcher/jailedgrader.py index e44d136..91b3bd3 100644 --- a/xqueue_watcher/jailedgrader.py +++ b/xqueue_watcher/jailedgrader.py @@ -243,10 +243,19 @@ def grade(self, grader_path, grader_config, submission): # If there were no tests run, then there was probably an error, so it's incorrect n = len(corrects) - results['correct'] = all(corrects) and n > 0 + + # *** ALLOW GRADERS WITH ONLY INPUT CHECKS & NO TESTS *** + # ======================================================= + results['correct'] = all(corrects) and (n or grader._input_checks) + # ------------------------------------------------------- + results['score'] = float(sum(corrects))/n if n > 0 else 0 - if n == 0 and len(results['errors']) == 0: + # *** ALLOW GRADERS WITH ONLY INPUT CHECKS & NO TESTS *** + # ======================================================= + if not (n or results['errors'] or grader._input_checks): + # ------------------------------------------------------- + results['errors'] = [ _("There was a problem while running your code (Staff debug: L450). " "Please contact the course staff for assistance.") From 48ab9b60305460890576c571021d7a41f48ba8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=20Vinh=20LUONG=20=28L=C6=AF=C6=A0NG=20Th=E1=BA=BF=20Vi?= =?UTF-8?q?nh=29?= Date: Thu, 18 Aug 2022 22:33:56 -0700 Subject: [PATCH 4/9] refactor + allow graders with only input checks & no tests --- xqueue_watcher/jailedgrader.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xqueue_watcher/jailedgrader.py b/xqueue_watcher/jailedgrader.py index 91b3bd3..6384517 100644 --- a/xqueue_watcher/jailedgrader.py +++ b/xqueue_watcher/jailedgrader.py @@ -246,20 +246,20 @@ def grade(self, grader_path, grader_config, submission): # *** ALLOW GRADERS WITH ONLY INPUT CHECKS & NO TESTS *** # ======================================================= - results['correct'] = all(corrects) and (n or grader._input_checks) + _n = len(grader._input_checks) # pylint: disable=protected-access + results['correct'] = all(corrects) and ((n > 0) or (_n > 0)) # ------------------------------------------------------- results['score'] = float(sum(corrects))/n if n > 0 else 0 # *** ALLOW GRADERS WITH ONLY INPUT CHECKS & NO TESTS *** # ======================================================= - if not (n or results['errors'] or grader._input_checks): - # ------------------------------------------------------- - + if not (n or results['errors'] or _n): results['errors'] = [ _("There was a problem while running your code (Staff debug: L450). " "Please contact the course staff for assistance.") ] + # ------------------------------------------------------- return results From df004003fd356b963f021cb4bce6a71a693f8c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=20Vinh=20LUONG=20=28L=C6=AF=C6=A0NG=20Th=E1=BA=BF=20Vi?= =?UTF-8?q?nh=29?= Date: Thu, 18 Aug 2022 22:43:22 -0700 Subject: [PATCH 5/9] install grader_support package as well --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index d4ac4a7..9034cad 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,7 @@ version='0.2', description='XQueue Pull Grader', packages=[ + 'grader_support', 'xqueue_watcher', ], install_requires=open('requirements/production.txt', 'rt').readlines() From a6f021e18a253ae3e220ab5dca27334f04205aec Mon Sep 17 00:00:00 2001 From: Vinh Luong Date: Sat, 20 Aug 2022 16:57:44 -0700 Subject: [PATCH 6/9] minor edits (setup.py) --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9034cad..cf56982 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ from setuptools import setup + setup( name='xqueue_watcher', version='0.2', @@ -8,5 +9,6 @@ 'grader_support', 'xqueue_watcher', ], - install_requires=open('requirements/production.txt', 'rt').readlines() + install_requires=open('requirements/production.txt', + 'rt', encoding='utf-8').readlines(), ) From b5269aea60286b0ab67b5c4f5081bc359712e84a Mon Sep 17 00:00:00 2001 From: Vinh Luong Date: Mon, 22 Aug 2022 16:42:31 -0700 Subject: [PATCH 7/9] minor temp fix in xqueue_watcher.jailedgrader.JailedGrader to accommodate multiple answer files --- setup.py | 2 +- xqueue_watcher/jailedgrader.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index cf56982..e214c39 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='xqueue_watcher', - version='0.2', + version='0.2.1', description='XQueue Pull Grader', packages=[ 'grader_support', diff --git a/xqueue_watcher/jailedgrader.py b/xqueue_watcher/jailedgrader.py index 6384517..78c0ba6 100644 --- a/xqueue_watcher/jailedgrader.py +++ b/xqueue_watcher/jailedgrader.py @@ -115,7 +115,14 @@ def grade(self, grader_path, grader_config, submission): self._enable_i18n(grader_config.get("lang", LANGUAGE)) - answer_path = Path(grader_path).dirname() / 'answer.py' + # *** MINOR TEMP FIX TO ACCOMMODATE MULTIPLE ANSWER FILES *** + # =========================================================== + answer_path = ((parent_dir_path := Path(grader_path).parent) / # noqa: W504 + next(file_name + for file_name in os.listdir(path=parent_dir_path) + if file_name.lower().startswith('answer') + and file_name.endswith('.py'))) # noqa: W503 + # ----------------------------------------------------------- with open(answer_path, 'rb') as f: answer = f.read().decode('utf-8') From 57e2a007b2561b7aa4cbd6867170c12feb06ad6b Mon Sep 17 00:00:00 2001 From: Vinh Luong Date: Mon, 22 Aug 2022 22:07:54 -0700 Subject: [PATCH 8/9] minor temp fix to xqueue_watcher.jailedgrader.JailedGrader.grade(...) --- setup.py | 2 +- xqueue_watcher/jailedgrader.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e214c39..94e1bac 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='xqueue_watcher', - version='0.2.1', + version='0.2.2', description='XQueue Pull Grader', packages=[ 'grader_support', diff --git a/xqueue_watcher/jailedgrader.py b/xqueue_watcher/jailedgrader.py index 78c0ba6..7b3df22 100644 --- a/xqueue_watcher/jailedgrader.py +++ b/xqueue_watcher/jailedgrader.py @@ -139,6 +139,13 @@ def grade(self, grader_path, grader_config, submission): # Don't run tests if there were errors return results + # *** IF THERE'RE ONLY INPUT CHECKS & NO TESTS, THEN RETURN CORRECT *** + # ===================================================================== + elif not grader._tests: # pylint: disable=protected-access + results['correct'] = True + return results + # --------------------------------------------------------------------- + # Add a unicode encoding declaration. processed_answer = prepend_coding(grader.preprocess(answer)) processed_submission = prepend_coding(grader.preprocess(submission)) From 7b8e8e3630ddb8b799c56712073b111c644afc71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=20Vinh=20LUONG=20=28LU=CC=9BO=CC=9BNG=20The=CC=82?= =?UTF-8?q?=CC=81=20Vinh=29?= Date: Thu, 13 Jul 2023 16:17:11 -0700 Subject: [PATCH 9/9] fix NewRelic dep --- requirements/production.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/requirements/production.txt b/requirements/production.txt index 2293cd2..7b3f094 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -20,11 +20,7 @@ idna==3.4 # via # -r requirements/base.txt # requests -<<<<<<< HEAD -# newrelic==7.16.0.178 # TODO: fix installation error -======= newrelic==8.7.0 ->>>>>>> 180d12060386e88b36f0bcdc12a2e4c77db2a49f # via -r requirements/base.txt path==16.6.0 # via