Repository navigation
temporal: add parameter to skip creation of TGIS DB in current mapset on tgis.init - #7645
Conversation
echoix
left a comment
There was a problem hiding this comment.
Quick review, assuming tests will pass
|
I saw a failure in a PR, on macOS, on one of these new tests, that might be because the success of this test is either order of execution dependent, or is impacted by other tests running in parallel. It is probably not isolated enough to fail only in intended cases. See https://github.com/OSGeo/grass/actions/runs/29107259300/job/86410721891?pr=7635 |
|
Just tried if copilot has an intelligent idea or not, I'm not sure it actually looked at the code that is tested by its response: Solution for Failing JobProblemThe test The issue is on line 71 of the test file. When Root CauseWhen SolutionThe test's expectation is incorrect. When database initialization is skipped, the backend should not be queried or the assertion should be conditional. Here's the recommended fix: Option 1: Skip the backend assertion when DB init is skipped (Recommended) def test_init_succeeds_without_db_creation(simple_mapset):
"""tgis.init(skip_db_init=True) does not create a DB or connection entry in VAR."""
project_c = simple_mapset
var_file = Path(project_c) / "VAR"
tgis_db = Path(project_c) / "tgis"
with gs.setup.init(project_c):
tgis.init(skip_db_init=True)
first_ciface = tgis.get_tgis_c_library_interface()
assert first_ciface.available_mapsets() == ["c", "PERMANENT"]
assert tgis.get_tgis_version() == 2
# Don't assert backend when DB initialization is skipped
# assert tgis.get_tgis_backend() == "sqlite"
assert tgis.get_enable_mapset_check() is True
assert tgis.get_enable_timestamp_write() is True
assert tgis.get_sql_template_path().endswith("sql")
assert not var_file.exists()
assert not tgis_db.exists()Option 2: Allow None as a valid return value # At line 71, change:
assert tgis.get_tgis_backend() == "sqlite"
# To:
backend = tgis.get_tgis_backend()
assert backend is None or backend == "sqlite" # Accept None when DB init is skippedOption 3: Ensure backend is initialized even without DB If the backend should always be available, modify the Recommended Action: Use Option 1 - remove the backend assertion from the |
Some temporal tools (like t.list, t.rast.list, t.info, ...) do not need to write to a TGIS database. For those modules, it would make sense if
tgis.init()not allways forces the creation of a TGIS DB in the current mapset.This PR adds a parameter so DB creation can be skipped. The current behavior is unchanged, as skipping TGIS DB creation has to be explicitly requested.
A regression test is added to test that both alternatives work as expected.