Merge pull request #11349 from jmchilton/tool_environment_vars_puslar

[21.01] Add tool environment variables to Pulsar client.
This commit is contained in:
Marius van den Beek
2021-02-13 18:58:05 +01:00
committed by GitHub
4 changed files with 22 additions and 3 deletions
+4
View File
@@ -2586,6 +2586,10 @@ class SharedComputeEnvironment(SimpleComputeEnvironment):
def working_directory(self):
return self.job_wrapper.working_directory
def env_config_directory(self):
"""Working directory (possibly as environment variable evaluation)."""
return "$_GALAXY_JOB_DIR"
def new_file_path(self):
return os.path.abspath(self.app.config.new_file_path)
+14 -1
View File
@@ -382,6 +382,16 @@ class PulsarJobRunner(AsynchronousJobRunner):
if os.path.exists(tool_script):
log.debug("Registering tool_script for Pulsar transfer [%s]" % tool_script)
job_directory_files.append(tool_script)
# Following is job destination environment variables
env = client.env
# extend it with tool defined environment variables
tool_envs = job_wrapper.environment_variables
env.extend(tool_envs)
for tool_env in tool_envs:
job_directory_path = tool_env.get("job_directory_path")
if job_directory_path:
config_files.append(job_directory_path)
client_job_description = ClientJobDescription(
command_line=command_line,
input_files=input_files,
@@ -392,7 +402,7 @@ class PulsarJobRunner(AsynchronousJobRunner):
tool=job_wrapper.tool,
config_files=config_files,
dependencies_description=dependencies_description,
env=client.env,
env=env,
rewrite_paths=rewrite_paths,
arbitrary_files=path_rewrites_unstructured,
touch_outputs=output_names,
@@ -1056,6 +1066,9 @@ class PulsarComputeEnvironment(ComputeEnvironment):
def working_directory(self):
return self._working_directory
def env_config_directory(self):
return self.config_directory()
def config_directory(self):
return self._config_directory
+3 -2
View File
@@ -540,13 +540,14 @@ class ToolEvaluator:
is_template = False
else:
is_template = True
with tempfile.NamedTemporaryFile(dir=directory, delete=False) as temp:
with tempfile.NamedTemporaryFile(dir=directory, prefix="tool_env_", delete=False) as temp:
config_filename = temp.name
self.__write_workdir_file(config_filename, environment_variable_template, param_dict, is_template=is_template, strip=environment_variable_def.get("strip", False))
config_file_basename = os.path.basename(config_filename)
# environment setup in job file template happens before `cd $working_directory`
environment_variable["value"] = '`cat "$_GALAXY_JOB_DIR/%s"`' % config_file_basename
environment_variable["value"] = '`cat "%s/%s"`' % (self.compute_environment.env_config_directory(), config_file_basename)
environment_variable["raw"] = True
environment_variable["job_directory_path"] = config_filename
environment_variables.append(environment_variable)
home_dir = self.compute_environment.home_directory()
+1
View File
@@ -25,4 +25,5 @@ test_tools = integration_util.integration_tool_runner([
"multi_data_param",
"output_filter",
"vcf_bgzip_test",
"environment_variables",
])