utils: migrate set_target_region to Tools API#7207
utils: migrate set_target_region to Tools API#7207AkshadSonawane wants to merge 2 commits intoOSGeo:mainfrom
Conversation
|
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
left a comment
There was a problem hiding this comment.
Please test this locally.
91acd77 to
67e0180
Compare
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. |
983f1a2 to
67e0180
Compare
|
Hi @petrasovaa, I added a basic sanity test to ensure While attempting to write a full integration test using Would you recommend a preferred testing pattern for this function, or should it be covered at a higher integration level? I’d be happy to expand the test coverage based on your guidance. Thanks! |

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.