Skip to content

MNT: install contextily with the other optional requirements - #1179

Draft
ting-hong-shieh wants to merge 1 commit into
RocketPy-Team:developfrom
ting-hong-shieh:mnt/optional-requirements-contextily
Draft

MNT: install contextily with the other optional requirements#1179
ting-hong-shieh wants to merge 1 commit into
RocketPy-Team:developfrom
ting-hong-shieh:mnt/optional-requirements-contextily

Conversation

@ting-hong-shieh

Copy link
Copy Markdown

The gap

contextily is declared in the monte-carlo extra in pyproject.toml:

monte-carlo = [
    "imageio",
    "multiprocess>=0.70",
    "statsmodels",
    "prettytable",
    "contextily>=1.0.0; python_version < '3.14'",
]

but not in requirements-optional.txt, and that is what the documented setup installs:

install:
	$(PYTHON) -m pip install --upgrade pip
	pip install -r requirements.txt
	pip install -r requirements-optional.txt
	pip install -r requirements-tests.txt
	pip install -e .

tests/unit/simulation/test_monte_carlo_plots_background.py opens with pytest.importorskip("contextily"), so the whole file is skipped.

What it costs

Measured at 4263fa95d7fe6f63d9593f01e4ff7a088369e195, running the five steps of test_pytest.yaml in order with --cov-append:

Without contextily With it
plots/monte_carlo_plots.py 89 missed 36 missed
Project, non-slow 14,771 covered, 84.2757% 14,824 covered, 84.5781%

Codecov reports 84.57% for that commit, and 14,824 hits against 2,703 misses. The second row is the one that matches; the first is what a contributor following the Makefile sees.

Tests installs .[all], which does resolve the extra on Python 3.10, so CI is unaffected either way. What this fixes is a local run quietly disagreeing with CI by 53 statements, with a skip reason buried in -rs output as the only clue.

The change

One line, the same specifier as pyproject.toml, marker included:

contextily>=1.0.0; python_version < '3.14'

Verification

Before, in an environment built from the requirements files:

$ pytest tests/unit/simulation/test_monte_carlo_plots_background.py -q
SKIPPED [1] tests/unit/simulation/test_monte_carlo_plots_background.py:17: This test requires contextily to be installed
1 skipped in 0.03s

After installing it:

$ pytest tests/unit/simulation/test_monte_carlo_plots_background.py -q
18 passed, 16 warnings in 37.14s

Those 18 do reach the network — they call contextily.bounds2img against real tile providers rather than stubbing it. That is existing behavior and not changed here, but it is worth knowing that this makes the default local suite contact Esri, OpenStreetMap and CartoDB where it previously did not. Happy to close this instead if the team would rather those tests were stubbed first, or would rather keep them opt-in.

Found while re-measuring the baseline for #709; it is why the figures in my first comment there were 53 statements low.

contextily is declared in the monte-carlo extra in pyproject.toml but not
in requirements-optional.txt, and the Makefile's install target reads the
requirements files. test_monte_carlo_plots_background.py opens with
pytest.importorskip("contextily"), so anyone who sets up with `make
install` skips that file: 18 tests, and 53 statements that Codecov counts
as covered.

The workflow installs .[all], so CI already has it and is unaffected. What
this fixes is the local suite silently disagreeing with CI, with a skip
reason as the only clue.

Same specifier as pyproject.toml, including the 3.14 marker.
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.57%. Comparing base (4263fa9) to head (966cb8a).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1179   +/-   ##
========================================
  Coverage    84.57%   84.57%           
========================================
  Files          131      131           
  Lines        17527    17527           
========================================
  Hits         14824    14824           
  Misses        2703     2703           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ting-hong-shieh
ting-hong-shieh marked this pull request as draft August 16, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant