Skip to content

Commit e66b5f1

Browse files
committed
Merge branch 'master' into issue668-federation-extension
2 parents 25f9ce9 + 62cc233 commit e66b5f1

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121

2222
### Fixed
2323

24+
- `CsvJobDatabase`: workaround GeoPandas issue (on Python>3.9) when there is a column named "crs" ([#714](https://github.com/Open-EO/openeo-python-client/issues/714))
25+
2426

2527
## [0.37.0] - 2025-01-21 - "SAP10" release
2628

openeo/extra/job_management/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,8 @@ def read(self) -> pd.DataFrame:
904904
import geopandas
905905

906906
# `df.to_csv()` in `persist()` has encoded geometries as WKT, so we decode that here.
907-
df = geopandas.GeoDataFrame(df, geometry=geopandas.GeoSeries.from_wkt(df["geometry"]))
907+
df.geometry = geopandas.GeoSeries.from_wkt(df["geometry"])
908+
df = geopandas.GeoDataFrame(df)
908909
return df
909910

910911
def persist(self, df: pd.DataFrame):

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
"urllib3<2.3.0", # httpretty doesn't work properly with urllib3>=2.3.0. See #700 and https://github.com/gabrielfalcao/HTTPretty/issues/484
2626
"netCDF4>=1.7.0",
2727
"matplotlib", # TODO: eliminate matplotlib as test dependency
28-
"geopandas",
28+
# TODO #717 Simplify geopandas constraints when Python 3.8 support is dropped
29+
"geopandas>=0.14; python_version>='3.9'",
30+
"geopandas", # Best-effort geopandas dependency for Python 3.8
2931
"flake8>=5.0.0",
3032
"time_machine",
3133
"pyproj>=3.2.0", # Pyproj is an optional, best-effort runtime dependency

tests/extra/job_management/test_job_management.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import copy
2+
import datetime
23
import json
34
import logging
45
import re
@@ -7,7 +8,6 @@
78
from time import sleep
89
from typing import Callable, Union
910
from unittest import mock
10-
import datetime
1111

1212
import dirty_equals
1313
import geopandas
@@ -40,6 +40,7 @@
4040
)
4141
from openeo.rest._testing import OPENEO_BACKEND, DummyBackend, build_capabilities
4242
from openeo.util import rfc3339
43+
from openeo.utils.version import ComparableVersion
4344

4445

4546
@pytest.fixture
@@ -977,6 +978,30 @@ def test_initialize_from_df_on_exists_skip(self, tmp_path):
977978
)
978979
assert set(db.read()["some_number"]) == {1, 2, 3}
979980

981+
@pytest.mark.skipif(
982+
ComparableVersion(geopandas.__version__) < "0.14",
983+
reason="This issue has no workaround with geopandas < 0.14 (highest available version on Python 3.8 is 0.13.2)",
984+
)
985+
def test_read_with_crs_column(self, tmp_path):
986+
"""
987+
Having a column named "crs" can cause obscure error messages when creating a GeoPandas dataframe
988+
https://github.com/Open-EO/openeo-python-client/issues/714
989+
"""
990+
source_df = pd.DataFrame(
991+
{
992+
"crs": [1234],
993+
"geometry": ["Point(2 3)"],
994+
}
995+
)
996+
path = tmp_path / "jobs.csv"
997+
source_df.to_csv(path, index=False)
998+
result_df = CsvJobDatabase(path).read()
999+
assert isinstance(result_df, geopandas.GeoDataFrame)
1000+
assert result_df.to_dict(orient="list") == {
1001+
"crs": [1234],
1002+
"geometry": [shapely.geometry.Point(2, 3)],
1003+
}
1004+
9801005

9811006
class TestParquetJobDatabase:
9821007

0 commit comments

Comments
 (0)