From 5553369e81fe225ba7853476fc0179ae87584f5b Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Mon, 28 Oct 2024 16:39:35 -0400 Subject: [PATCH] specify workdir when submitting batch jobs --- apps/dashboard/app/models/launcher.rb | 9 ++++++++- apps/myjobs/app/models/resource_mgr_adapter.rb | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/dashboard/app/models/launcher.rb b/apps/dashboard/app/models/launcher.rb index f63cee97b5..3e1d45e59d 100644 --- a/apps/dashboard/app/models/launcher.rb +++ b/apps/dashboard/app/models/launcher.rb @@ -193,6 +193,7 @@ def submit(options) render_format = adapter.class.name.split('::').last.downcase job_script = OodCore::Job::Script.new(**submit_opts(options, render_format)) + Rails.logger.debug("Submitting with script: #{job_script.inspect}") job_id = Dir.chdir(project_dir) do adapter.submit(job_script) @@ -317,7 +318,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) diff --git a/apps/myjobs/app/models/resource_mgr_adapter.rb b/apps/myjobs/app/models/resource_mgr_adapter.rb index c00dae7ab3..1e28ffcfba 100644 --- a/apps/myjobs/app/models/resource_mgr_adapter.rb +++ b/apps/myjobs/app/models/resource_mgr_adapter.rb @@ -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