Skip to content

Commit

Permalink
Merge pull request #17440 from mvdbeek/fix_it_templating
Browse files Browse the repository at this point in the history
[23.2] Build param dict before creating entrypoint
  • Loading branch information
nsoranzo authored Feb 13, 2024
2 parents 8884dfa + 9eebb60 commit f4229aa
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 14 deletions.
5 changes: 2 additions & 3 deletions lib/galaxy/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,15 +1249,13 @@ def get_special():

tool_evaluator = self._get_tool_evaluator(job)
compute_environment = compute_environment or self.default_compute_environment(job)
if hasattr(self.app, "interactivetool_manager"):
self.interactivetools = tool_evaluator.populate_interactivetools()
self.app.interactivetool_manager.create_interactivetool(job, self.tool, self.interactivetools)
tool_evaluator.set_compute_environment(compute_environment, get_special=get_special)
(
self.command_line,
self.version_command_line,
self.extra_filenames,
self.environment_variables,
self.interactivetools,
) = tool_evaluator.build()
job.command_line = self.command_line

Expand Down Expand Up @@ -2623,6 +2621,7 @@ def prepare(self, compute_environment=None):
self.version_command_line,
extra_filenames,
self.environment_variables,
*_,
) = tool_evaluator.build()
self.extra_filenames.extend(extra_filenames)

Expand Down
35 changes: 31 additions & 4 deletions lib/galaxy/tools/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(self, app: MinimalToolApp, tool, job, local_working_directory):
self.environment_variables: List[Dict[str, str]] = []
self.version_command_line: Optional[str] = None
self.command_line: Optional[str] = None
self.interactivetools: List[Dict[str, Any]] = []

def set_compute_environment(self, compute_environment: ComputeEnvironment, get_special: Optional[Callable] = None):
"""
Expand Down Expand Up @@ -514,7 +515,12 @@ def rewrite_unstructured_paths(input_values, input):
# the paths rewritten.
self.__walk_inputs(self.tool.inputs, param_dict, rewrite_unstructured_paths)

def populate_interactivetools(self):
def _create_interactivetools_entry_points(self):
if hasattr(self.app, "interactivetool_manager"):
self.interactivetools = self._populate_interactivetools_template()
self.app.interactivetool_manager.create_interactivetool(self.job, self.tool, self.interactivetools)

def _populate_interactivetools_template(self):
"""
Populate InteractiveTools templated values.
"""
Expand Down Expand Up @@ -571,12 +577,21 @@ def build(self):
compute environment.
"""
config_file = self.tool.config_file
global_tool_logs(
self._create_interactivetools_entry_points, config_file, "Building Interactive Tool Entry Points"
)
global_tool_logs(self._build_config_files, config_file, "Building Config Files")
global_tool_logs(self._build_param_file, config_file, "Building Param File")
global_tool_logs(self._build_command_line, config_file, "Building Command Line")
global_tool_logs(self._build_version_command, config_file, "Building Version Command Line")
global_tool_logs(self._build_environment_variables, config_file, "Building Environment Variables")
return self.command_line, self.version_command_line, self.extra_filenames, self.environment_variables
return (
self.command_line,
self.version_command_line,
self.extra_filenames,
self.environment_variables,
self.interactivetools,
)

def _build_command_line(self):
"""
Expand Down Expand Up @@ -823,7 +838,13 @@ class PartialToolEvaluator(ToolEvaluator):
def build(self):
config_file = self.tool.config_file
global_tool_logs(self._build_environment_variables, config_file, "Building Environment Variables")
return self.command_line, self.version_command_line, self.extra_filenames, self.environment_variables
return (
self.command_line,
self.version_command_line,
self.extra_filenames,
self.environment_variables,
self.interactivetools,
)


class RemoteToolEvaluator(ToolEvaluator):
Expand All @@ -841,4 +862,10 @@ def build(self):
global_tool_logs(self._build_param_file, config_file, "Building Param File")
global_tool_logs(self._build_command_line, config_file, "Building Command Line")
global_tool_logs(self._build_version_command, config_file, "Building Version Command Line")
return self.command_line, self.version_command_line, self.extra_filenames, self.environment_variables
return (
self.command_line,
self.version_command_line,
self.extra_filenames,
self.environment_variables,
self.interactivetools,
)
2 changes: 1 addition & 1 deletion lib/galaxy/tools/remote_tool_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def main(TMPDIR, WORKING_DIRECTORY, IMPORT_STORE_DIRECTORY):
)
tool_evaluator.set_compute_environment(compute_environment=SharedComputeEnvironment(job_io=job_io, job=job_io.job))
with open(os.path.join(WORKING_DIRECTORY, "tool_script.sh"), "a") as out:
command_line, version_command_line, extra_filenames, environment_variables = tool_evaluator.build()
command_line, version_command_line, extra_filenames, environment_variables, *_ = tool_evaluator.build()
out.write(f'{version_command_line or ""}{command_line}')


Expand Down
2 changes: 1 addition & 1 deletion test/functional/tools/interactivetool_simple.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<container type="docker">galaxy/test-http-example:0.1</container>
</requirements>
<entry_points>
<entry_point name="Simple" requires_domain="True">
<entry_point name="Simple IT for $__user_email__" requires_domain="True">
<port>7000</port>
<url>/</url>
</entry_point>
Expand Down
5 changes: 1 addition & 4 deletions test/unit/app/jobs/test_job_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,11 @@ def __init__(self, app, tool, job, local_working_directory):
self.local_working_directory = local_working_directory
self.param_dict = {}

def populate_interactivetools(self):
return []

def set_compute_environment(self, *args, **kwds):
pass

def build(self):
return TEST_COMMAND, "", [], []
return TEST_COMMAND, "", [], [], []


class MockJobQueue:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/app/tools/test_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_configfiles_evaluation(self):
self.tool.config_files.append(("conf1", None, "$thresh"))
self.tool._command_line = "prog1 $conf1"
self._set_compute_environment()
command_line, _, extra_filenames, _ = self.evaluator.build()
command_line, _, extra_filenames, *_ = self.evaluator.build()
assert len(extra_filenames) == 1
config_filename = extra_filenames[0]
config_basename = os.path.basename(config_filename)
Expand Down

0 comments on commit f4229aa

Please sign in to comment.