You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "ump45nose (via GitHub)" <gi...@apache.org> on 2026/10/22 01:14:57 UTC

[PR] feat(python/sedonadb): Add ConfigurationWarning and an opt-out for PROJ/GDAL auto-configuration [sedona-db]

ump45nose opened a new pull request, #1479:
URL: https://github.com/apache/sedona-db/pull/1479

   ## Summary
   
   When `sedonadb` is imported without PROJ or GDAL available (e.g., no `pyproj`/`rasterio`/`pyogrio` installed), the automatic configuration on import emits two plain `UserWarning`s. That's noisy for lower-level users that don't need either library, and the only way to silence them today is to filter all `UserWarning`s or match on the message text.
   
   This adds two things:
   
   - `sedonadb.ConfigurationWarning`, a `UserWarning` subclass that `configure_proj("auto")` and `configure_gdal("auto")` now use (with `stacklevel=2` so the warning points at the caller rather than at `context.py`). It can be filtered selectively, e.g. `warnings.filterwarnings("ignore", category=sedonadb.ConfigurationWarning)`.
   - A `SEDONADB_AUTO_CONFIGURE` environment variable: setting it to `false` (or `0`/`no`/`off`) skips the `configure_proj("auto")` / `configure_gdal("auto")` calls in `sedonadb/__init__.py`, so the package can be imported without configuring either library. PROJ/GDAL can still be configured explicitly afterwards with `configure_proj()` / `configure_gdal()`. The env var is needed in addition to the warning class because the warnings fire while `sedonadb` itself is being imported, before a filter on `sedonadb.ConfigurationWarning` can be installed.
   
   The default behaviour is unchanged. Happy to drop or rename the environment variable if you'd prefer a different spelling or only the warning class.
   
   Closes #1149.
   
   ## Testing
   
   Built locally with `maturin develop`. New tests in `tests/test_context.py`:
   
   - `configure_proj("auto")` and `configure_gdal("auto")` (with every preset forced to fail) warn with `ConfigurationWarning`, and filtering that class silences them while other warnings are still errors;
   - reloading `sedonadb` with `SEDONADB_AUTO_CONFIGURE` unset/`true` calls both auto-configure functions, and with `false`/`0`/`OFF` calls neither.
   
   The new tests fail on main (5 failed, 2 passed) and pass with this change; `pytest tests/test_context.py tests/test_gdal.py` gives `21 passed`. I also ran the full `python/sedonadb/tests` suite locally and saw no failures up to ~92% before my local time limit cut it off. `SEDONADB_AUTO_CONFIGURE=false python -W error -c "import sedonadb"` imports cleanly. `ruff check` / `ruff format --check` (0.14.6, as pinned in pre-commit) pass on the changed files.
   
   This PR was prepared with AI assistance; I reviewed the change and ran the tests above.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(python/sedonadb): Add ConfigurationWarning and an opt-out for PROJ/GDAL auto-configuration [sedona-db]

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot merged PR #1479:
URL: https://github.com/apache/sedona-db/pull/1479


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(python/sedonadb): Add ConfigurationWarning and an opt-out for PROJ/GDAL auto-configuration [sedona-db]

Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on code in PR #1479:
URL: https://github.com/apache/sedona-db/pull/1479#discussion_r4343807984


##########
python/sedonadb/tests/test_context.py:
##########
@@ -350,3 +351,73 @@ def test_read_parquet_invalid_azure_option():
         match='Config value "unknown_option" not found on AzureOptions',
     ):
         con.read_parquet(url, options={"azure.unknown_option": "value"})
+
+
+def _raise(*args, **kwargs):
+    raise RuntimeError("not available")
+
+
+def test_configure_proj_auto_warning_class(monkeypatch):
+    import sedonadb.context as context

Review Comment:
   I appreciate the completeness here, although I think in this case we should not include a test using monkey patching. If you do want to test this, you can add a dedicated section to `.github/workflows/python.yml` (i.e., test more realistic usage of this). Also OK with me if we don't test this particular bit 🙂 



