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

library: Add imagery Python library module to grass.script #3756

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

ninsbl
Copy link
Member

@ninsbl ninsbl commented May 31, 2024

This PR adds a new imagery module to grass.script. For the time being it has just one function, that returns a dictionary for an imagery group with the contained maps and metadata.

It addresses #3750

@ninsbl ninsbl added enhancement New feature or request Python Related code is in Python libraries imagery labels May 31, 2024
@ninsbl ninsbl added this to the Future milestone May 31, 2024
@github-actions github-actions bot added the tests Related to Test Suite label May 31, 2024
python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
echoix
echoix previously requested changes Jun 4, 2024
python/grass/script/testsuite/test_imagery.py Outdated Show resolved Hide resolved
@ninsbl ninsbl requested review from wenzeslaus and echoix June 5, 2024 21:46
@echoix echoix dismissed their stale review June 5, 2024 21:50

Changes addressed

@ninsbl ninsbl modified the milestones: Future, 8.5.0 Jun 15, 2024
@ninsbl ninsbl requested a review from wenzeslaus July 17, 2024 22:08
python/grass/script/testsuite/test_imagery.py Outdated Show resolved Hide resolved
python/grass/script/testsuite/test_imagery.py Outdated Show resolved Hide resolved
python/grass/script/testsuite/test_imagery.py Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@echoix
Copy link
Member

echoix commented Jul 19, 2024

One last question about this one: does it wire up everything in order for the sphinx docs to be generated correctly for it? For the makefiles it is probably enough, I didn't search more.

Comment on lines +8 to +10
import grass.script as gs

gs.imagery.group_to_dict(imagery_group)
Copy link
Member

Choose a reason for hiding this comment

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

If you mean for it to be used this way, then don't add that to the __init__.py or leave .imagery here out. (I don't know if it would even not work the way it is written now.) It is basically a decision between the imagery being part of the internal structure versus part of the API. Simpler imports versus more freedom in naming (no danger of collisions).

I added from . import setup there so that there is no need for extra import, but that the namespace stays separate. However setup is a special case.

For consistency with raster and others, having from .imagery import * seems appropriate.

Copy link
Member

Choose a reason for hiding this comment

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

We should tend to avoid adding new star imports

Copy link
Member

Choose a reason for hiding this comment

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

We should tend to avoid adding new star imports

In general, of course, but here in __init__.py and next to from .raster import *?

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason I included the star import is do have it consistent with the other modules...

And with that: gs.imagery.group_to_dict(imagery_group) does work.

Copy link
Member Author

Choose a reason for hiding this comment

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

That said, gs.group_to_dict(imagery_group) works too. I do what you prefer regarding the star-import. Not being able to do gs.group_to_dict(imagery_group) without the star-import would be fine with me...
Let me know what to do to merge it...

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm... tests fail without the import of imagery in __init__.py

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Of course the long way, import grass.script.imagery will work.
if you add it, then gs.imagery should work too

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused. Why it works right now? I thought from . import imagery is needed for gs.imagery.group_to_dict to work. I think I had to do it that way for from . import setup and gs.setup.init.

python/grass/script/imagery.py Outdated Show resolved Hide resolved
python/grass/script/imagery.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request imagery libraries Python Related code is in Python tests Related to Test Suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants