-
-
Notifications
You must be signed in to change notification settings - Fork 373
grass.tools: Add API to access tools as functions #2923
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
Merged
Merged
Changes from all commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
d905882
grass.experimental: Add object to access modules as functions
wenzeslaus aaef183
Support verbosity, overwrite and region freezing
wenzeslaus 54db575
Raise exception instead of calling handle_errors
wenzeslaus 82f5894
Allow to specify stdin and use a new instance of Tools itself to exec…
wenzeslaus 0f1e210
Add ignore errors, r_mapcalc example, draft tests
wenzeslaus f4e3fed
Add test for exceptions
wenzeslaus 04087e8
Add tests and Makefile
wenzeslaus 6ab8e40
Convert values to ints and floats in keyval
wenzeslaus 744cfac
Do not overwrite by default to follow default behavior in GRASS GIS
wenzeslaus 24c27e6
Add doc, remove old code and todos
wenzeslaus ff187a6
Add to top Makefile
wenzeslaus 22773c8
Add docs for tests
wenzeslaus 2911065
Allow test to fail because of the missing seed parameter (so results …
wenzeslaus 3ac46c3
Merge branch 'main' into add-session-tools-object
echoix 437d46e
Allow for optional output capture (error handling and printing still …
wenzeslaus cb8f483
Merge branch 'main' into add-session-tools-object
wenzeslaus a958142
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 61972d4
Access JSON as dict directly without an attribute using getitem. Sugg…
wenzeslaus c86d8ff
Fix whitespace and regexp
wenzeslaus 3b995c9
Represent not captured stdout as None, not empty string.
wenzeslaus d8c354d
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 4cc5a32
Add run subcommand to have a CLI use case for the tools. It runs one …
wenzeslaus 459b2ad
Update function name
wenzeslaus 513c9f8
Add prototype code for numpy support
wenzeslaus 24ef6b9
Merge main branch
wenzeslaus 4a1e374
Make the special features standalone objects used by composition
wenzeslaus 651df11
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 15aa936
Remove NumPy and pack file code
wenzeslaus 5e9b50d
Capture the name of a subcommand to fix the tests
wenzeslaus 2acdde0
Don't worry about specific r.univar output value for mean, just test …
wenzeslaus 8f80eb9
Use the special grass.script sauce to run subprocess to have it worki…
wenzeslaus a422356
Use low level run functions internally, align result with subprocess.…
wenzeslaus 8f1e8ff
Use tools API also for help in the CLI, support other special flags, …
wenzeslaus 2085b94
Provide dir(tools) functionality
wenzeslaus d341183
Support prefixes in attribute access and error messages. Also improve…
wenzeslaus 4f86be4
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus d8f6c40
Improve error message without tool suggestions (still include tool na…
wenzeslaus ac98322
Remove prefixes
wenzeslaus 3abc34b
Clean up error handling, remove naive run_command family wrappers
wenzeslaus 816b215
Add test with corresponding run_command family examples except feed, …
wenzeslaus e95bb51
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 3c99498
Use the no-copy approach for env taked also elsewhere like init which…
wenzeslaus 14be050
Remove the feed_input_to method and stdin from the constructor. Inste…
wenzeslaus f9f7c0a
Add support for len on the result
wenzeslaus 3a45c00
Make the file layout what it can be if not experimental, and make it …
wenzeslaus 5658d3e
Disable Pylint warning because Pylint does not see the dynamic attrib…
wenzeslaus 549cf1a
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus bbd80a5
Use create_project
wenzeslaus ff17612
Merge to update handle_errors
wenzeslaus 7754592
Add doc for the main run function
wenzeslaus 0587621
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 1345f79
Use input for stdin aligning with subprocess.run and Popen.communicat…
wenzeslaus 11d7bb0
Use also command in result if kwargs are not available. Do not use se…
wenzeslaus 35a785b
More migration examples. More examples with context managers.
wenzeslaus 2176395
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus acff8ce
Add g.list examples
wenzeslaus caa2126
Fix typo in text comment
wenzeslaus 8477243
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 94ea39c
Rely on grass.script.Popen defaults for text=True. Pass stderr as is …
wenzeslaus 2bda54f
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 81ea7d3
Behave also like context manager (useful when used with other context…
wenzeslaus 15fd4f7
Allow stderr to be captured even without capturing stdin
wenzeslaus 2815511
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 46a43be
Update r.univar test
wenzeslaus 7e10c91
Test result attributes and give more consistent results for JSON
wenzeslaus 3352146
Remove r.pack-IO-related fixtures
wenzeslaus 58162a8
Use possibly more common order for region and mask managers (both are…
wenzeslaus 2c4d5dd
Document tests
wenzeslaus c098c16
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 54bdb4a
Sort tool suggestions, document tests
wenzeslaus b5de481
Document run and call functions
wenzeslaus 91a775f
Add examples in doc which pass doctest and create repr for that
wenzeslaus a0eb515
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus a5601b3
Move tools from grass.experimental to grass.tools, but document them …
wenzeslaus 505b72a
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus d31cdb4
Update the path in the Makefile
wenzeslaus 603b20a
Update cmake build
wenzeslaus 8cd22b3
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 5220b4a
Use grass.tools import in grass.app.cli
wenzeslaus 660704d
Merge branch 'main' into add-session-tools-object
wenzeslaus 39b500b
Merge branch 'main' into add-session-tools-object
wenzeslaus b5af2c0
Apply isort suggestions
wenzeslaus ddb4a7b
Add tests for specific values
wenzeslaus 6b2b4fa
Fix copy-paste
wenzeslaus 04ce72e
Make sure return code is passed from the tool subprocess, add tests
wenzeslaus f13cb23
Merge remote-tracking branch 'upstream/main' into add-session-tools-o…
wenzeslaus 7e3514c
Test decoding and stripping of the result
wenzeslaus 15967c4
No tool provided needs to be handled explicitly. Add missing smoke te…
wenzeslaus f091d64
Update python/grass/app/tests/grass_app_cli_test.py
echoix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ SUBDIRS = \ | |
| script \ | ||
| semantic_label \ | ||
| temporal \ | ||
| tools \ | ||
| utils | ||
|
|
||
| default: $(PYDIR)/__init__.py | ||
|
|
||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """Fixtures for grass.script""" | ||
| """Fixtures for grass.experimental""" | ||
|
|
||
| import uuid | ||
| import os | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MODULE_TOPDIR = ../../.. | ||
|
|
||
| include $(MODULE_TOPDIR)/include/Make/Other.make | ||
| include $(MODULE_TOPDIR)/include/Make/Python.make | ||
|
|
||
| DSTDIR = $(ETC)/python/grass/tools | ||
|
|
||
| MODULES = \ | ||
| session_tools \ | ||
| support | ||
|
|
||
| PYFILES := $(patsubst %,$(DSTDIR)/%.py,$(MODULES) __init__) | ||
| PYCFILES := $(patsubst %,$(DSTDIR)/%.pyc,$(MODULES) __init__) | ||
|
|
||
| default: $(PYFILES) $(PYCFILES) | ||
|
|
||
| $(DSTDIR): | ||
| $(MKDIR) $@ | ||
|
|
||
| $(DSTDIR)/%: % | $(DSTDIR) | ||
| $(INSTALL_DATA) $< $@ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| def __getattr__(name): | ||
| if name == "Tools": | ||
| from .session_tools import Tools | ||
|
|
||
| return Tools | ||
| msg = f"module {__name__} has no attribute {name}" | ||
| raise AttributeError(msg) | ||
|
|
||
|
|
||
| __all__ = ["Tools"] # pylint: disable=undefined-all-variable |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.