##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -62,6 +62,20 @@
 _DEFAULT_PYOGRIO_EXTENSIONS = ("fgb", "gpkg", "shp", "geojson")
 
 
+class ConfigurationWarning(UserWarning):
+    """Warning issued when an optional native dependency can't be configured
+
+    SedonaDB attempts to locate PROJ and GDAL when it is imported (see
+    :func:`configure_proj` and :func:`configure_gdal`). Most functionality
+    works without them, so a failure to find either is reported with this
+    warning rather than an error. Because it is a dedicated subclass of
+    ``UserWarning``, it can be silenced selectively, for example with
+    ``warnings.filterwarnings("ignore", category=sedonadb.ConfigurationWarning)``.
+    To skip the automatic configuration on import entirely, set the
+    ``SEDONADB_AUTO_CONFIGURE`` environment variable to ``false``.
+    """

Review Comment:
   Because one would need to import `sedonadb` in order to run that filter (and configuration happens on `import sedonadb`), I think we should remove `filterwarnings` example.
   
   The warning subclass is still better than a raw user warning and we should keep it around for when we want to solve that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(python/sedonadb): Add ConfigurationWarning and an opt-out for PROJ/GDAL auto-configuration [sedona-db]

Posted by "ump45nose (via GitHub)" <gi...@apache.org>.
ump45nose commented on code in PR #1479:
URL: https://github.com/apache/sedona-db/pull/1479#discussion_r4348754955


##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -62,6 +62,20 @@
 _DEFAULT_PYOGRIO_EXTENSIONS = ("fgb", "gpkg", "shp", "geojson")
 
 
+class ConfigurationWarning(UserWarning):
+    """Warning issued when an optional native dependency can't be configured
+
+    SedonaDB attempts to locate PROJ and GDAL when it is imported (see
+    :func:`configure_proj` and :func:`configure_gdal`). Most functionality
+    works without them, so a failure to find either is reported with this
+    warning rather than an error. Because it is a dedicated subclass of
+    ``UserWarning``, it can be silenced selectively, for example with
+    ``warnings.filterwarnings("ignore", category=sedonadb.ConfigurationWarning)``.
+    To skip the automatic configuration on import entirely, set the
+    ``SEDONADB_AUTO_CONFIGURE`` environment variable to ``false``.
+    """

Review Comment:
   Agreed, removed the `filterwarnings` example in c74bb5f. The class itself stays, and the docstrings now use markdown instead of ReST. (AI-assisted reply.)
   



##########
python/sedonadb/tests/test_context.py:
##########
@@ -350,3 +351,73 @@ def test_read_parquet_invalid_azure_option():
         match='Config value "unknown_option" not found on AzureOptions',
     ):
         con.read_parquet(url, options={"azure.unknown_option": "value"})
+
+
+def _raise(*args, **kwargs):
+    raise RuntimeError("not available")
+
+
+def test_configure_proj_auto_warning_class(monkeypatch):
+    import sedonadb.context as context

Review Comment:
   Makes sense. I dropped the monkeypatch-based tests in c74bb5f rather than adding a workflow section, so the PR no longer touches `test_context.py`. (AI-assisted reply.)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(python/sedonadb): Add ConfigurationWarning and an opt-out for PROJ/GDAL auto-configuration [sedona-db]

Posted by "ump45nose (via GitHub)" <gi...@apache.org>.
ump45nose commented on PR #1479:
URL: https://github.com/apache/sedona-db/pull/1479#issuecomment-6341658994

   Thanks @paleolimbot. c74bb5f converts the new docstrings to markdown, removes the `filterwarnings` example and drops the monkeypatch tests. The `python ubuntu-latest` failure is unrelated to this change: the DuckDB-based tests fail with `Relations no longer have fetchone()`, which comes from a new DuckDB release. (AI-assisted reply.)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org