utils: migrate set_target_region to Tools API#7207
Open
AkshadSonawane wants to merge 1 commit intoOSGeo:mainfrom
Open
utils: migrate set_target_region to Tools API#7207AkshadSonawane wants to merge 1 commit intoOSGeo:mainfrom
AkshadSonawane wants to merge 1 commit intoOSGeo:mainfrom
Conversation
Member
| It's probably not a problem in this file, but we just have to watch out that our low-level library functions don't depend on high level functions, creating a circular dependency, which could cause import problems. |
petrasovaa requested changes Mar 22, 2026
Contributor
petrasovaa left a comment
There was a problem hiding this comment.
Please test this locally.
91acd77 to 67e0180 Compare Author
Good catch — checked and Tools comes from grass.tools which sits below grass.jupyter in the dependency chain, so no circular dependency here. Good thing to keep in mind for future migrations though. |
Author
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.

Continuing the Tools API migration from #6950, which covered get_region and get_location_proj_string. Two more functions in utils.py still used the old gs.* style — this cleans those up.
set_target_region now uses Tools(env=tgt_env).g_region(...) instead of gs.run_command. get_region_bounds_latlon switches to Tools().g_region(flags="bp", format="json").json — the -g flag is dropped since it was only needed for shell-script output formatting, which format="json" makes redundant.
I left update_region alone for now. Its return value gets unpacked by _update_output in interactivemap.py using long key names (north, south, etc.), and I wasn't confident the Tools API JSON output uses the same keys without a live environment to test against. Happy to revisit that one if there's a clean way to verify it.