Skip to content

Commit

Permalink
allow auto_job_name to be fixed (#3750)
Browse files Browse the repository at this point in the history
Allow auto_job_name to be fixed in the project manager.
  • Loading branch information
johrstrom authored Aug 29, 2024
1 parent 5c3e10a commit 1489dc0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard/app/controllers/launchers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LaunchersController < ApplicationController
:auto_batch_clusters, :auto_batch_clusters_exclude, :auto_batch_clusters_fixed,
:bc_num_slots, :bc_num_slots_fixed, :bc_num_slots_min, :bc_num_slots_max,
:bc_num_hours, :bc_num_hours_fixed, :bc_num_hours_min, :bc_num_hours_max,
:auto_job_name
:auto_job_name, :auto_job_name_fixed
].freeze

def new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module SmartAttributes
class AttributeFactory

# Build this attribute object. Must specify a valid directory in opts
#
# @param opts [Hash] attribute's options
Expand All @@ -18,8 +17,7 @@ class AutoJobName < Attribute
# Defaults to ondemand/[dev,sys]/projects
# @return [String] attribute value
def value
env = Rails.env.production? ? 'sys' : 'dev'
opts[:value] || "ondemand/#{env}/projects"
job_name(opts[:value] || 'Project Manager Job')
end

def widget
Expand All @@ -36,6 +34,16 @@ def label(*)
def submit(*)
{ script: { job_name: value } }
end

# TODO: need to sanitize the job name for some schedulers
def job_name(name)
[
ENV['OOD_PORTAL'], # the OOD portal id
ENV['RAILS_RELATIVE_URL_ROOT'].to_s.sub(%r{^/[^/]+/}, ''), # the OOD app
'project-manager',
name # the user supplied job name
].reject(&:blank?).join('/')
end
end
end
end
2 changes: 1 addition & 1 deletion apps/dashboard/test/system/project_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def add_auto_environment_variable(project_id, script_id, save: true)

Open3
.stubs(:capture3)
.with({}, 'sbatch', '-J', 'my cool job name', '-A', 'pas2051', '--export',
.with({}, 'sbatch', '-J', 'project-manager/my cool job name', '-A', 'pas2051', '--export',
'NONE', '--parsable', '-M', 'owens',
stdin_data: "hostname\n")
.returns(['job-id-123', '', exit_success])
Expand Down

0 comments on commit 1489dc0

Please sign in to comment.