Skip to content

Commit

Permalink
Don't sys.exit from run() function (#2055)
Browse files Browse the repository at this point in the history
* Don't sys.exit from run() function

* Replace two other sys.exit() calls in multiqc.run()

* Changelog

---------

Co-authored-by: vladsaveliev <vladislav.savelyev@populationgenomics.org.au>
  • Loading branch information
ewels and vladsavelyev committed Sep 21, 2023
1 parent 5f21841 commit bf7d471
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This idea goes way back to [issue #290](https://github.com/ewels/MultiQC/issues/
- Fixed parsing of `plot_type: "html"` `data` in json custom content
- Replace deprecated `pkg_resources`
- [Fix](https://github.com/ewels/MultiQC/issues/2032) the module groups configuration for modules where the namespace is passed explicitly to `general_stats_addcols`. Namespace is now always appended to the module name in the general stats ([2037](https://github.com/ewels/MultiQC/pull/2037)).
- Do not call `sys.exit()` in the `multiqc.run()` function, to avoid breaking interactive environments. [#2055](https://github.com/ewels/MultiQC/pull/2055)

### New Modules

Expand Down
6 changes: 3 additions & 3 deletions multiqc/multiqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def run(
run_modules = [m for m in run_modules if list(m.keys())[0] not in config.exclude_modules]
if len(run_modules) == 0:
logger.critical("No analysis modules specified!")
sys.exit(1)
return {"report": report, "config": config, "sys_exit_code": 1}
run_module_names = [list(m.keys())[0] for m in run_modules]
logger.debug("Analysing modules: {}".format(", ".join(run_module_names)))

Expand Down Expand Up @@ -773,7 +773,7 @@ def __rich_measure__(self, console: rich.console.Console, options: rich.console.
shutil.rmtree(tmp_dir)
logger.info("MultiQC complete")
# Exit with an error code if a module broke
sys.exit(sys_exit_code)
return {"report": report, "config": config, "sys_exit_code": sys_exit_code}

if config.make_report:
# Sort the report module output if we have a config
Expand Down Expand Up @@ -981,7 +981,7 @@ def __rich_measure__(self, console: rich.console.Console, options: rich.console.
logger.error("Output directory {} already exists.".format(config.plots_dir))
logger.info("Use -f or --force to overwrite existing reports")
shutil.rmtree(tmp_dir)
sys.exit(1)
return {"report": report, "config": config, "sys_exit_code": 1}
logger.info(
"Plots : {}{}".format(
os.path.relpath(config.plots_dir),
Expand Down

0 comments on commit bf7d471

Please sign in to comment.