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

Concurrent Grading using asyncio #33

Closed
wants to merge 9 commits into from
Closed

Concurrent Grading using asyncio #33

wants to merge 9 commits into from

Conversation

brhoades
Copy link
Member

@brhoades brhoades commented Mar 4, 2017

I've drafted concurrent grading using asyncio coroutines (threads instead of processes). By default, it's synchronous, but if -j is specified it uses that many worker threads.

It's currently NOT printing output as I'm not sure if that's desirable / if print locks stdout until it finishes.

Implements #21

Default (unchanged) behavior:

$ bin/grader grade hw1
INFO     Grading submissions for 6960054b3387
INFO:grade-it:Time to start the tests.
============================= test session starts ==============================
platform linux -- Python 3.4.3, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /tmp/tmp.nH26e9oICs, inifile:
collected 0 items

========================= no tests ran in 0.00 seconds =========================
INFO     Logging 6960054b3387 output as text
INFO     Wrote to grader/assignments/hw1/results/6960054b3387.13.log
INFO     Grading submissions for 9d7fe62204ad
INFO:grade-it:Time to start the tests.
============================= test session starts ==============================
platform linux -- Python 3.4.3, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /tmp/tmp.dMhPCDEGYY, inifile:
collected 0 items

========================= no tests ran in 0.00 seconds =========================
INFO     Logging 9d7fe62204ad output as text
INFO     Wrote to grader/assignments/hw1/results/9d7fe62204ad.13.log
INFO     Grading submissions for a65a6d7183c2
INFO:grade-it:Time to start the tests.
============================= test session starts ==============================
platform linux -- Python 3.4.3, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /tmp/tmp.myqboGzXZb, inifile:
collected 0 items

========================= no tests ran in 0.00 seconds =========================
INFO     Logging a65a6d7183c2 output as text
INFO     Wrote to grader/assignments/hw1/results/a65a6d7183c2.12.log
INFO     Grading submissions for dacb24920b25
INFO:grade-it:Time to start the tests.
============================= test session starts ==============================
platform linux -- Python 3.4.3, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /tmp/tmp.s3cgnK0vx8, inifile:
collected 0 items

========================= no tests ran in 0.00 seconds =========================
INFO     Logging dacb24920b25 output as text
INFO     Wrote to grader/assignments/hw1/results/dacb24920b25.12.log

and with concurrency:

$ bin/grader grade -j2 hw1
INFO     Grading submission for 6960054b3387
INFO     Grading submission for 9d7fe62204ad
INFO     Logging 9d7fe62204ad output as text
INFO     Wrote to grader/assignments/hw1/results/9d7fe62204ad.14.log
INFO     Logging 6960054b3387 output as text
INFO     Wrote to grader/assignments/hw1/results/6960054b3387.14.log
INFO     Grading submission for a65a6d7183c2
INFO     Grading submission for dacb24920b25
INFO     Logging dacb24920b25 output as text
INFO     Wrote to grader/assignments/hw1/results/dacb24920b25.13.log
INFO     Logging a65a6d7183c2 output as text
INFO     Wrote to grader/assignments/hw1/results/a65a6d7183c2.13.log

@brhoades brhoades changed the title #21 Concurrent Grading using asyncio Concurrent Grading using asyncio Mar 4, 2017
@brhoades
Copy link
Member Author

brhoades commented Mar 4, 2017

Output from threads is now, by default, printed unless suppress_output is enabled. Output is printed at the end of the thread by the thread (not as it is retrieved). This reduces the chance that two threads will print at once, but it's still possible.

Do we want to do a mutex lock on stdout here?

ie: https://docs.python.org/3/library/threading.html#condition-objects

@LinuxMercedes
Copy link
Member

I think it'd be nice to have printing synchronous, but not a requirement.

@brhoades
Copy link
Member Author

brhoades commented Mar 5, 2017

@LinuxMercedes added print lock
@michaelwisely comments?

@michaelwisely
Copy link
Member

michaelwisely commented Mar 5, 2017

@brhoades i think there's a more idiomatic way to synchronize output without using a Lock(). Let me have a go at refactoring tonight.

"""
logger.info("Grading submission for %s", submission.user_id)
output = submission.grade(
rebuild_container=rebuild, show_output=False)
Copy link
Member

Choose a reason for hiding this comment

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

@brhoades is this an unbalanced parenthesis?

@LinuxMercedes LinuxMercedes force-pushed the master branch 2 times, most recently from a972380 to d15b772 Compare October 31, 2019 16:03
@brhoades
Copy link
Member Author

This PR is almost as old as my career. Closing it out.

@brhoades brhoades closed this Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants