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: Fix minimal test env and remove deps on pandas / geopandas #134

Merged
merged 6 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion .github/workflows/tests-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
python: ["3.9", "3.10"]
env: ["environment.yml"]
include:
# minimal environment without optional dependencies
- os: "ubuntu-latest"
python: "3.10"
env: "environment-minimal.yml"

steps:
- name: Checkout repo
Expand All @@ -32,7 +38,7 @@ jobs:
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-file: ci/environment.yml
environment-file: ci/${{ matrix.env }}
extra-specs: python=${{ matrix.python }}
cache-env: true

Expand Down
8 changes: 8 additions & 0 deletions ci/environment-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: test
channels:
- conda-forge
dependencies:
- numpy
- libgdal
- pytest

14 changes: 9 additions & 5 deletions pyogrio/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from pyogrio import __gdal_version_string__, __version__, list_drivers
import pyogrio
from pyogrio.raw import read, write


_data_dir = Path(__file__).parent.resolve() / "fixtures"
Expand All @@ -27,12 +27,16 @@ def prepare_testfile(testfile_path, dst_dir, ext):
dst_path = dst_dir / f"{testfile_path.stem}{ext}"
if dst_path.exists():
return dst_path
gdf = pyogrio.read_dataframe(testfile_path)

meta, _, geometry, field_data = read(testfile_path)

if ext == ".fgb":
# For .fgb, spatial_index=False to avoid the rows being reordered
pyogrio.write_dataframe(gdf, dst_path, spatial_index=False)
else:
pyogrio.write_dataframe(gdf, dst_path)
meta["spatial_index"] = False
# allow mixed Polygons/MultiPolygons type
meta["geometry_type"] = "Unknown"
Copy link
Member

Choose a reason for hiding this comment

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

This one line is a change compared to what was there before? Or did write_dataframe infer such a geometry type? (I would have expected that it would infer "MultiPolgyon" and set promote_to_multi to true)

Copy link
Member Author

Choose a reason for hiding this comment

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

The detection and promotion happens in write_geodataframe and doesn't happen in the case of the raw write.

With a little bit of refactoring we could move that into write instead (I think this was even suggested when that was first added), but I didn't think we needed to do so prior to 0.4 (changes noted in the changelog are specific to GeoDataFrame)


write(dst_path, geometry, field_data, **meta)
return dst_path


Expand Down
5 changes: 3 additions & 2 deletions pyogrio/tests/test_geopandas_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import os

import numpy as np
import pandas as pd
from pandas.testing import assert_frame_equal, assert_index_equal
import pytest

from pyogrio import list_layers, read_info, __gdal_geos_version__
Expand All @@ -13,6 +11,9 @@
from pyogrio.tests.conftest import ALL_EXTS

try:
import pandas as pd
from pandas.testing import assert_frame_equal, assert_index_equal

import geopandas as gp
from geopandas.testing import assert_geodataframe_equal

Expand Down