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

allow auto_job_name to be fixed #3750

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we just pulling the app or the router and app? I ask because the comment only mentions the app but:

irb(main):003:0> "/pun/dev/dashboard".sub(%r{^/[^/]+/}, '')
=> "dev/dashboard"

Just wanted to check the intent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the router and the app (and the portal and the subapp).

If you look in activejobs right now at OSC you'll see job names like this, so this follows the same implementation that the jobcomposer and batch connect apps currently use.

image

'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 @@ -429,7 +429,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
Loading