-
Notifications
You must be signed in to change notification settings - Fork 232
Add EC2 autograder features #2281
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
Open
evanyeyeye
wants to merge
15
commits into
master
Choose a base branch
from
ec2-testing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
356f22c
testing ec2, add support on autolab side
20wildmanj 5539c82
add support for EC2 settings in Autolab
20wildmanj a47484c
fix issue with autograder initialization
20wildmanj a7fd8a1
add new option on Tango side to explicitly check for ec2 vmms usage, …
20wildmanj 30cc992
add ec2ssh to prod config
20wildmanj fc35ace
temporary changes to help with testing autolab 3
20wildmanj c3f761b
Revert "temporary changes to help with testing autolab 3"
20wildmanj 0345846
Merge conflicts
KesterTan e663c5d
Merge branch 'master' into ec2-testing
KesterTan 1ae51ed
Minor touchups
evanyeyeye 259f0f2
Merge branch 'ec2-testing' of github.com:autolab/Autolab into ec2-tes…
evanyeyeye afd0665
ec2-dropdown
Futurecomputerfixer b240eaf
fix linting
Futurecomputerfixer 5a93401
fix linting #2
Futurecomputerfixer 6765f5f
Merge branch 'master' into ec2-testing
KesterTan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
;(function() { | ||
$(document).ready(function () { | ||
function access_key_callback() { | ||
const checked = $(this).prop('checked'); | ||
const $access_key_field = $('#autograder_access_key'); | ||
const $access_key_id_field = $('#autograder_access_key_id'); | ||
$access_key_field.prop('disabled', !checked); | ||
$access_key_id_field.prop('disabled', !checked); | ||
if (!checked) { | ||
$access_key_field.val('', checked); | ||
$access_key_id_field.val('', checked); | ||
} | ||
} | ||
|
||
$('#autograder_use_access_key').on('change', access_key_callback); | ||
access_key_callback.call($('#autograder_use_access_key')); | ||
|
||
function initializeEC2Dropdown() { | ||
if ($.fn.tooltip) { | ||
$('.browser-default[data-tooltip]').tooltip({ | ||
enterDelay: 300, | ||
exitDelay: 200, | ||
position: 'top' | ||
}); | ||
} | ||
|
||
$('#autograder_instance_type option').hover( | ||
function() { $(this).addClass('highlighted-option'); }, | ||
function() { $(this).removeClass('highlighted-option'); } | ||
); | ||
|
||
$('#autograder_instance_type').on('change.ec2-instance', function() { | ||
const selectedInstance = $(this).val(); | ||
console.log('Selected EC2 instance type:', selectedInstance); | ||
}); | ||
} | ||
|
||
// Initialize the EC2 dropdown functionality | ||
initializeEC2Dropdown(); | ||
}); | ||
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<%= f.text_field :autograde_image, display_name: "VM Image", | ||
help_text: "VM image for autograding (e.g. <kbd>rhel.img</kbd>). #{link_to 'Click here', tango_status_course_jobs_path} to view the list of VM images and pools currently being used".html_safe + | ||
(Rails.configuration.x.docker_image_upload_enabled.presence ? ", or #{link_to 'click here', course_dockers_path} to upload a new docker image.".html_safe : "."), | ||
required: true, maxlength: 64 %> | ||
|
||
<%= f.number_field :autograde_timeout, display_name: "Timeout", | ||
help_text: "Timeout for autograding jobs (secs). Must be between 10s and 900s, inclusive.", min: 10, max: 900 %> | ||
<%= f.check_box :release_score, | ||
display_name: "Release Scores?", | ||
help_text: "Check to release autograded scores to students immediately after autograding (strongly recommended)." %> | ||
|
||
<% help_tar_text = "Tar file exists, upload a file to override." %> | ||
<% help_makefile_text = "Makefile exists, upload a file to override." %> | ||
<%= f.file_field :makefile, label_text: "Autograder Makefile", action: :upload, file_exists_text: help_makefile_text, class: "form-file-field", file_exists: @makefile_exists %> | ||
<%= f.file_field :tar, label_text: "Autograder Tar", action: :upload, file_exists_text: help_tar_text, class: "form-file-field", file_exists: @tar_exists %> | ||
<p class="help-block"> | ||
Both of the above files will be renamed upon upload. | ||
</p> | ||
|
||
<%= f.fields_for :assessment, @assessment do |af| %> | ||
<%= af.check_box :disable_network, help_text: "Disable network access for autograding containers." %> | ||
<% end %> | ||
|
||
<%= f.submit "Save Settings" %> | ||
|
||
<%= link_to "Delete Autograder", course_assessment_autograder_path(@course, @assessment), | ||
method: :delete, class: "btn danger", | ||
data: { confirm: "Are you sure you want to delete the Autograder for this assesssment?" } %> | ||
|
||
<% unless @makefile_exists.nil? %> | ||
<%= link_to "Download Makefile", download_file_course_assessment_autograder_path(file_path: @makefile_exists, file_key: 'makefile'), class: "btn" %> | ||
<% end %> | ||
|
||
<% unless @tar_exists.nil? %> | ||
<%= link_to "Download Tar", download_file_course_assessment_autograder_path(file_path: @tar_exists, file_key: 'tar'), class: "btn" %> | ||
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<% content_for :javascripts do %> | ||
<%= javascript_include_tag "autograder" %> | ||
<% end %> | ||
|
||
<h4>EC2 Settings</h4> | ||
<%= f.check_box :use_access_key, | ||
display_name: "Enable Access Key", | ||
help_text: "(Optional) Use your own provided access key to authenticate to different EC2 instances than the default one on Tango" %> | ||
<%= f.text_field :access_key, display_name: "Access Key" %> | ||
<%= f.text_field :access_key_id, display_name: "Access Key ID" %> | ||
|
||
<% | ||
# Group EC2 instance options by category for better organization | ||
ec2_instance_options = [ | ||
# General Purpose - T2 (burstable) | ||
['T2 - General Purpose (Burstable)', [ | ||
['t2.nano - 1 vCPU, 0.5 GiB RAM (minimal, lowest cost)', 't2.nano'], | ||
['t2.micro - 1 vCPU, 1 GiB RAM (lowest cost, suitable for small jobs)', 't2.micro'], | ||
['t2.small - 1 vCPU, 2 GiB RAM (low cost, better for memory-intensive tasks)', 't2.small'], | ||
['t2.medium - 2 vCPU, 4 GiB RAM (balanced, good for most autograding tasks)', 't2.medium'], | ||
['t2.large - 2 vCPU, 8 GiB RAM (better for memory-heavy workloads)', 't2.large'], | ||
['t2.xlarge - 4 vCPU, 16 GiB RAM (good for parallel processing)', 't2.xlarge'], | ||
['t2.2xlarge - 8 vCPU, 32 GiB RAM (high performance, burstable)', 't2.2xlarge'] | ||
]], | ||
# General Purpose - T3 (newer generation) | ||
['T3 - General Purpose (Newer Generation)', [ | ||
['t3.micro - 2 vCPU, 1 GiB RAM (better performance than t2.micro)', 't3.micro'], | ||
['t3.small - 2 vCPU, 2 GiB RAM (improved over t2.small)', 't3.small'], | ||
['t3.medium - 2 vCPU, 4 GiB RAM (better CPU performance than t2)', 't3.medium'], | ||
['t3.large - 2 vCPU, 8 GiB RAM (improved networking)', 't3.large'] | ||
]], | ||
# Compute Optimized | ||
['C - Compute Optimized', [ | ||
['c5.large - 2 vCPU, 4 GiB RAM (compute-optimized, faster CPU)', 'c5.large'], | ||
['c5.xlarge - 4 vCPU, 8 GiB RAM (high compute performance)', 'c5.xlarge'], | ||
['c5.2xlarge - 8 vCPU, 16 GiB RAM (very high compute performance)', 'c5.2xlarge'] | ||
]], | ||
# Memory Optimized | ||
['R - Memory Optimized', [ | ||
['r5.large - 2 vCPU, 16 GiB RAM (memory-optimized, for large datasets)', 'r5.large'], | ||
['r5.xlarge - 4 vCPU, 32 GiB RAM (high memory capacity)', 'r5.xlarge'], | ||
['r5.2xlarge - 8 vCPU, 64 GiB RAM (very high memory capacity)', 'r5.2xlarge'] | ||
]] | ||
] | ||
%> | ||
|
||
<div style="margin-bottom: 5px;"><strong>EC2 Instance Type</strong></div> | ||
|
||
<%= f.select :instance_type, | ||
grouped_options_for_select(ec2_instance_options, @autograder.instance_type), | ||
{ include_blank: false, label: "EC2 Instance Type" }, | ||
{ class: 'browser-default', | ||
data: { tooltip: "Select an EC2 instance type based on your autograding needs. Larger instances cost more but run faster." }, | ||
display_name: "EC2 Instance Type" } %> | ||
<div class="help-text"> | ||
Choose an instance type based on your autograding requirements: | ||
<ul class="browser-default" style="margin-top: 5px; margin-left: 15px;"> | ||
<li><strong>T2 instances</strong>: Burstable performance instances, good for varying workloads | ||
<ul> | ||
<li><strong>t2.micro</strong>: Default, lowest cost, suitable for simple autograding</li> | ||
<li><strong>t2.medium/large</strong>: Better for more complex tests with moderate requirements</li> | ||
</ul> | ||
</li> | ||
<li><strong>T3 instances</strong>: Newer generation with better baseline performance than T2</li> | ||
<li><strong>C5 (Compute-optimized)</strong>: Best for CPU-bound tasks like compilation, testing algorithms</li> | ||
<li><strong>R5 (Memory-optimized)</strong>: Best for memory-intensive operations with large datasets</li> | ||
</ul> | ||
<div class="recommendation-box" style="background-color: #f5f5f5; padding: 10px; border-left: 4px solid #2196F3; margin-top: 10px;"> | ||
<strong>Recommendations:</strong> | ||
<ul class="browser-default" style="margin-top: 5px; margin-left: 15px;"> | ||
<li>Start with <strong>t2.micro</strong> for basic assignments with minimal resource requirements</li> | ||
<li>Use <strong>t2.medium</strong> or <strong>t3.medium</strong> for most standard programming assignments</li> | ||
<li>Choose <strong>c5.xlarge</strong> for computationally intensive tasks (e.g., compiler projects)</li> | ||
<li>Select <strong>r5.large</strong> for memory-intensive workloads (e.g., large datasets, ML)</li> | ||
</ul> | ||
</div> | ||
<small>Note: Larger instances incur higher AWS costs. <a href='https://aws.amazon.com/ec2/pricing/on-demand/' target='_blank'>View EC2 pricing</a></small> | ||
</div> | ||
|
||
<%= f.submit "Save Settings" %> | ||
|
||
<%= link_to "Delete Autograder", course_assessment_autograder_path(@course, @assessment), | ||
method: :delete, class: "btn danger", | ||
data: { confirm: "Are you sure you want to delete the Autograder for this assesssment?" } %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,34 @@ | ||
<%= form_for @autograder, url: course_assessment_autograder_path(@course, @assessment, @autograder), | ||
builder: FormBuilderWithDateTimeInput, | ||
html: { multipart: true } do |f| %> | ||
<%= f.text_field :autograde_image, display_name: "VM Image", | ||
help_text: "VM image for autograding (e.g. <kbd>rhel.img</kbd>). #{link_to 'Click here', tango_status_course_jobs_path} to view the list of VM images and pools currently being used".html_safe + | ||
(Rails.configuration.x.docker_image_upload_enabled.presence ? ", or #{link_to 'click here', course_dockers_path} to upload a new docker image.".html_safe : "."), | ||
required: true, maxlength: 64 %> | ||
<div class="row"> | ||
<div class="col s12"> | ||
<ul id="tabs" class="tabs tabs-fixed-width"> | ||
<% list = ["basic"] %> | ||
<% if Rails.configuration.x.ec2_ssh.presence %> | ||
<% list.append("ec2") %> | ||
<% end %> | ||
<% list.each do |tab_name| %> | ||
<%= if tab_name == params[:active_tab] | ||
tag.li(link_to(tab_name.titleize, "#tab_#{tab_name}"), class: "active tab") | ||
else | ||
tag.li(link_to(tab_name.titleize, "#tab_#{tab_name}"), class: :tab) | ||
end %> | ||
<% end %> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
<%= f.number_field :autograde_timeout, display_name: "Timeout", | ||
help_text: "Timeout for autograding jobs (secs). Must be between 10s and 900s, inclusive.", min: 10, max: 900 %> | ||
<%= f.check_box :release_score, | ||
display_name: "Release Scores?", | ||
help_text: "Check to release autograded scores to students immediately after autograding (strongly recommended)." %> | ||
|
||
<% help_tar_text = "Tar file exists, upload a file to override." %> | ||
<% help_makefile_text = "Makefile exists, upload a file to override." %> | ||
<%= f.file_field :makefile, label_text: "Autograder Makefile", action: :upload, file_exists_text: help_makefile_text, class: "form-file-field", file_exists: @makefile_exists %> | ||
<%= f.file_field :tar, label_text: "Autograder Tar", action: :upload, file_exists_text: help_tar_text, class: "form-file-field", file_exists: @tar_exists %> | ||
<p class="help-block"> | ||
Both of the above files will be renamed upon upload. | ||
</p> | ||
|
||
<%= f.fields_for :assessment, @assessment do |af| %> | ||
<%= af.check_box :disable_network, help_text: "Disable network access for autograding containers." %> | ||
<% end %> | ||
|
||
<%= f.submit "Save Settings" %> | ||
|
||
<%= link_to "Delete Autograder", course_assessment_autograder_path(@course, @assessment), | ||
method: :delete, class: "btn danger", | ||
data: { confirm: "Are you sure you want to delete the Autograder for this assesssment?" } %> | ||
|
||
<% unless @makefile_exists.nil? %> | ||
<%= link_to "Download Makefile", download_file_course_assessment_autograder_path(file_path: @makefile_exists, file_key: 'makefile'), class: "btn" %> | ||
<% end %> | ||
|
||
<% unless @tar_exists.nil? %> | ||
<%= link_to "Download Tar", download_file_course_assessment_autograder_path(file_path: @tar_exists, file_key: 'tar'), class: "btn" %> | ||
<% end %> | ||
<% end %> | ||
<div class="row"> | ||
<div class="col s12"> | ||
<%= form_for @autograder, url: course_assessment_autograder_path(@course, @assessment, @autograder), | ||
builder: FormBuilderWithDateTimeInput, | ||
html: { multipart: true } do |f| %> | ||
<div id="tab_basic"> | ||
<%= render "basic_settings", f: %> | ||
</div> | ||
<% if Rails.configuration.x.ec2_ssh.presence %> | ||
<div id="tab_ec2"> | ||
<%= render "ec2_settings", f: %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
db/migrate/20241205233214_add_ec2_ssh_fields_to_autograders.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class AddEc2SshFieldsToAutograders < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :autograders, :instance_type, :string, default: "" | ||
add_column :autograders, :access_key, :string, default: "" | ||
add_column :autograders, :access_key_id, :string, default: "" | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20241211042124_add_use_access_key_to_autograder.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddUseAccessKeyToAutograder < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :autograders, :use_access_key, :boolean, default: false | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Ensure proper validation for EC2 parameters
The controller now correctly permits the new EC2 parameters. However, consider adding validation for the instance type and secure handling of AWS credentials.
🏁 Script executed:
Length of output: 348
Action Required: Enforce Validations on EC2 Parameters & Secure AWS Credentials
The controller now permits the new EC2 parameters, but our search in the Autograder model did not reveal any validations for
instance_type
or any encryption for AWS credentials. Please ensure that:instance_type
(e.g., checking that it matches a set of allowed values).access_key
(and potentiallyaccess_key_id
) are processed securely (e.g., through encryption or another secure handling mechanism).