Skip to content

[Feature:TAGrading] Add submission clustering daemon#13004

Merged
bmcutler merged 20 commits into
mainfrom
daemon-cluster-infra
Jul 20, 2026
Merged

[Feature:TAGrading] Add submission clustering daemon#13004
bmcutler merged 20 commits into
mainfrom
daemon-cluster-infra

Conversation

@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor

Why is this Change Important & Necessary?

This PR adds a daemon job to support asynchronous submission clustering.

What is the New Behavior?

Now the submission clustering algorithms run asynchronously.
In this PR we have also removed some the files that would not be needed now that was introduced in #12886.

What steps should a reviewer take to reproduce or test the bug or new feature?

  1. Run submitty_install

  2. Run php unit test (in site folder)-
    vendor/bin/phpunit tests/app/controllers/grading/GradingClusterControllerTester.php

  3. Run python unit test -
    cd /usr/local/submitty/GIT_CHECKOUT/Submitty/sbin/submitty_daemon_jobs
    python3 -m unittest tests/test_grading_clustering.py

Test if backend is fine-

  1. First inside site folder to see the logs-
    tail -f /var/local/submitty/logs/daemon_job_queue/$(date +%Y%m%d).txt

  2. Go to any gradeable, in the browser console, hit a post request-
    let formData = new FormData();
    formData.append('csrf_token', csrfToken);
    formData.append('algorithm', 'dummy_split');

fetch(buildCourseUrl(['gradeable', '<GRADEABLE_ID>', 'create_clustering']), {
method: 'POST',
body: formData
})
.then(res => res.json())
.then(console.log);

Please check the daemon log-
image

  1. Make a get request to verify the clusters formed-
    fetch(buildCourseUrl(['gradeable', '<GRADEABLE_ID>', 'clustering']))
    .then(res => res.json())
    .then(console.log);

Automated Testing & Documentation

The core Python clustering logic is covered by unit tests in sbin/submitty_daemon_jobs/tests/test_grading_clustering.py. The PHP Controller is covered by tests/app/controllers/grading/GradingClusterControllerTester.php.

Other information

Please run submitty_install before reviewing.

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.16%. Comparing base (60ec398) to head (a55590a).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #13004      +/-   ##
============================================
+ Coverage     21.11%   21.16%   +0.04%     
+ Complexity    10104    10102       -2     
============================================
  Files           282      285       +3     
  Lines         38230    38769     +539     
  Branches        596      596              
============================================
+ Hits           8074     8205     +131     
- Misses        29574    29982     +408     
  Partials        582      582              
Flag Coverage Δ
autograder 21.16% <ø> (ø)
js 1.73% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.20% <3.03%> (-0.01%) ⬇️
python_submitty_utils 79.83% <ø> (ø)
submitty_daemon_jobs 55.91% <97.72%> (-35.23%) ⬇️
vue 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dagemcn dagemcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was able to verify the daemon is working and after sending the POST request I could see the correct output in the logs. I looked over the code but I'm not too familiar with the previous code for this project so someone that reviewed the backend PR should definitely also look at this. To clarify, is there a reason to run the php-lint before testing the backend? Also, see my other comment.

Comment thread sbin/grading_clustering/algorithms/__init__.py
@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Work in Progress in Submitty Development Jul 6, 2026
@GarvitKhandelwal31

GarvitKhandelwal31 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

To clarify, is there a reason to run the php-lint before testing the backend?

I am not sure where are we running php lint? We are running a php unit test GradingClusterControllerTester.php

@williamjallen williamjallen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks pretty reasonable to me overall. I plan to approve once the inline comments are addressed. @bmcutler should probably double check the high level stuff since she knows the architecture of this part of the codebase better than I do.

Comment thread sbin/submitty_daemon_jobs/submitty_jobs/jobs.py Outdated
Comment thread sbin/submitty_daemon_jobs/tests/test_grading_clustering.py Outdated
Comment thread sbin/run_grading_clustering.py Outdated
Comment thread sbin/grading_clustering/main.py

@NicholasCiuica NicholasCiuica left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't know if this is an issue with your PHP test or a misunderstanding on my end, but with our current documentation I was not able to run the new PHP unit test by itself. I can run all PHP unit tests by running "submitty_test php-unit", but I get an error when running the following command in the site directory in my VM:

submitty_test php-unit --filter vendor/bin/phpunit tests/app/controllers/grading/GradingClusterControllerTester.php

Image

And upon trying to define XDBUG_MODE=coverage in my command, I get error "Test file "XDEBUG_MODE=coverage" not found".

Other than that, I was able to follow the testing procedure and confirm using the logs that the daemon completed the clustering task after the post request. I can't really comment on the code itself, as I am not super familiar with daemon programming.

@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor Author

I don't know if this is an issue with your PHP test or a misunderstanding on my end, but with our current documentation I was not able to run the new PHP unit test by itself. I can run all PHP unit tests by running "submitty_test php-unit", but I get an error when running the following command in the site directory in my VM:

submitty_test php-unit --filter vendor/bin/phpunit tests/app/controllers/grading/GradingClusterControllerTester.php

