From 07a94cb76ac36a69c72f2e976955b10f5fa72356 Mon Sep 17 00:00:00 2001 From: buedaswag Date: Fri, 5 Nov 2021 11:49:45 +0000 Subject: [PATCH 1/2] allows grading locally without providing checksum --- dev_requirements.in | 1 + ldsagrader/ldsagrader.py | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dev_requirements.in b/dev_requirements.in index d0b89e5..c03786d 100644 --- a/dev_requirements.in +++ b/dev_requirements.in @@ -9,6 +9,7 @@ Sphinx twine black pip-tools +jupyter_client==6.1.12 pytest pytest-runner diff --git a/ldsagrader/ldsagrader.py b/ldsagrader/ldsagrader.py index efadde4..a3fb883 100644 --- a/ldsagrader/ldsagrader.py +++ b/ldsagrader/ldsagrader.py @@ -1,6 +1,7 @@ import io import os import sys +from typing import Dict import click import nbformat @@ -106,15 +107,15 @@ def notebook_validate(notebook, checksum, timeout): # noinspection PyShadowingNames @notebook.command("grade") @click.argument("notebook", type=click.Path(exists=True)) -@click.option("--checksum", required=True, type=click.Path(exists=True)) +@click.option("--checksum", type=click.Path(exists=True)) @click.option("--timeout", type=int, default=None) -def notebook_grade(notebook, checksum, timeout): +def notebook_grade(notebook, checksum, timeout) -> Dict[str, float]: """ Grade notebook running validations """ notebook = nbformat.read(notebook, as_version=nbformat.NO_CONVERT) - if not utils.is_valid(notebook, checksum): + if checksum and not utils.is_valid(notebook, checksum): print("Checksum mismatch! (a)") sys.exit(1) @@ -122,13 +123,15 @@ def notebook_grade(notebook, checksum, timeout): notebook = utils.execute(notebook, timeout) print("Grading notebook...") - if not utils.is_valid(notebook, checksum): + if checksum and not utils.is_valid(notebook, checksum): print("Checksum mismatch! (b)") sys.exit(1) total_score, max_score = utils.grade(notebook) print(f"Score: {total_score}/{max_score}") + return {'total_score': total_score, 'max_score': max_score} + # noinspection PyShadowingNames @notebook.command("execute") From 16479e2b805f421a7a39638ffbd93dad0edb7348 Mon Sep 17 00:00:00 2001 From: buedaswag Date: Fri, 5 Nov 2021 12:19:11 +0000 Subject: [PATCH 2/2] allows grading locally without providing checksum --- dev_requirements.in | 1 - setup.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_requirements.in b/dev_requirements.in index c03786d..d0b89e5 100644 --- a/dev_requirements.in +++ b/dev_requirements.in @@ -9,7 +9,6 @@ Sphinx twine black pip-tools -jupyter_client==6.1.12 pytest pytest-runner diff --git a/setup.py b/setup.py index db46621..ad2935b 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ "Click", "nbgrader", "requests", + "jupyter_client==6.1.12" ] setup_requirements = [