Skip to content

grass.tools: Use Tools in v.dissolve #6148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wenzeslaus
Copy link
Member

This uses grass.tools in the v.dissolve tool for whatever was previously done by the grass.script.run_command functions. There is no strong reason to do this migration except to test grass.tool more and create more examples, but that's a good reason. Nice thing is that simple calls once the Tools object is created are shorter by one line. Tools objects need to be created. (I opted for creating them again in functions as opposed to passing one to all functions.)

To keep the behavior close to the original, some of the Tools objects do not capture stdout and stderr so that it is printed as it would be with run_command. This means that progress messages will be printed from the underlying tools and error messages will be part of that output as well. (This choice might have been different for a newly written tool or for different parts of a tool.) Places which capture stdin for further processing are kept with the defaults, so stderr is captured and will be part of an exception, but will not be visible otherwise (but was previously visible).

Places which use tool wrappers from grass.script are left as is. Replacement of the convenience wrappers is waiting for JSON outputs of specific tools, so the current change is only focusing on run_command and friends.

Running the pytest test takes the same time with the old and new code (20-29s depending on external factors but consistent for both versions).

This uses grass.tools in the v.dissolve tool for whatever was previously done by the grass.script.run_command functions. There is no strong reason to do this migration except to test grass.tool more and create more examples, but that's a good reason. Nice thing is that simple calls once the Tools object is created are shorter by one line. Tools objects need to be created. (I opted for creating them again in functions as opposed to passing one to all functions.)

To keep the behavior close to the original, some of the Tools objects do not capture stdout and stderr so that it is printed as it would be with run_command. This means that progress messages will be printed from the underlying tools and error messages will be part of that output as well. (This choice might have been different for a newly written tool or for different parts of a tool.) Places which capture stdin for further processing are kept with the defaults, so stderr is captured and will be part of an exception, but will not be visible otherwise (but was previously visible).

Places which use tool wrappers from grass.script are left as is. Replacement of the convenience wrappers is waiting for JSON outputs of specific tools, so the current change is only focusing on run_command and friends.

Running the pytest test takes the same time with the old and new code (20-29s depending on external factors but consistent for both versions).
@github-actions github-actions bot added vector Related to vector data processing Python Related code is in Python module labels Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Python Related code is in Python vector Related to vector data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant