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

DM-48159 : Make Coverage import optional #316

Merged
merged 3 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions doc/changes/DM-47159.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Makes coverage package optional and lazy-loads it only when needed.
Declares packaging extra for coverage, i.e., `pip install lsst-ctrl-mpexec[coverage]`.
Updates minimum supported Python to 3.11 (dependency-driven change).
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "lsst-ctrl-mpexec"
requires-python = ">=3.10.0"
requires-python = ">=3.11.0"
description = "Pipeline execution infrastructure for the Rubin Observatory LSST Science Pipelines."
license = {text = "BSD 3-Clause License"}
readme = "README.rst"
Expand All @@ -16,8 +16,9 @@ classifiers = [
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: Astronomy",
]
keywords = ["lsst"]
Expand All @@ -38,6 +39,7 @@ dynamic = ["version"]
"Homepage" = "https://github.com/lsst/ctrl_mpexec"

[project.optional-dependencies]
coverage = ["coverage"]
test = ["pytest >= 3.2"]

[tool.setuptools.packages.find]
Expand Down
6 changes: 5 additions & 1 deletion python/lsst/ctrl/mpexec/cli/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from typing import Any

import click
import coverage
import lsst.pipe.base.cli.opt as pipeBaseOpts
from lsst.ctrl.mpexec import Report
from lsst.ctrl.mpexec.showInfo import ShowInfo
Expand Down Expand Up @@ -145,6 +144,11 @@
if not kwargs.pop("coverage", False):
yield
return
# Lazily import coverage only when we might need it
try:
import coverage
except ModuleNotFoundError:
raise click.ClickException("coverage was requested but the coverage package is not installed.")

Check warning on line 151 in python/lsst/ctrl/mpexec/cli/cmd/commands.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/mpexec/cli/cmd/commands.py#L148-L151

Added lines #L148 - L151 were not covered by tests
with NamedTemporaryFile("w") as rcfile:
rcfile.write(
"""
Expand Down
4 changes: 3 additions & 1 deletion python/lsst/ctrl/mpexec/cli/opt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
"--debug", help="Enable debugging output using lsstDebug facility (imports debug.py).", is_flag=True
)

coverage_option = MWOptionDecorator("--coverage", help="Enable coverage output.", is_flag=True)
coverage_option = MWOptionDecorator(
"--coverage", help="Enable coverage output (requires coverage package).", is_flag=True
)

coverage_report_option = MWOptionDecorator(
"--cov-report/--no-cov-report",
Expand Down
Loading