Image And upon trying to define XDBUG_MODE=coverage in my command, I get error "Test file "XDEBUG_MODE=coverage" not found".

From what I know the XDEBUG warning when running unit tests in VM is normal. Also I tried myself the command I stated in description for running unit test is working, I dont know what maybe caused the issue on your side.
Try running this in site folder-
XDEBUG_MODE=coverage vendor/bin/phpunit tests/app/controllers/grading/GradingClusterControllerTester.php

@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Jul 10, 2026
@GarvitKhandelwal31
GarvitKhandelwal31 marked this pull request as draft July 10, 2026 17:50
@automateprojectmangement automateprojectmangement Bot moved this from In Review to Work in Progress in Submitty Development Jul 10, 2026
@GarvitKhandelwal31
GarvitKhandelwal31 marked this pull request as ready for review July 10, 2026 18:45
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to Seeking Reviewer in Submitty Development Jul 10, 2026

@williamjallen williamjallen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me once the inline comment is addressed.

Comment thread sbin/grading_clustering/algorithms/dummy_split.py

@bmcutler bmcutler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this PR adding multiple files at the top level of sbin?
sbin is a collection of one-off superuser scripts -- many run directly by the sysadmin doing maintenance tasks. I don't think clustering should be mixed up with these files. I think clustering is a more substantial project and should be organized in its own directory.

Why is this PR editing the cleanup active graders script?

I don't like the vague naming of the 'database_queries.py' script. You've added very specific functions only used by clustering to this script. Is this a good design plan?

@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor Author

@bmcutler

Why is this PR adding multiple files at the top level of sbin? sbin is a collection of one-off superuser scripts -- many run directly by the sysadmin doing maintenance tasks. I don't think clustering should be mixed up with these files. I think clustering is a more substantial project and should be organized in its own directory.

I previously hadn't considered the clutter in sbin/ , but I agree it should now be separated. We can create a new directory sbin/grading_clustering/ and move related files there.

Why is this PR editing the cleanup active graders script?

My reason for touching that file was to fix Python Lint error. Both scripts needed the same database connection logic so linter was complaining about the duplicate code. If you would want I can revert that.

I don't like the vague naming of the 'database_queries.py' script. You've added very specific functions only used by clustering to this script. Is this a good design plan?

My rationale was to make it like a centralized file for all database queries just like we have DatabaseQueries.php. But if you would want I can create a new 'database.py' file located inside the new directory we plan to create.

@bmcutler bmcutler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for restructuring the files.
I also did a brief test as described in the message and it seems to have worked as intended.

Comment thread sbin/submitty_daemon_jobs/submitty_jobs/__init__.py
@bmcutler
bmcutler merged commit fbdaa75 into main Jul 20, 2026
27 of 28 checks passed
@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Done in Submitty Development Jul 20, 2026
@bmcutler
bmcutler deleted the daemon-cluster-infra branch July 20, 2026 03:30
jndlansh pushed a commit to jndlansh/Submitty that referenced this pull request Jul 20, 2026
### Why is this Change Important & Necessary?
This PR adds a daemon job to support asynchronous submission clustering.

### What is the New Behavior?
Now the submission clustering algorithms run asynchronously.
In this PR we have also removed some the files that would not be needed
now that was introduced in Submitty#12886.

### What steps should a reviewer take to reproduce or test the bug or
new feature?
1. Run submitty_install
2. Run php unit test (in site folder)-
vendor/bin/phpunit
tests/app/controllers/grading/GradingClusterControllerTester.php
 
 
 3. Run python unit test -
 cd /usr/local/submitty/GIT_CHECKOUT/Submitty/sbin/submitty_daemon_jobs
 python3 -m unittest tests/test_grading_clustering.py
 
Test if backend is fine-
1) First inside site folder to see the logs-
tail -f /var/local/submitty/logs/daemon_job_queue/$(date +%Y%m%d).txt

2) Go to any gradeable, in the browser console, hit a post request-
let formData = new FormData();
formData.append('csrf_token', csrfToken);
formData.append('algorithm', 'dummy_split');

fetch(buildCourseUrl(['gradeable', '<GRADEABLE_ID>',
'create_clustering']), {
method: 'POST',
body: formData
})
.then(res => res.json())
.then(console.log);

Please check the daemon log-
<img width="1435" height="142" alt="image"
src="https://github.com/user-attachments/assets/85cbaa8f-3a79-4add-8df9-83829fb7d71d"
/>

3) Make a get request to verify the clusters formed-
fetch(buildCourseUrl(['gradeable', '<GRADEABLE_ID>', 'clustering']))
.then(res => res.json())
.then(console.log);

### Automated Testing & Documentation
The core Python clustering logic is covered by unit tests in
`sbin/submitty_daemon_jobs/tests/test_grading_clustering.py`. The PHP
Controller is covered by
`tests/app/controllers/grading/GradingClusterControllerTester.php`.

### Other information
Please run submitty_install before reviewing.
jndlansh added a commit to jndlansh/Submitty that referenced this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants