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

CI: Unpin geopandas in the Docs workflow and manually register gdal drivers as workaround #3305

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/ci_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
netCDF4
packaging
contextily
geopandas<1.0
geopandas
ipython
rioxarray
build
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- packaging
# Optional dependencies
- contextily
- geopandas<1.0
- geopandas
- ipython
- rioxarray
# Development dependencies (general)
Expand Down
2 changes: 2 additions & 0 deletions examples/gallery/lines/roads.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
# %%
import geopandas as gpd
import pygmt
import pyogrio
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move it to conf.py so that we don't have to repeat it in multiple gallery examples?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried locally, no it doesn't work if I put it in doc/conf.py.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitating to merge this PR because (1) users may be confused about pyogrio.core._register_drivers(); (2) Users may still use geopandas v0.x and don't have pyogrio installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, don't think it's a good option either. I just tried adding it to the Makefile and it doesn't work either.

The funny thing is, the examples/gallery/maps/choropleth_map.py example which also has a import geopandas as gpd line, and runs before the roads example, doesn't fail with the DataSourceError. If I move that choropleth_map.py file somewhere else, all the builds work without needing to register the driver manually 😅

Copy link
Member Author

@seisman seisman Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# Read shapefile data using geopandas
pyogrio.core._register_drivers()
gdf = gpd.read_file(
Copy link
Member

@weiji14 weiji14 Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found this issue geopandas/pyogrio#144 that mentions an error like pyogrio.errors.DataSourceError: Could not obtain driver: GPKG (check that it was installed correctly into GDAL) was due to drivers not being loaded properly. This should have been fixed in geopandas/pyogrio#145, but unsure why we're still hitting into this in the sphinx build and not in the regular tests.

Calling pyogrio.core._register_drivers() seems to get the GDAL drivers to register, so the build passes. But it doesn't look nice, and we should report this as a bug upstream if we can find a way to reproduce this outside of sphinx.

"http://www2.census.gov/geo/tiger/TIGER2015/PRISECROADS/tl_2015_15_prisecroads.zip"
)
Expand Down
3 changes: 3 additions & 0 deletions examples/get_started/04_table_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import numpy as np
import pandas as pd
import pygmt
import pyogrio

pyogrio.core._register_drivers()

# %%
# ASCII table file
Expand Down