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

Python 3.x fixes and codejail config #58

Merged
merged 1 commit into from
Apr 7, 2021
Merged

Conversation

shaidar
Copy link
Contributor

@shaidar shaidar commented Mar 26, 2021

This PR addresses the following two issues:

  • Reported issue where the learner input was not being properly tokenized and thus import statements weren't being read and causing an error to be thrown that no import statement are specified.
  • When the limits object is set in the codejail configuration block it causes the command used for launching a watcher process to be invalid. This is because there was a variable name used in a for loop that shadowed a variable from an outer scope that is then returned from the enable_codejail method that is used as an argument for the execution.
  • The PR that removed the usage of six failed to wrap the conditional environment or {} in parentheses before calling .items() on the resulting value. This would lead to trying to iterate over either environment or {}.items() which is not the correct behavior.

@openedx-webhooks
Copy link

Thanks for the pull request, @shaidar! I've created OSPR-5693 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels Mar 26, 2021
@natabene
Copy link

@shaidar Thank you for your contribution. I am lining this up for our review.

@openedx-webhooks openedx-webhooks added awaiting prioritization and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. labels Mar 26, 2021
@pdpinch
Copy link

pdpinch commented Mar 26, 2021

Not sure, but I think this might have been a regression related to #56

@UsamaSadiq or @iamsobanjaved can you take a look?

As far as I can tell, this code isn't covered by tests. We were going to hold off until we could get some tests written, but I just heard this is causing problems for a final exam that starts today.

@sarina
Copy link
Contributor

sarina commented Mar 26, 2021

@adzuci maybe? The two you've tagged are probably offline through Monday. And #56 wasn't merged; I would assume this is related to #57

@pdpinch
Copy link

pdpinch commented Mar 26, 2021

Thanks, I did mean #57.

And I'm probably wrong about the cause the regression. It may be more of an environment issue -- I don't see how the code we're patching here could have ever worked, except that it wasn't touched in a Python 2.7

@adzuci
Copy link
Contributor

adzuci commented Mar 26, 2021

I think it would be better to merge the PR rather than https://github.com/edx/xqueue-watcher/pull/59/files, but since there is an exam going on until 3/30 and edx has rolled back to the version of the xqwatcher from 3/8 in prod I think it may be better to leave the service on python 2.7 until Monday.

Note that this code likely won't get pulled in until we unpause our xqwatcher pipelines and do a deploy on python 3.5: https://github.com/mitodl/graders-mit-600x/blob/master/graders/python3graders

Copy link
Member

@UsamaSadiq UsamaSadiq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. We can merge it and then try deploying to Python35 again once the test is over.

@UsamaSadiq
Copy link
Member

UsamaSadiq commented Mar 30, 2021

@shaidar Thanks for this effort. Just a heads-up, before merging this PR, I'll squash the commits and rewrite the commit message so it follows the Conventional Commit guidelines.

Copy link
Contributor

@doctoryes doctoryes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment removal - otherwise 👍🏼

@@ -238,11 +239,7 @@ def _tokens(code):
A wrapper around tokenize.generate_tokens.
"""
# Protect against pathological inputs: http://bugs.python.org/issue16152
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should also be removed, as the bug is fixed and the bug workaround is removed.

@adzuci
Copy link
Contributor

adzuci commented Apr 7, 2021

@shaidar or @blarghmatey, we are planning to ship this this morning. Would one of you be able to update the PR to resolve the comment by @doctoryes?

Fixes incompatible tokenization of user submitted code when running under Python 3.x. This is used to add checks to ensure that students are using specific keywords or language features.

Fix bug when using codejail limits in xqueue-watcher

When the `limits` object is set in the codejail configuration block it causes the command used for launching a watcher process to be invalid. This is because there was a variable name used in a for loop that shadowed a variable from an outer scope that is then returned from the `enable_codejail` method that is used as an argument for the execution.

Fixed invalid conversion of conditional dictionary iterator

The PR that removed the usage of `six` failed to wrap the conditional `environment or {}` in parentheses before calling `.items()` on the resulting value. This would lead to trying to iterate over _either_ `environment` or `{}.items()` which is not the correct behavior.
@openedx-webhooks
Copy link

@shaidar 🎉 Your pull request was merged!

Please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged open-source-contribution PR author is not from Axim or 2U
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants