Commit c25cb04
refactor: streamline geojson handling by centralizing file reading logic (#1336)
* refactor: streamline geojson handling by centralizing file reading logic
Updated the handling of GeoJSON inputs across multiple files to utilize the new `geojson_to_gdf` function. This change improves code consistency and simplifies the process of reading GeoJSON data from both local files and URLs. Adjustments made in `common.py`, `foliumap.py`, `leafmap.py`, and `maplibregl.py` to replace direct calls to `gpd.read_file` with the new function.
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* chore: update Python version in CI workflows to 3.13
Updated the Python version in multiple GitHub Actions workflows to 3.13, ensuring compatibility with the latest features and improvements. Changes made in docs.yml, installation.yml, macos.yml, ubuntu.yml, and windows.yml.
* Address CodeRabbit review feedback
- Remove redundant HTTP/file branching at three call sites in maplibregl.py
(add_vector/add_geojson path, add_symbol, DateFilterWidget.__init__) since
geojson_to_gdf() now internally branches on http URLs vs local files
* Pin pyproj>=3.7 to fix Python 3.13 CI
- uv was resolving the transitive pyproj (via geopandas) to 3.6.1, which
has no cp313 wheel and fails to build from source (PROJ not found),
breaking the 3.13 installation workflows on Linux/macOS/Windows
- pyproj 3.7+ ships prebuilt cp313 wheels
* Scope pyproj>=3.7 pin to Python 3.13 only
- Unconditional pyproj>=3.7 conflicts with requires-python>=3.9 since
pyproj 3.7+ requires Python>=3.10, making resolution unsatisfiable for
3.9-3.12
- Add an environment marker so the pin only applies on Python 3.13, where
the missing cp313 wheel for pyproj 3.6.1 is the actual problem
* Fix Python 3.13 CI: run installed venv instead of re-resolving with uv run
The pyproj>=3.7 pin (reverted here) could not work: leafmap declares
requires-python>=3.9, and `uv run` resolves the whole version range at once
(universal resolution), so pyproj is forced to 3.6.1 (the only version that
supports 3.9) — which has no cp313 wheel and fails to build from source.
Instead, `uv pip install .` already resolves per-interpreter and correctly
installs pyproj 3.7.x (with a cp313 wheel) on Python 3.13. The failure was
only the subsequent `uv run` step re-resolving universally. Run the installed
.venv's python/pytest directly so no re-resolution happens.
- Remove pyproj pin from requirements.txt
- installation/macos/windows/ubuntu workflows: replace `uv run` in the
Test import and pytest steps with the .venv interpreter
* Keep uv run for ubuntu pytest workflow
Reverting ubuntu.yml to `uv run`: switching to the per-interpreter .venv
pulls in numpy>=2.1, which breaks map JSON serialization in the test suite
(29 tests fail with "ndarray is not JSON serializable"). The install-only
workflows (installation/macos/windows) keep the .venv fix since they only
do an import check and are unaffected.
* Fix numpy>=2.1 GeoJSON serialization, support Python 3.14, add 3.14 to CI
Root-cause fixes for the CI failures and Python 3.14 support:
- sanitize_geojson (common.py): recursively convert NumPy arrays/scalars in
GeoJSON to native Python types. Newer geopandas/numpy read list-valued
feature properties (e.g. a "coordinates" property) back as ndarrays, which
are not JSON serializable and broke ipyleaflet/folium widget serialization
("Object of type ndarray is not JSON serializable") across ~30 tests.
Applied in Map.add_geojson for both leafmap.py and foliumap.py.
- fit_bounds (leafmap.py): override ipyleaflet's fit_bounds to ensure an
asyncio event loop exists first. Python 3.14 no longer provides an implicit
current loop outside a running loop, so ipyleaflet's
asyncio.ensure_future(self._fit_bounds(...)) raised RuntimeError.
- Make fiona optional (leafmap.py, foliumap.py, common.py): fiona has no
Python 3.14 wheel. It was only used to register the KML driver; the default
pyogrio engine reads KML natively, so import it lazily and fall back.
- requirements_dev.txt: fiona only on Python < 3.14 (no cp314 wheel yet).
- CI: add Python 3.14 to the ubuntu/macOS/windows/installation matrices.
ubuntu.yml now runs the installed .venv interpreter for the import check and
pytest instead of `uv run`, which re-resolves universally under
requires-python>=3.9 and pins pyproj to 3.6.1 (no cp313/cp314 wheel).
Verified locally: full test suite (80 tests) passes on Python 3.14.
* Remove stray us_states.kml test artifact
* Use latest uv in CI so Python 3.14 can be installed
The pinned uv 0.4.16 predates Python 3.14 and has no download for it
("No download found for request: cpython-3.14-..."). Bump the setup-uv
version to "latest" in the workflows that test 3.14.
* Bump docs-build CI to Python 3.13
docs.yml already uses 3.13; align docs-build.yml (was 3.12).
* Fix docs CI on Python 3.13: run installed venv instead of uv run
Bumping docs-build to 3.13 exposed the same universal-resolution trap: `uv run`
re-resolves under requires-python>=3.9 and pins pyproj to 3.6.1, which has no
cp313 wheel and fails to build (proj not found). Use the installed .venv
interpreter for the import, pytest, and mkdocs steps in both docs.yml and
docs-build.yml.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent beeabc4 commit c25cb04
11 files changed
Lines changed: 140 additions & 54 deletions
File tree
- .github/workflows
- leafmap
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1516 | 1516 | | |
1517 | 1517 | | |
1518 | 1518 | | |
1519 | | - | |
1520 | 1519 | | |
1521 | 1520 | | |
1522 | | - | |
1523 | | - | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
1524 | 1528 | | |
1525 | 1529 | | |
1526 | 1530 | | |
| |||
1555 | 1559 | | |
1556 | 1560 | | |
1557 | 1561 | | |
1558 | | - | |
1559 | 1562 | | |
1560 | 1563 | | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
1564 | 1571 | | |
1565 | 1572 | | |
1566 | 1573 | | |
| |||
1693 | 1700 | | |
1694 | 1701 | | |
1695 | 1702 | | |
1696 | | - | |
1697 | 1703 | | |
1698 | 1704 | | |
1699 | 1705 | | |
| |||
1702 | 1708 | | |
1703 | 1709 | | |
1704 | 1710 | | |
1705 | | - | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
1706 | 1718 | | |
1707 | 1719 | | |
1708 | 1720 | | |
| |||
3950 | 3962 | | |
3951 | 3963 | | |
3952 | 3964 | | |
| 3965 | + | |
| 3966 | + | |
| 3967 | + | |
| 3968 | + | |
| 3969 | + | |
| 3970 | + | |
| 3971 | + | |
| 3972 | + | |
| 3973 | + | |
| 3974 | + | |
3953 | 3975 | | |
3954 | 3976 | | |
3955 | 3977 | | |
3956 | 3978 | | |
3957 | 3979 | | |
| 3980 | + | |
| 3981 | + | |
| 3982 | + | |
| 3983 | + | |
| 3984 | + | |
| 3985 | + | |
| 3986 | + | |
| 3987 | + | |
| 3988 | + | |
| 3989 | + | |
| 3990 | + | |
| 3991 | + | |
| 3992 | + | |
| 3993 | + | |
| 3994 | + | |
| 3995 | + | |
| 3996 | + | |
| 3997 | + | |
| 3998 | + | |
| 3999 | + | |
| 4000 | + | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
| 4005 | + | |
3958 | 4006 | | |
3959 | 4007 | | |
3960 | 4008 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2046 | 2046 | | |
2047 | 2047 | | |
2048 | 2048 | | |
2049 | | - | |
| 2049 | + | |
2050 | 2050 | | |
2051 | 2051 | | |
2052 | | - | |
| 2052 | + | |
2053 | 2053 | | |
2054 | 2054 | | |
2055 | 2055 | | |
| |||
2067 | 2067 | | |
2068 | 2068 | | |
2069 | 2069 | | |
2070 | | - | |
| 2070 | + | |
2071 | 2071 | | |
2072 | 2072 | | |
2073 | 2073 | | |
| |||
2411 | 2411 | | |
2412 | 2412 | | |
2413 | 2413 | | |
2414 | | - | |
2415 | 2414 | | |
2416 | 2415 | | |
2417 | 2416 | | |
2418 | | - | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
2419 | 2424 | | |
2420 | 2425 | | |
2421 | 2426 | | |
| |||
0 commit comments