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

New Feature: Automatic generation of test code #1650

Closed
wants to merge 113 commits into from

Conversation

trevorcampbell
Copy link
Contributor

@trevorcampbell trevorcampbell commented Jul 28, 2022

This is a PR related to Discussion #1633 -- please see that discussion for context!


Alright @jhamrick, as promised, here is the PR for the autotest functionality built into nbgrader. Major changes in this PR:

  • nbgrader/preprocessors/instantiatetests.py: A new preprocessor that converts ### AUTOTEST statements into test code. This preprocessor is included in the generate_assignments app and the instantiate_tests app.
  • nbgrader/converters/instantiate_tests.py: A new converter that creates a source_with_tests folder to see the source copy of the assignment with autogenerated test code
  • nbgrader/apps/instantiatetestsapp.py: A new instantiate_tests app that allows instructors to generate the test code in their solution version (this is useful for checking/playing with/debugging the test code that gets generated). The instantiated version of the notebook still contains all solutions and appears in the instantiated/ folder. this was removed per @jhamrick request.
  • nbgrader/preprocessors/limittestcellheights.py: A new preprocessor that edits test code cell metadata with a cell height property to ensure they don't get too large/unwieldy in the release version. This is included in the generate_assignments app. This was moved to a separate PR New Feature: Limit test cell height extension #1656 per @jhamrick request
  • nbgrader/nbextensions/limit_cell_height/: A new javascript extension responsible for making sure test cells don't get too large in the browser. Any test cell that would be larger than the max height gets a scroll bar instead. This was moved to a separate PR New Feature: Limit test cell height extension #1656 per @jhamrick request
  • Test code for all of the above
  • Some new example notebooks in the nbgrader/docs/source/user_guide/source folder that illustrate the use of autotest, with test template YaML code in nbgrader/docs/source/user_guide/tests.yml illustrating multiple languages
  • (minor unrelated change) an R codestub in the clearsolutions preprocessor

Please let @Alireza-Iranpour and myself know if you need any additional info!

Alireza-Iranpour and others added 27 commits June 24, 2022 03:38
Commented out `ClearSolutions` from the list of `preprocessors`
Restructured tests.yml file to support multiple kernel types including Python and R
Modified instantiatetests.py to support the new changes
@trevorcampbell
Copy link
Contributor Author

trevorcampbell commented Jul 29, 2022

I see a bunch of the tests failing because the PyYAML package isn't installed. We included it in the requirements.txt file, but I'm sure that's the wrong place to put it. I'm trying to trace through the code to figure out where packages are listed for the cmd = 'pip install -e .[tests]' line in tasks.py, but struggling a bit... advice much appreciated.

Nevermind, found it in setup.cfg! Will edit and see if I can get tests to go through.

Alireza-Iranpour and others added 4 commits August 24, 2022 10:23
Modified the check statement in tests.yml to be more robust in handling string quotation marks in python expressions passed to autotest
@trevorcampbell
Copy link
Contributor Author

@jhamrick we've handled all of your comments now. Should be ready for you again!

One question did come up. Running python tasks.py docs generated some extra files, not sure if you wanted those to be committed. See #1650 (comment)

@trevorcampbell
Copy link
Contributor Author

Hi @jhamrick -- it's been a few months now, and the PR has fallen behind the main branch a bit. This will need a bit of cleanup to get ready for review again. I'm happy to do the cleanup to bring it back up to speed, but I'll hold off on doing that until you let me know that you're ready!

@trevorcampbell
Copy link
Contributor Author

This PR is superceded by #1817 . We can close this one I think (hopefully the milestone tag can be transferred over to the new PR).

@trevorcampbell
Copy link
Contributor Author

After #1817 was merged this PR is no longer needed. Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants