Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix params-in functionality in nf-core launch #1986

Merged
merged 3 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 12 additions & 5 deletions nf_core/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +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 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.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 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.")
log.info("Exiting. Use --params-out to specify a custom output filename.")
return False

log.info(
Expand Down Expand Up @@ -716,6 +723,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)