Skip to content

Commit

Permalink
specify workdir when submitting batch jobs (#3913)
Browse files Browse the repository at this point in the history
* specify workdir when submitting batch jobs

* rm debug log message

* fix this test for new cli args
  • Loading branch information
johrstrom authored Oct 31, 2024
1 parent 73e5638 commit f0959ad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 7 additions & 1 deletion apps/dashboard/app/models/launcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,13 @@ def submit_opts(options, render_format)
sm
end.map do |sm|
sm.submit(fmt: render_format)
end.reduce(&:deep_merge)[:script]
end.reduce(&:deep_merge)[:script].merge(
# force some values for scripts like the 'workdir'. We could use auto
# attributes, but this is not optional and not variable.
{
workdir: project_dir.to_s
}
)
end

def adapter(cluster_id)
Expand Down
14 changes: 9 additions & 5 deletions apps/dashboard/test/system/project_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def add_auto_environment_variable(project_id, script_id, save: true)

Open3
.stubs(:capture3)
.with({}, 'sbatch', '-A', 'pas2051', '--export', 'NONE', '--parsable', '-M', 'owens',
.with({}, 'sbatch', '-D', project_dir, '-A', 'pas2051', '--export', 'NONE', '--parsable', '-M', 'owens',
stdin_data: "hostname\n")
.returns(['job-id-123', '', exit_success])

Expand Down Expand Up @@ -439,8 +439,9 @@ def add_auto_environment_variable(project_id, script_id, save: true)

Open3
.stubs(:capture3)
.with({}, 'sbatch', '-J', 'project-manager/my cool job name', '-A', 'pas2051', '--export',
'NONE', '--parsable', '-M', 'owens',
.with({}, 'sbatch', '-D', project_dir,
'-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 Expand Up @@ -480,7 +481,7 @@ def add_auto_environment_variable(project_id, script_id, save: true)

Open3
.stubs(:capture3)
.with({}, 'sbatch', '-A', 'pas2051', '--export', 'NONE', '--parsable', '-M', 'owens',
.with({}, 'sbatch', '-D', project_dir, '-A', 'pas2051', '--export', 'NONE', '--parsable', '-M', 'owens',
stdin_data: "hostname\n")
.returns(['', 'some error message', exit_failure])

Expand Down Expand Up @@ -959,11 +960,14 @@ def add_auto_environment_variable(project_id, script_id, save: true)
find('i.fa-atom').click
input_data = File.read('test/fixtures/projects/chemistry-5533/assignment_1.sh')

project_dir = Dir.children(dir).select { |p| Pathname.new("#{dir}/#{p}").directory? }.first
project_dir = "#{dir}/#{project_dir}"

# NOTE: we're using pzs1715 from sacctmgr_show_accts_alt.txt instead of psz0175
# from the template.
Open3
.stubs(:capture3)
.with({}, 'sbatch', '-A', 'pzs1715', '--export', 'NONE', '--parsable', '-M', 'owens',
.with({}, 'sbatch', '-D', project_dir, '-A', 'pzs1715', '--export', 'NONE', '--parsable', '-M', 'owens',
stdin_data: input_data)
.returns(['job-id-123', '', exit_success])

Expand Down
1 change: 1 addition & 0 deletions apps/myjobs/app/models/resource_mgr_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def qsub(script_path, host: nil, depends_on: {}, account_string: nil)
cluster = cluster_for_host_id(host)
script = OodCore::Job::Script.new(
content: script_path.read,
workdir: script_path.parent.expand_path.to_s,
accounting_id: account_string,
job_array_request: workflow.job_array_request.presence,
copy_environment: workflow.copy_environment.eql?('1') ? true : false
Expand Down

0 comments on commit f0959ad

Please sign in to comment.