From fec4a2df5db072b33fb473e49561dde012b7cd29 Mon Sep 17 00:00:00 2001 From: mashehu <mashehu3@gmail.com> Date: Mon, 31 Oct 2022 11:48:53 +0100 Subject: [PATCH 1/3] fix name collision if input name is provided, add default value to run command at the end of launch --- nf_core/launch.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/nf_core/launch.py b/nf_core/launch.py index d57d9f112f..2287ae76f1 100644 --- a/nf_core/launch.py +++ b/nf_core/launch.py @@ -120,13 +120,19 @@ def launch_pipeline(self): # Check if the output file exists already if os.path.exists(self.params_out): - log.warning(f"Parameter output file already exists! {os.path.relpath(self.params_out)}") - if Confirm.ask("[yellow]Do you want to overwrite this file?"): - os.remove(self.params_out) - log.info(f"Deleted {self.params_out}\n") + # if params_in has the same name as params_out, don't ask to overwrite + if self.params_in and os.path.abspath(self.params_in) == os.path.abspath(self.params_out): + log.warning( + f"The parameter input file has the same name as the output file! {os.path.relpath(self.params_out)} will be overwritten." + ) else: - log.info("Exiting. Use --params-out to specify a custom filename.") - return False + log.warning(f"Parameter output file already exists! {os.path.relpath(self.params_out)}") + if Confirm.ask("[yellow]Do you want to overwrite this file?"): + os.remove(self.params_out) + log.info(f"Deleted {self.params_out}\n") + else: + log.info("Exiting. Use --params-out to specify a custom filename.") + return False log.info( "NOTE: This tool ignores any pipeline parameter defaults overwritten by Nextflow config files or profiles\n" @@ -716,6 +722,6 @@ def launch_workflow(self): """Launch nextflow if required""" log.info(f"[bold underline]Nextflow command:[/]\n[magenta]{self.nextflow_cmd}\n\n") - if Confirm.ask("Do you want to run this command now? "): + if Confirm.ask("Do you want to run this command now? ", default=True): log.info("Launching workflow! :rocket:") subprocess.call(self.nextflow_cmd, shell=True) From eff0721fd5535ee666214e31d36e8dd71f68cf10 Mon Sep 17 00:00:00 2001 From: mashehu <mashehu3@gmail.com> Date: Mon, 31 Oct 2022 11:50:57 +0100 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e51660e52c..61ca21ffed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Mock biocontainers and anaconda api calls in modules and subworkflows tests [#1967](https://github.com/nf-core/tools/pull/1967) - Run tests with Python 3.11 ([#1970](https://github.com/nf-core/tools/pull/1970)) - Bump promoted Python version from 3.7 to 3.8 ([#1971](https://github.com/nf-core/tools/pull/1971)) +- Fix incorrect file deletion in `nf-core launch` when `--params_in` has the same name as `--params_out` ### Modules From e0baf780a077f1b7e3567d7bd9cf0ac3decdb510 Mon Sep 17 00:00:00 2001 From: mashehu <mashehu3@gmail.com> Date: Mon, 31 Oct 2022 11:57:19 +0100 Subject: [PATCH 3/3] still ask before overwriting --- nf_core/launch.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nf_core/launch.py b/nf_core/launch.py index 2287ae76f1..53fce1f43f 100644 --- a/nf_core/launch.py +++ b/nf_core/launch.py @@ -127,12 +127,13 @@ def launch_pipeline(self): ) else: log.warning(f"Parameter output file already exists! {os.path.relpath(self.params_out)}") - if Confirm.ask("[yellow]Do you want to overwrite this file?"): + if Confirm.ask("[yellow]Do you want to overwrite this file?"): + if not (self.params_in and os.path.abspath(self.params_in) == os.path.abspath(self.params_out)): os.remove(self.params_out) log.info(f"Deleted {self.params_out}\n") - else: - log.info("Exiting. Use --params-out to specify a custom filename.") - return False + else: + log.info("Exiting. Use --params-out to specify a custom output filename.") + return False log.info( "NOTE: This tool ignores any pipeline parameter defaults overwritten by Nextflow config files or profiles\n"