Skip to content
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

__getattr__ shortcut for calling GRASS display modules #1723

Merged
merged 12 commits into from
Jul 29, 2021

Conversation

chaedri
Copy link
Contributor

@chaedri chaedri commented Jul 13, 2021

  • Shortcut allowing users to call GRASS display modules ('d.*) with class method .d_*.
  • Example of usage in jupyter_integration.ipynb
  • Typo fix and black formatting

These modifications are part of an on-going Google Summer of Code project, Improved Integration of GRASS GIS and Jupyter Notebooks. You can find more information here. You can test out the functionality in Binder here:

https://mybinder.org/v2/gh/chaedri/grass/non-interactive-display-update?urlpath=lab%2Ftree%2Fdoc%2Fnotebooks%2Fjupyter_integration.ipynb

@chaedri
Copy link
Contributor Author

chaedri commented Jul 13, 2021

There are a couple things that need improvement still:

  1. Error Handling. If the user passes an incorrect or incorrectly formatted command, say .d_raster instead of .d_rast, it returns two errors, one that results from the try: statement and one that results from the except: statement. I think this is unexpected behavior...
  2. There might be other errors that need handling. For example, if you pass incorrect keyword arguments such as d.rast("elevation") instead of `d.rast(map="elevation"), the error isn't very useful.
  3. I haven't tested all the `d.* modules.

@wenzeslaus wenzeslaus added this to In progress in Integration with Jupyter Notebooks via automation Jul 13, 2021
@wenzeslaus wenzeslaus added enhancement New feature or request gsoc Reserved for Google Summer of Code student(s) labels Jul 13, 2021
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet and simple, just the error handling needs some more work.

Please, include an example in the notebook, so that others can try easily.

python/grass/jupyter/display.py Outdated Show resolved Hide resolved
python/grass/jupyter/display.py Outdated Show resolved Hide resolved
python/grass/jupyter/display.py Outdated Show resolved Hide resolved
python/grass/jupyter/display.py Outdated Show resolved Hide resolved
python/grass/jupyter/display.py Outdated Show resolved Hide resolved
@chaedri chaedri marked this pull request as ready for review July 20, 2021 21:13
@chaedri chaedri marked this pull request as draft July 21, 2021 12:40
@chaedri chaedri marked this pull request as ready for review July 23, 2021 14:01
@wenzeslaus
Copy link
Member

@chaedri It seems to me that the message "Module must begin with 'd_'" needs little more clarification, but let's leave that for some documentation PR. (I'm thinking module vs GRASS module, "must begin with" vs display commands, and including the name of the command.

@wenzeslaus wenzeslaus merged commit fd19e91 into OSGeo:master Jul 29, 2021
Integration with Jupyter Notebooks automation moved this from In progress to Done Jul 29, 2021
a0x8o added a commit to a0x8o/grass that referenced this pull request Jul 29, 2021
…OSGeo#1723)

Shortcut allowing users to call GRASS display modules (d.*) with method .d_*.
Method name must start with d and underscore and it needs to be an executable on path,
other error handling is left to the underlying functions. Example is in the Jupyter integration notebook.
@chaedri chaedri deleted the non-interactive-display-update branch July 30, 2021 17:37
@neteler neteler added this to the 8.0.0 milestone Dec 9, 2021
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
…OSGeo#1723)

Shortcut allowing users to call GRASS display modules (d.*) with method .d_*.
Method name must start with d and underscore and it needs to be an executable on path,
other error handling is left to the underlying functions. Example is in the Jupyter integration notebook.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
…OSGeo#1723)

Shortcut allowing users to call GRASS display modules (d.*) with method .d_*.
Method name must start with d and underscore and it needs to be an executable on path,
other error handling is left to the underlying functions. Example is in the Jupyter integration notebook.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gsoc Reserved for Google Summer of Code student(s)
Development

Successfully merging this pull request may close these issues.

None yet

3 participants