Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Student's solution with input() passes "Validate", but fails on "Autograde" #1844

Open
lahwaacz opened this issue Nov 1, 2023 · 1 comment
Labels

Comments

@lahwaacz
Copy link
Contributor

lahwaacz commented Nov 1, 2023

Steps to reproduce the actual behavior

For example, give students this assignment (I'll omit the description as it is self-explanatory):

def count_digits(n, d):
    ### BEGIN SOLUTION
    n = abs(n)
    return str(n).count(str(d))
    ### END SOLUTION

Let's assume just one simple public test case:

assert count_digits(112233, 2) == 2

Let's say that a student changes the cell with the assignment as follows:

a = input("Enter an integer")
b = input("Enter a digit")

def count_digits(n, d):
    n = abs(n)
    return str(n).count(str(d))

s = count_digits(int(a), int(b))
print(s)

Now there is an issue: when the student clicks on the "Validate" button in JupyterLab to validate their assignment, nbgrader executes it just fine and says that the solution passes all the tests. However, when the instructor runs autograde, it fails with the following error:

StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.

Expected behavior

Validate and autograde should behave consistently with respect to the input() function: either both should succeed, or both should fail with the same error.

Operating system

Arch Linux

nbgrader --version

Python version 3.11.5 (main, Sep  2 2023, 14:16:33) [GCC 13.2.1 20230801]
nbgrader version 0.9.1

jupyterhub --version (if used with JupyterHub)

4.0.2

jupyter notebook --version

7.0.6

jupyter lab --version

4.0.7
@brichet brichet added bug and removed bug labels Mar 25, 2024
@brichet
Copy link
Contributor

brichet commented Mar 25, 2024

Thanks @lahwaacz for reporting this issue.
After some inspection, it seems intentional that using the validate button only return errors on grade cells.

if utils.is_grade(cell):

There is even an option to validate the whole notebook, c.Validator.validate_all = True (default to False).

validate_all = Bool(
False,
help="Validate all cells, not just the graded tests cells."
).tag(config=True)

I don't have the history of these choices...

@brichet brichet added the UX/UI label Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants