From 880977943eaea770d36cb0997b7bea062ebf4849 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Sat, 10 Feb 2024 12:14:59 +0100 Subject: [PATCH 1/3] Add templating to test IT --- test/functional/tools/interactivetool_simple.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/tools/interactivetool_simple.xml b/test/functional/tools/interactivetool_simple.xml index 63e4c4b410ea..8919ec251d29 100644 --- a/test/functional/tools/interactivetool_simple.xml +++ b/test/functional/tools/interactivetool_simple.xml @@ -3,7 +3,7 @@ galaxy/test-http-example:0.1 - + 7000 / From 3aa84429e078ae2530eb848b502821df8d34c77a Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 8 Feb 2024 11:42:43 +0100 Subject: [PATCH 2/3] Build param dict before creating entrypoint Fixes https://github.com/galaxyproject/galaxy/issues/17438. --- lib/galaxy/jobs/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 91a0ed792be1..fcce9e0b738e 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -1249,9 +1249,6 @@ 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, @@ -1260,6 +1257,9 @@ def get_special(): self.environment_variables, ) = tool_evaluator.build() job.command_line = self.command_line + if hasattr(self.app, "interactivetool_manager"): + self.interactivetools = tool_evaluator.populate_interactivetools() + self.app.interactivetool_manager.create_interactivetool(job, self.tool, self.interactivetools) # Ensure galaxy_lib_dir is set in case there are any later chdirs self.galaxy_lib_dir # noqa: B018 From 9eebb606477bfc217354a9d3aa947d9e3d427db5 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Sat, 10 Feb 2024 12:10:28 +0100 Subject: [PATCH 3/3] Sandwich IT entry point creating after param_dict building and env var creation --- lib/galaxy/jobs/__init__.py | 5 ++-- lib/galaxy/tools/evaluation.py | 35 +++++++++++++++++++++++--- lib/galaxy/tools/remote_tool_eval.py | 2 +- test/unit/app/jobs/test_job_wrapper.py | 5 +--- test/unit/app/tools/test_evaluation.py | 2 +- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index fcce9e0b738e..3329c98253c5 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -1255,11 +1255,9 @@ def get_special(): self.version_command_line, self.extra_filenames, self.environment_variables, + self.interactivetools, ) = tool_evaluator.build() job.command_line = self.command_line - if hasattr(self.app, "interactivetool_manager"): - self.interactivetools = tool_evaluator.populate_interactivetools() - self.app.interactivetool_manager.create_interactivetool(job, self.tool, self.interactivetools) # Ensure galaxy_lib_dir is set in case there are any later chdirs self.galaxy_lib_dir # noqa: B018 @@ -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) diff --git a/lib/galaxy/tools/evaluation.py b/lib/galaxy/tools/evaluation.py index d06af3b01d53..9e4a8964a4c3 100644 --- a/lib/galaxy/tools/evaluation.py +++ b/lib/galaxy/tools/evaluation.py @@ -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): """ @@ -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. """ @@ -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): """ @@ -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): @@ -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, + ) diff --git a/lib/galaxy/tools/remote_tool_eval.py b/lib/galaxy/tools/remote_tool_eval.py index e69ce53899af..b07c6cf6a875 100644 --- a/lib/galaxy/tools/remote_tool_eval.py +++ b/lib/galaxy/tools/remote_tool_eval.py @@ -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}') diff --git a/test/unit/app/jobs/test_job_wrapper.py b/test/unit/app/jobs/test_job_wrapper.py index 40862720e24a..6c914c3efafa 100644 --- a/test/unit/app/jobs/test_job_wrapper.py +++ b/test/unit/app/jobs/test_job_wrapper.py @@ -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: diff --git a/test/unit/app/tools/test_evaluation.py b/test/unit/app/tools/test_evaluation.py index 24473b5d7fcf..06e0e2380e19 100644 --- a/test/unit/app/tools/test_evaluation.py +++ b/test/unit/app/tools/test_evaluation.py @@ -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)