grass.temporal: set backend when init() skips database creation#7671
Closed
gkneighb wants to merge 1 commit into
Closed
grass.temporal: set backend when init() skips database creation#7671gkneighb wants to merge 1 commit into
gkneighb wants to merge 1 commit into
Conversation
init(skip_db_init=True) returned before setting the tgis_backend global, so get_tgis_backend() was None even though the docstring documents that skip_db_init still provides the backend. The test test_init_succeeds_without_db_creation only passed when a sibling test had already run a full init() in the same process to set the global; run standalone or split across pytest-xdist workers it failed with "assert None == 'sqlite'". Set the backend before the early return by reading the driver name non-destructively (via the C-library interface, not t.connect, which would write the connection VAR) and defaulting to sqlite when no temporal connection is defined. This preserves the no-side-effect guarantee of skip_db_init (no VAR file, no database created) while honoring the documented contract, so the test passes in isolation and under parallel execution. Test Plan: Previously failed standalone and under pytest-xdist; now passes: ``` pytest python/grass/temporal/tests/grass_temporal_core_init_skip_db_test.py -n 2 ``` Full temporal regression under parallel execution (139 passed): ``` pytest python/grass/temporal/tests/ temporal/*/tests/ -n auto ``` Authored with the help of an AI assistant.
Member
|
@ninsbl I think you had a PR prepared on your fork for addressing that issue |
ninsbl
reviewed
Jul 12, 2026
ninsbl
left a comment
Member
There was a problem hiding this comment.
Good catch.
Still, I would rather solve this as part of #7672 (where I solved it slightly different).
While the solution here is OK and would use a more meaningful default if a TGIS DB connection is defined in the current mapset, I think it is unnecessary to get the defaults from the current mapset, because if the SQL connection gets initialized the defaults in the globals will be overwritten anyway...
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
init(skip_db_init=True)returned before setting thetgis_backendglobal, soget_tgis_backend()wasNoneafter it — even thoughinit()'s own docstring documents thatskip_db_initstill provides "the global TGIS state (backend, mapset, interfaces)".The regression test
grass_temporal_core_init_skip_db_test.py::test_init_succeeds_without_db_creationassertsget_tgis_backend() == "sqlite", but that only held when its siblingtest_init_creates_tgis_db_if_not_skippedran first in the same process and set the global via a fullinit(). Run standalone, or split acrosspytest-xdistworkers, it failed withassert None == 'sqlite'.Fix
Set the backend before the early return, reading the driver name non-destructively through the C-library interface (not
t.connect, whose-cflag would write the connection VAR) and defaulting tosqlitewhen no temporal connection is defined yet. This preserves the no-side-effect guarantee ofskip_db_init(the same test still assertsnot var_file.exists()andnot tgis_db.exists()) while honoring the documented contract, so the test passes in isolation and under parallel execution.How this was found
The failure surfaced on the macOS CI of an unrelated temporal PR (#7670): adding test files shifted
pytest-xdist's worker distribution so the two sibling tests landed in different workers, exposing this latent ordering dependency. It reproduces onmainwithpytest .../grass_temporal_core_init_skip_db_test.py -n 2.Test plan
Previously failed standalone and under xdist; now passes:
Full temporal regression under parallel execution (139 passed):
AI assistance
Implemented with the assistance of an AI coding assistant (Claude), reviewed and verified by the author.