From f7e43384a2fcd552fc8ab6dc10a5ff6264147493 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Fri, 1 May 2015 11:48:04 -0400 Subject: [PATCH] Ensure JobWrapper.galaxy_lib_dir is set, necessary for locally setting metadata externally with Pulsar, which (sometimes?) does not call the wrapper's prepare() method. --- lib/galaxy/jobs/__init__.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 9603588265f6..d41c2b84aaef 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -720,7 +720,7 @@ def __init__( self, job, queue, use_persisted_destination=False ): # Tool versioning variables self.write_version_cmd = None self.version_string = "" - self.galaxy_lib_dir = None + self.__galaxy_lib_dir = None # With job outputs in the working directory, we need the working # directory to be set before prepare is run, or else premature deletion # and job recovery fail. @@ -769,6 +769,12 @@ def get_parallelism(self): def commands_in_new_shell(self): return self.app.config.commands_in_new_shell + @property + def galaxy_lib_dir(self): + if self.__galaxy_lib_dir is None: + self.__galaxy_lib_dir = os.path.abspath( "lib" ) # cwd = galaxy root + return self.__galaxy_lib_dir + # legacy naming get_job_runner = get_job_runner_url @@ -830,8 +836,8 @@ def get_special( ): self.sa_session.flush() self.command_line, self.extra_filenames = tool_evaluator.build() - # FIXME: for now, tools get Galaxy's lib dir in their path - self.galaxy_lib_dir = os.path.abspath( "lib" ) # cwd = galaxy root + # Ensure galaxy_lib_dir is set in case there are any later chdirs + self.galaxy_lib_dir # Shell fragment to inject dependencies self.dependency_shell_commands = self.tool.build_dependency_shell_commands() # We need command_line persisted to the db in order for Galaxy to re-queue the job @@ -1631,9 +1637,8 @@ def prepare( self, compute_environment=None ): self.command_line, self.extra_filenames = tool_evaluator.build() - # FIXME: for now, tools get Galaxy's lib dir in their path - if self.command_line and self.command_line.startswith( 'python' ): - self.galaxy_lib_dir = os.path.abspath( "lib" ) # cwd = galaxy root + # Ensure galaxy_lib_dir is set in case there are any later chdirs + self.galaxy_lib_dir # Shell fragment to inject dependencies self.dependency_shell_commands = self.tool.build_dependency_shell_commands() # We need command_line persisted to the db in order for Galaxy to re-queue the job