Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/controllers/autograders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def create
a.access_key_id = ""
a.access_key = ""
a.instance_type = "t2.micro"
a.ami = ""
a.security_group = ""
end
if @autograder.save
flash[:success] = "Autograder created."
Expand All @@ -37,6 +39,9 @@ def edit
tar_path = Rails.root.join("courses", @course.name, @assessment.name, "autograde.tar")
@makefile_exists = File.exist?(makefile_path) ? makefile_path : nil
@tar_exists = File.exist?(tar_path) ? tar_path : nil
tango_info = TangoClient.info
@tagged_amis = tango_info["tagged_amis"] || []
@security_groups = tango_info["security_groups"] || []
end

action_auth_level :update, :instructor
Expand Down Expand Up @@ -116,7 +121,7 @@ def set_autograder

def autograder_params
params[:autograder].permit(:autograde_timeout, :autograde_image, :release_score, :access_key,
:access_key_id, :instance_type)
:access_key_id, :instance_type, :ami, :security_group)
end

def assessment_params
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ def getjob
def tango_status
# Obtain overall Tango info and pool status
@tango_info = TangoClient.info

# Obtain tagged AMIs and security groups from Tango
@tagged_amis = @tango_info["tagged_amis"] || []
@security_groups = @tango_info["security_groups"] || []

@vm_pool_list = TangoClient.pool
# Obtain Image -> Course mapping
@img_to_course = {}
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/assessment_autograde_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ def tango_add_job(course, assessment, upload_file_list, callback_url, job_name,
job_properties["accessKeyId"] = ""
end
job_properties["instanceType"] = @autograde_prop.instance_type
job_properties["ami"] = @autograde_prop.ami
job_properties["security_group"] = @autograde_prop.security_group
end

job_properties = job_properties.to_json

begin
response = TangoClient.addjob("#{course.name}-#{assessment.name}", job_properties)
rescue TangoClient::TangoException => e
Expand Down
9 changes: 9 additions & 0 deletions app/views/autograders/_ec2_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
<%= f.text_field :access_key_id, display_name: "Access Key ID" %>
<%= f.text_field :instance_type, display_name: "EC2 Instance Type",
help_text: "Type of EC2 instance to be used to run the autograding job. See <a href='https://aws.amazon.com/ec2/instance-types/'> here </a> for more details".html_safe %>
AMI
<%= f.select :ami,
options_for_select(@tagged_amis.map { |ami| ["Name: #{ami['name']}, ID: #{ami['id']}", ami['id']] }, f.object.ami),
{ include_blank: "Use Tango Default" } %>
<br>
Security Group
<%= f.select :security_group,
options_for_select(@security_groups.map { |sg| ["Name: #{sg['name']}, ID: #{sg['id']}", sg['name']] }, f.object.security_group),
{ include_blank: "Use Tango Default" } %>
<%= f.submit "Save Settings" %>

<%= link_to "Delete Autograder", course_assessment_autograder_path(@course, @assessment),
Expand Down
5 changes: 3 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2025_01_30_055238) do
ActiveRecord::Schema.define(version: 2025_04_13_141437) do

create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
Expand Down Expand Up @@ -153,6 +153,8 @@
t.string "access_key", default: ""
t.string "access_key_id", default: ""
t.boolean "use_access_key", default: false
t.string "ami", default: ""
t.string "security_group", default: ""
end

create_table "course_user_data", force: :cascade do |t|
Expand Down Expand Up @@ -384,7 +386,6 @@
t.text "missing_problems"
t.index ["assessment_id"], name: "index_submissions_on_assessment_id"
t.index ["course_user_datum_id"], name: "index_submissions_on_course_user_datum_id"
t.index ["created_at"], name: "index_submissions_on_created_at"
end

create_table "users", force: :cascade do |t|
Expand Down
Loading