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

grass.script: Make setup available without another import #2451

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

wenzeslaus
Copy link
Member

@wenzeslaus wenzeslaus commented Jun 19, 2022

import grass.script.setup or similar was needed to get access to functions in the setup module. Now the module is imported in the init file which makes it available without an additional import in user code. gs.setup.init() is now an easy and clear way of getting access to the init function.

Most of the code using grass.script.setup was modified to the new style (except for grass.py and imports of specific functions).

Documentation related to the session returned from gs.setup.init updated as gs.setup.finish() call is not even needed when easier session.finish() call is used instead. (Using session.finish() leaves gs.setup.init() call to be the only one from setup for typical session handling code, so the previously required separate import would be for one call only; now there is no import except for grass.script.)

Alternatives to this implementation would be to import all functions (which would bring many symbols to grass.script) or importing specific functions (e.g., init only), but importing setup makes it most clear (all are available) while keeping them separate under setup. (There are other setup or session related functions in grass.script.core already available after importing grass.script, so there is still some confusion related to that. However, rather than mixing all together, it seems that these need to be separated from core or organized better in some other way.)

import grass.script.setup or similar was needed to get access to functions in the setup module. Now the module is imported in the init file which makes it available without an additional import in user code. gs.setup.init() is now an easy and clear way of getting access to the init function.

Most of the code using grass.script.setup was modified to the new style (except for grass.py and imports of specific functions).

Documentation related to the session returned from gs.setup.init updated as gs.setup.finish() call is not even needed with session.finish() call is easier. (Using session.finish() leaves gs.setup.init() call to be the only one from setup for typical session handling code, so the previsouly required separate import would be for one call only; now there is no import except for grass.script.)

Alternative would be to import all functions (which would bring many symbols to gs) and importing specific functions (e.g., init only), but importing init makes it most clear (all are available) while keeping them separate under setup (although there are other setup or session related functions in grass.script.core already available after importing grass.script).
@wenzeslaus wenzeslaus added this to the 8.4.0 milestone Jul 25, 2022
@wenzeslaus wenzeslaus added the enhancement New feature or request label Jul 26, 2022
@wenzeslaus wenzeslaus merged commit 05380bc into OSGeo:main Jul 26, 2022
@wenzeslaus wenzeslaus deleted the setup-part-of-grass-script branch July 26, 2022 15:15
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
import grass.script.setup or similar was needed to get access to functions in the setup module. Now the module is imported in the init file which makes it available without an additional import in user code. gs.setup.init() is now an easy and clear way of getting access to the init function.

Most of the code using grass.script.setup was modified to the new style (except for grass.py and imports of specific functions).

Documentation related to the session returned from gs.setup.init updated as gs.setup.finish() call is not even needed when easier session.finish() call is used instead. (Using session.finish() leaves gs.setup.init() call to be the only one from setup for typical session handling code, so the previously required separate import would be for one call only; now there is no import except for grass.script.)

Alternatives to this implementation would be to import all functions (which would bring many symbols to grass.script) or importing specific functions (e.g., init only), but importing setup makes it most clear (all are available) while keeping them separate under setup. (There are other setup or session related functions in grass.script.core already available after importing grass.script, so there is still some confusion related to that. However, rather than mixing all together, it seems that these need to be separated from core or organized better in some other way.)
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
import grass.script.setup or similar was needed to get access to functions in the setup module. Now the module is imported in the init file which makes it available without an additional import in user code. gs.setup.init() is now an easy and clear way of getting access to the init function.

Most of the code using grass.script.setup was modified to the new style (except for grass.py and imports of specific functions).

Documentation related to the session returned from gs.setup.init updated as gs.setup.finish() call is not even needed when easier session.finish() call is used instead. (Using session.finish() leaves gs.setup.init() call to be the only one from setup for typical session handling code, so the previously required separate import would be for one call only; now there is no import except for grass.script.)

Alternatives to this implementation would be to import all functions (which would bring many symbols to grass.script) or importing specific functions (e.g., init only), but importing setup makes it most clear (all are available) while keeping them separate under setup. (There are other setup or session related functions in grass.script.core already available after importing grass.script, so there is still some confusion related to that. However, rather than mixing all together, it seems that these need to be separated from core or organized better in some other way.)
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
import grass.script.setup or similar was needed to get access to functions in the setup module. Now the module is imported in the init file which makes it available without an additional import in user code. gs.setup.init() is now an easy and clear way of getting access to the init function.

Most of the code using grass.script.setup was modified to the new style (except for grass.py and imports of specific functions).

Documentation related to the session returned from gs.setup.init updated as gs.setup.finish() call is not even needed when easier session.finish() call is used instead. (Using session.finish() leaves gs.setup.init() call to be the only one from setup for typical session handling code, so the previously required separate import would be for one call only; now there is no import except for grass.script.)

Alternatives to this implementation would be to import all functions (which would bring many symbols to grass.script) or importing specific functions (e.g., init only), but importing setup makes it most clear (all are available) while keeping them separate under setup. (There are other setup or session related functions in grass.script.core already available after importing grass.script, so there is still some confusion related to that. However, rather than mixing all together, it seems that these need to be separated from core or organized better in some other way.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant