Skip to content

Commit

Permalink
Merge pull request #1986 from mashehu/fix-launch-params-in
Browse files Browse the repository at this point in the history
Fix params-in functionality in `nf-core launch`
  • Loading branch information
mashehu authored Nov 2, 2022
2 parents 6bf8f30 + e0baf78 commit 53618a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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)

0 comments on commit 53618a5

Please sign in to comment.