From 9cdf4bcad7b720c90ba25b5450f1c9f4cbf67c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Tue, 12 Apr 2022 12:14:41 +0200 Subject: [PATCH 1/8] remove md5sum for versions.yml file --- nf_core/modules/test_yml_builder.py | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/nf_core/modules/test_yml_builder.py b/nf_core/modules/test_yml_builder.py index d210cf350e..3a525dfbaf 100644 --- a/nf_core/modules/test_yml_builder.py +++ b/nf_core/modules/test_yml_builder.py @@ -227,20 +227,22 @@ def create_test_file_dict(self, results_dir, is_repeat=False): test_files = [] for root, dir, file in os.walk(results_dir): for elem in file: - elem = os.path.join(root, elem) - test_file = {"path": elem} # add the key here so that it comes first in the dict - # Check that this isn't an empty file - if self.check_if_empty_file(elem): - if not is_repeat: - self.errors.append(f"Empty file found! '{os.path.basename(elem)}'") - # Add the md5 anyway, linting should fail later and can be manually removed if needed. - # Originally we skipped this if empty, but then it's too easy to miss the warning. - # Equally, if a file is legitimately empty we don't want to prevent this from working. - elem_md5 = self._md5(elem) - test_file["md5sum"] = elem_md5 - # Switch out the results directory path with the expected 'output' directory - test_file["path"] = elem.replace(results_dir, "output") - test_files.append(test_file) + # Check that the file is not versions.yml + if elem != "versions.yml": + elem = os.path.join(root, elem) + test_file = {"path": elem} # add the key here so that it comes first in the dict + # Check that this isn't an empty file + if self.check_if_empty_file(elem): + if not is_repeat: + self.errors.append(f"Empty file found! '{os.path.basename(elem)}'") + # Add the md5 anyway, linting should fail later and can be manually removed if needed. + # Originally we skipped this if empty, but then it's too easy to miss the warning. + # Equally, if a file is legitimately empty we don't want to prevent this from working. + elem_md5 = self._md5(elem) + test_file["md5sum"] = elem_md5 + # Switch out the results directory path with the expected 'output' directory + test_file["path"] = elem.replace(results_dir, "output") + test_files.append(test_file) test_files = sorted(test_files, key=operator.itemgetter("path")) From 10fe141f2530d55f2cd75cf3cd3c53f9718c1f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Tue, 12 Apr 2022 12:36:21 +0200 Subject: [PATCH 2/8] modify changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 399db4dc61..652fcd5db3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Very minor patch release to fix the full size AWS tests and re-run the template - Remove traces of markdownlint in the template ([#1486](https://github.com/nf-core/tools/pull/1486) - Remove accidentally added line in `CHANGELOG.md` in the template ([#1487](https://github.com/nf-core/tools/pull/1487)) - Update linting to check that `.editorconfig` is there and `.yamllint.yml` isn't. +- Remove md5sum for versions.yml ## [v2.3.1 - Mercury Vulture Formatting](https://github.com/nf-core/tools/releases/tag/2.3.1) - [2022-03-23] From cd78ef9bd2c7e2fde4f9b1a4a0571a7ea787f24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Wed, 13 Apr 2022 12:51:26 +0200 Subject: [PATCH 3/8] Update CHANGELOG.md Co-authored-by: Phil Ewels --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 652fcd5db3..65c59935e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ Very minor patch release to fix the full size AWS tests and re-run the template - Remove traces of markdownlint in the template ([#1486](https://github.com/nf-core/tools/pull/1486) - Remove accidentally added line in `CHANGELOG.md` in the template ([#1487](https://github.com/nf-core/tools/pull/1487)) - Update linting to check that `.editorconfig` is there and `.yamllint.yml` isn't. -- Remove md5sum for versions.yml +- Don't save md5sum for `versions.yml` when running `nf-core modules create-test-yml` ([#1511](https://github.com/nf-core/tools/pull/1511)) ## [v2.3.1 - Mercury Vulture Formatting](https://github.com/nf-core/tools/releases/tag/2.3.1) - [2022-03-23] From 708c8075bc23e3efcd40844bb24e851f11271383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Wed, 13 Apr 2022 14:02:23 +0200 Subject: [PATCH 4/8] Use continue in if statement Co-authored-by: Phil Ewels --- nf_core/modules/test_yml_builder.py | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/nf_core/modules/test_yml_builder.py b/nf_core/modules/test_yml_builder.py index 3a525dfbaf..5ece0da97e 100644 --- a/nf_core/modules/test_yml_builder.py +++ b/nf_core/modules/test_yml_builder.py @@ -228,21 +228,23 @@ def create_test_file_dict(self, results_dir, is_repeat=False): for root, dir, file in os.walk(results_dir): for elem in file: # Check that the file is not versions.yml - if elem != "versions.yml": - elem = os.path.join(root, elem) - test_file = {"path": elem} # add the key here so that it comes first in the dict - # Check that this isn't an empty file - if self.check_if_empty_file(elem): - if not is_repeat: - self.errors.append(f"Empty file found! '{os.path.basename(elem)}'") - # Add the md5 anyway, linting should fail later and can be manually removed if needed. - # Originally we skipped this if empty, but then it's too easy to miss the warning. - # Equally, if a file is legitimately empty we don't want to prevent this from working. - elem_md5 = self._md5(elem) - test_file["md5sum"] = elem_md5 - # Switch out the results directory path with the expected 'output' directory - test_file["path"] = elem.replace(results_dir, "output") - test_files.append(test_file) + if elem = "versions.yml": + continue + + elem = os.path.join(root, elem) + test_file = {"path": elem} # add the key here so that it comes first in the dict + # Check that this isn't an empty file + if self.check_if_empty_file(elem): + if not is_repeat: + self.errors.append(f"Empty file found! '{os.path.basename(elem)}'") + # Add the md5 anyway, linting should fail later and can be manually removed if needed. + # Originally we skipped this if empty, but then it's too easy to miss the warning. + # Equally, if a file is legitimately empty we don't want to prevent this from working. + elem_md5 = self._md5(elem) + test_file["md5sum"] = elem_md5 + # Switch out the results directory path with the expected 'output' directory + test_file["path"] = elem.replace(results_dir, "output") + test_files.append(test_file) test_files = sorted(test_files, key=operator.itemgetter("path")) From 6d4b103035b5f533b8b8bf7a74326dd8b7fa2074 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Wed, 13 Apr 2022 14:11:24 +0200 Subject: [PATCH 5/8] Update nf_core/modules/test_yml_builder.py --- nf_core/modules/test_yml_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/modules/test_yml_builder.py b/nf_core/modules/test_yml_builder.py index 5ece0da97e..2935e99f21 100644 --- a/nf_core/modules/test_yml_builder.py +++ b/nf_core/modules/test_yml_builder.py @@ -228,7 +228,7 @@ def create_test_file_dict(self, results_dir, is_repeat=False): for root, dir, file in os.walk(results_dir): for elem in file: # Check that the file is not versions.yml - if elem = "versions.yml": + if elem == "versions.yml": continue elem = os.path.join(root, elem) From a8baf994f855dfdcc25c9f965175ad5d1c1bf453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Wed, 13 Apr 2022 14:17:25 +0200 Subject: [PATCH 6/8] apply refactoring from review suggestions --- nf_core/modules/test_yml_builder.py | 74 ++++++++++++++++++----------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/nf_core/modules/test_yml_builder.py b/nf_core/modules/test_yml_builder.py index 5ece0da97e..cf4d5ff1bd 100644 --- a/nf_core/modules/test_yml_builder.py +++ b/nf_core/modules/test_yml_builder.py @@ -76,13 +76,16 @@ def check_inputs(self): style=nf_core.utils.nfcore_question_style, ).ask() self.module_dir = os.path.join("modules", *self.module_name.split("/")) - self.module_test_main = os.path.join("tests", "modules", *self.module_name.split("/"), "main.nf") + self.module_test_main = os.path.join( + "tests", "modules", *self.module_name.split("/"), "main.nf") # First, sanity check that the module directory exists if not os.path.isdir(self.module_dir): - raise UserWarning(f"Cannot find directory '{self.module_dir}'. Should be TOOL/SUBTOOL or TOOL") + raise UserWarning( + f"Cannot find directory '{self.module_dir}'. Should be TOOL/SUBTOOL or TOOL") if not os.path.exists(self.module_test_main): - raise UserWarning(f"Cannot find module test workflow '{self.module_test_main}'") + raise UserWarning( + f"Cannot find module test workflow '{self.module_test_main}'") # Check that we're running tests if no prompts if not self.run_tests and self.no_prompts: @@ -120,14 +123,16 @@ def check_inputs(self): def scrape_workflow_entry_points(self): """Find the test workflow entry points from main.nf""" - log.info(f"Looking for test workflow entry points: '{self.module_test_main}'") + log.info( + f"Looking for test workflow entry points: '{self.module_test_main}'") with open(self.module_test_main, "r") as fh: for line in fh: match = re.match(r"workflow\s+(\S+)\s+{", line) if match: self.entry_points.append(match.group(1)) if len(self.entry_points) == 0: - raise UserWarning("No workflow entry points found in 'self.module_test_main'") + raise UserWarning( + "No workflow entry points found in 'self.module_test_main'") def build_all_tests(self): """ @@ -161,7 +166,8 @@ def build_single_test(self, entry_point): if self.no_prompts: ep_test["name"] = default_val else: - ep_test["name"] = rich.prompt.Prompt.ask("[violet]Test name", default=default_val).strip() + ep_test["name"] = rich.prompt.Prompt.ask( + "[violet]Test name", default=default_val).strip() while ep_test["command"] == "": default_val = ( @@ -170,7 +176,8 @@ def build_single_test(self, entry_point): if self.no_prompts: ep_test["command"] = default_val else: - ep_test["command"] = rich.prompt.Prompt.ask("[violet]Test command", default=default_val).strip() + ep_test["command"] = rich.prompt.Prompt.ask( + "[violet]Test command", default=default_val).strip() while len(ep_test["tags"]) == 0: mod_name_parts = self.module_name.split("/") @@ -186,7 +193,8 @@ def build_single_test(self, entry_point): prompt_tags = rich.prompt.Prompt.ask( "[violet]Test tags[/] (comma separated)", default=",".join(tag_defaults) ).strip() - ep_test["tags"] = [t.strip() for t in prompt_tags.split(",")] + ep_test["tags"] = [t.strip() + for t in prompt_tags.split(",")] ep_test["files"] = self.get_md5_sums(entry_point, ep_test["command"]) @@ -225,25 +233,26 @@ def _md5(self, fname): def create_test_file_dict(self, results_dir, is_repeat=False): """Walk through directory and collect md5 sums""" test_files = [] - for root, dir, file in os.walk(results_dir): - for elem in file: + for root, dir, files in os.walk(results_dir): + for filename in files: # Check that the file is not versions.yml - if elem = "versions.yml": + if filename == "versions.yml": continue - - elem = os.path.join(root, elem) - test_file = {"path": elem} # add the key here so that it comes first in the dict + file_path = os.path.join(root, filename) + # add the key here so that it comes first in the dict + test_file = {"path": file_path} # Check that this isn't an empty file - if self.check_if_empty_file(elem): + if self.check_if_empty_file(file_path): if not is_repeat: - self.errors.append(f"Empty file found! '{os.path.basename(elem)}'") + self.errors.append( + f"Empty file found! '{os.path.basename(file_path)}'") # Add the md5 anyway, linting should fail later and can be manually removed if needed. # Originally we skipped this if empty, but then it's too easy to miss the warning. # Equally, if a file is legitimately empty we don't want to prevent this from working. - elem_md5 = self._md5(elem) - test_file["md5sum"] = elem_md5 + file_md5 = self._md5(file_path) + test_file["md5sum"] = file_md5 # Switch out the results directory path with the expected 'output' directory - test_file["path"] = elem.replace(results_dir, "output") + test_file["path"] = file_path.replace(results_dir, "output") test_files.append(test_file) test_files = sorted(test_files, key=operator.itemgetter("path")) @@ -260,7 +269,8 @@ def get_md5_sums(self, entry_point, command, results_dir=None, results_dir_repea run_this_test = False while results_dir is None: if self.run_tests or run_this_test: - results_dir, results_dir_repeat = self.run_tests_workflow(command) + results_dir, results_dir_repeat = self.run_tests_workflow( + command) else: results_dir = rich.prompt.Prompt.ask( f"[violet]Test output folder with results[/] (leave blank to run test)" @@ -276,7 +286,8 @@ def get_md5_sums(self, entry_point, command, results_dir=None, results_dir_repea # If test was repeated, compare the md5 sums if results_dir_repeat: - test_files_repeat = self.create_test_file_dict(results_dir=results_dir_repeat, is_repeat=True) + test_files_repeat = self.create_test_file_dict( + results_dir=results_dir_repeat, is_repeat=True) # Compare both test.yml files for i in range(len(test_files)): @@ -287,7 +298,8 @@ def get_md5_sums(self, entry_point, command, results_dir=None, results_dir_repea ] = "[ # TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ]" if len(test_files) == 0: - raise UserWarning(f"Could not find any test result files in '{results_dir}'") + raise UserWarning( + f"Could not find any test result files in '{results_dir}'") return test_files @@ -310,7 +322,8 @@ def run_tests_workflow(self, command): "message": "Choose software profile", "choices": ["Docker", "Singularity", "Conda"], } - answer = questionary.unsafe_prompt([question], style=nf_core.utils.nfcore_question_style) + answer = questionary.unsafe_prompt( + [question], style=nf_core.utils.nfcore_question_style) profile = answer["profile"].lower() if profile in ["singularity", "conda"]: os.environ["PROFILE"] = profile @@ -319,10 +332,12 @@ def run_tests_workflow(self, command): tmp_dir = tempfile.mkdtemp() tmp_dir_repeat = tempfile.mkdtemp() work_dir = tempfile.mkdtemp() - command_repeat = command + f" --outdir {tmp_dir_repeat} -work-dir {work_dir}" + command_repeat = command + \ + f" --outdir {tmp_dir_repeat} -work-dir {work_dir}" command += f" --outdir {tmp_dir} -work-dir {work_dir}" - log.info(f"Running '{self.module_name}' test with command:\n[violet]{command}") + log.info( + f"Running '{self.module_name}' test with command:\n[violet]{command}") try: nfconfig_raw = subprocess.check_output(shlex.split(command)) log.info(f"Repeating test ...") @@ -334,7 +349,8 @@ def run_tests_workflow(self, command): "It looks like Nextflow is not installed. It is required for most nf-core functions." ) except subprocess.CalledProcessError as e: - raise UserWarning(f"Error running test workflow (exit code {e.returncode})\n[red]{e.output.decode()}") + raise UserWarning( + f"Error running test workflow (exit code {e.returncode})\n[red]{e.output.decode()}") except Exception as e: raise UserWarning(f"Error running test workflow: {e}") else: @@ -350,13 +366,15 @@ def print_test_yml(self): if self.test_yml_output_path == "-": console = rich.console.Console() - yaml_str = yaml.dump(self.tests, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000) + yaml_str = yaml.dump( + self.tests, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000) console.print("\n", Syntax(yaml_str, "yaml"), "\n") return try: log.info(f"Writing to '{self.test_yml_output_path}'") with open(self.test_yml_output_path, "w") as fh: - yaml.dump(self.tests, fh, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000) + yaml.dump( + self.tests, fh, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000) except FileNotFoundError as e: raise UserWarning("Could not create test.yml file: '{}'".format(e)) From 66d1e98e04d754cde73e00e753f7a05ea71ec9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Wed, 13 Apr 2022 15:31:29 +0200 Subject: [PATCH 7/8] fix linting --- nf_core/modules/test_yml_builder.py | 56 ++++++++++------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/nf_core/modules/test_yml_builder.py b/nf_core/modules/test_yml_builder.py index 00e1e9d1d0..0366397d8e 100644 --- a/nf_core/modules/test_yml_builder.py +++ b/nf_core/modules/test_yml_builder.py @@ -76,16 +76,13 @@ def check_inputs(self): style=nf_core.utils.nfcore_question_style, ).ask() self.module_dir = os.path.join("modules", *self.module_name.split("/")) - self.module_test_main = os.path.join( - "tests", "modules", *self.module_name.split("/"), "main.nf") + self.module_test_main = os.path.join("tests", "modules", *self.module_name.split("/"), "main.nf") # First, sanity check that the module directory exists if not os.path.isdir(self.module_dir): - raise UserWarning( - f"Cannot find directory '{self.module_dir}'. Should be TOOL/SUBTOOL or TOOL") + raise UserWarning(f"Cannot find directory '{self.module_dir}'. Should be TOOL/SUBTOOL or TOOL") if not os.path.exists(self.module_test_main): - raise UserWarning( - f"Cannot find module test workflow '{self.module_test_main}'") + raise UserWarning(f"Cannot find module test workflow '{self.module_test_main}'") # Check that we're running tests if no prompts if not self.run_tests and self.no_prompts: @@ -123,16 +120,14 @@ def check_inputs(self): def scrape_workflow_entry_points(self): """Find the test workflow entry points from main.nf""" - log.info( - f"Looking for test workflow entry points: '{self.module_test_main}'") + log.info(f"Looking for test workflow entry points: '{self.module_test_main}'") with open(self.module_test_main, "r") as fh: for line in fh: match = re.match(r"workflow\s+(\S+)\s+{", line) if match: self.entry_points.append(match.group(1)) if len(self.entry_points) == 0: - raise UserWarning( - "No workflow entry points found in 'self.module_test_main'") + raise UserWarning("No workflow entry points found in 'self.module_test_main'") def build_all_tests(self): """ @@ -166,8 +161,7 @@ def build_single_test(self, entry_point): if self.no_prompts: ep_test["name"] = default_val else: - ep_test["name"] = rich.prompt.Prompt.ask( - "[violet]Test name", default=default_val).strip() + ep_test["name"] = rich.prompt.Prompt.ask("[violet]Test name", default=default_val).strip() while ep_test["command"] == "": default_val = ( @@ -176,8 +170,7 @@ def build_single_test(self, entry_point): if self.no_prompts: ep_test["command"] = default_val else: - ep_test["command"] = rich.prompt.Prompt.ask( - "[violet]Test command", default=default_val).strip() + ep_test["command"] = rich.prompt.Prompt.ask("[violet]Test command", default=default_val).strip() while len(ep_test["tags"]) == 0: mod_name_parts = self.module_name.split("/") @@ -193,8 +186,7 @@ def build_single_test(self, entry_point): prompt_tags = rich.prompt.Prompt.ask( "[violet]Test tags[/] (comma separated)", default=",".join(tag_defaults) ).strip() - ep_test["tags"] = [t.strip() - for t in prompt_tags.split(",")] + ep_test["tags"] = [t.strip() for t in prompt_tags.split(",")] ep_test["files"] = self.get_md5_sums(entry_point, ep_test["command"]) @@ -244,8 +236,7 @@ def create_test_file_dict(self, results_dir, is_repeat=False): # Check that this isn't an empty file if self.check_if_empty_file(file_path): if not is_repeat: - self.errors.append( - f"Empty file found! '{os.path.basename(file_path)}'") + self.errors.append(f"Empty file found! '{os.path.basename(file_path)}'") # Add the md5 anyway, linting should fail later and can be manually removed if needed. # Originally we skipped this if empty, but then it's too easy to miss the warning. # Equally, if a file is legitimately empty we don't want to prevent this from working. @@ -269,8 +260,7 @@ def get_md5_sums(self, entry_point, command, results_dir=None, results_dir_repea run_this_test = False while results_dir is None: if self.run_tests or run_this_test: - results_dir, results_dir_repeat = self.run_tests_workflow( - command) + results_dir, results_dir_repeat = self.run_tests_workflow(command) else: results_dir = rich.prompt.Prompt.ask( f"[violet]Test output folder with results[/] (leave blank to run test)" @@ -286,8 +276,7 @@ def get_md5_sums(self, entry_point, command, results_dir=None, results_dir_repea # If test was repeated, compare the md5 sums if results_dir_repeat: - test_files_repeat = self.create_test_file_dict( - results_dir=results_dir_repeat, is_repeat=True) + test_files_repeat = self.create_test_file_dict(results_dir=results_dir_repeat, is_repeat=True) # Compare both test.yml files for i in range(len(test_files)): @@ -298,8 +287,7 @@ def get_md5_sums(self, entry_point, command, results_dir=None, results_dir_repea ] = "[ # TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ]" if len(test_files) == 0: - raise UserWarning( - f"Could not find any test result files in '{results_dir}'") + raise UserWarning(f"Could not find any test result files in '{results_dir}'") return test_files @@ -322,8 +310,7 @@ def run_tests_workflow(self, command): "message": "Choose software profile", "choices": ["Docker", "Singularity", "Conda"], } - answer = questionary.unsafe_prompt( - [question], style=nf_core.utils.nfcore_question_style) + answer = questionary.unsafe_prompt([question], style=nf_core.utils.nfcore_question_style) profile = answer["profile"].lower() if profile in ["singularity", "conda"]: os.environ["PROFILE"] = profile @@ -332,12 +319,10 @@ def run_tests_workflow(self, command): tmp_dir = tempfile.mkdtemp() tmp_dir_repeat = tempfile.mkdtemp() work_dir = tempfile.mkdtemp() - command_repeat = command + \ - f" --outdir {tmp_dir_repeat} -work-dir {work_dir}" + command_repeat = command + f" --outdir {tmp_dir_repeat} -work-dir {work_dir}" command += f" --outdir {tmp_dir} -work-dir {work_dir}" - log.info( - f"Running '{self.module_name}' test with command:\n[violet]{command}") + log.info(f"Running '{self.module_name}' test with command:\n[violet]{command}") try: nfconfig_raw = subprocess.check_output(shlex.split(command)) log.info(f"Repeating test ...") @@ -349,13 +334,12 @@ def run_tests_workflow(self, command): "It looks like Nextflow is not installed. It is required for most nf-core functions." ) except subprocess.CalledProcessError as e: - output = rich.markup.escape(e.output.decode()) - raise UserWarning(f"Error running test workflow (exit code {e.returncode})\n[red]{output}") + raise UserWarning(f"Error running test workflow (exit code {e.returncode})\n[red]{e.output.decode()}") except Exception as e: raise UserWarning(f"Error running test workflow: {e}") else: log.info("Test workflow finished!") - log.debug(rich.markup.escape(nfconfig_raw)) + log.debug(nfconfig_raw) return tmp_dir, tmp_dir_repeat @@ -366,15 +350,13 @@ def print_test_yml(self): if self.test_yml_output_path == "-": console = rich.console.Console() - yaml_str = yaml.dump( - self.tests, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000) + yaml_str = yaml.dump(self.tests, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000) console.print("\n", Syntax(yaml_str, "yaml"), "\n") return try: log.info(f"Writing to '{self.test_yml_output_path}'") with open(self.test_yml_output_path, "w") as fh: - yaml.dump( - self.tests, fh, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000) + yaml.dump(self.tests, fh, Dumper=nf_core.utils.custom_yaml_dumper(), width=10000000) except FileNotFoundError as e: raise UserWarning("Could not create test.yml file: '{}'".format(e)) From 7772e5a5c8524870eebd145caf8bae252187a7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Thu, 14 Apr 2022 11:24:14 +0200 Subject: [PATCH 8/8] restore deleted lines Co-authored-by: Phil Ewels --- nf_core/modules/test_yml_builder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nf_core/modules/test_yml_builder.py b/nf_core/modules/test_yml_builder.py index 0366397d8e..b10c64204c 100644 --- a/nf_core/modules/test_yml_builder.py +++ b/nf_core/modules/test_yml_builder.py @@ -334,12 +334,13 @@ def run_tests_workflow(self, command): "It looks like Nextflow is not installed. It is required for most nf-core functions." ) except subprocess.CalledProcessError as e: - raise UserWarning(f"Error running test workflow (exit code {e.returncode})\n[red]{e.output.decode()}") + output = rich.markup.escape(e.output.decode()) + raise UserWarning(f"Error running test workflow (exit code {e.returncode})\n[red]{output}") except Exception as e: raise UserWarning(f"Error running test workflow: {e}") else: log.info("Test workflow finished!") - log.debug(nfconfig_raw) + log.debug(rich.markup.escape(nfconfig_raw)) return tmp_dir, tmp_dir_repeat