-
-
Notifications
You must be signed in to change notification settings - Fork 368
grass.app: Move lock to mapset subcommand #6437
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
Draft
wenzeslaus
wants to merge
5
commits into
OSGeo:main
Choose a base branch
from
wenzeslaus:add-create-subcommands
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+79
−35
Conversation
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 enables access to the subcommands from the main command. It keeps the commands not documeneted at the top level, so they remain hidden and experimental. The lock and unlock, now under 'grass mapset lock' and 'grass mapset unlock', are accessible from outside of GRASS through CLI (no Python API or GRASS tools), providing a way of other applications (such as QGIS) to use GRASS locking when accessing GRASS mapsets. Given that lock and unlock are under mapset (they are too low level to be at subcommand top level), it is clear there should be also project. The create_project function is readily available for CLI use (espetially after OSGeo#6415), so it is now under 'grass project create' and the subcommand is utilized in tests. For symmetry, this adds also 'grass mapset create' which uses the semi-internal function grass.grassdb.create.create_mapset. The function parameters were adjusted to allow for a single path being provided (which was already supported through path resolution function). The create_project function was also improved by adding description parameter as full word replacing (but keeping) desc parameter. The behavior was sligtly changes so that MYNAME is only created when description is provided which is what the documenetation suggests ('desc...creates MYNAME file'), but it was implemented that MYNAME was always created even if empty. Finally, missing documentation for the CRS parameter was added. The new structure in the cli file is that project and mapset subcommand parser definitions have their own functions. This minimizes name conflicts and keeps the main function short. Finally, 'grass run' subcommad now has --project to use an existing project (defaulting to PERMANENT mapset) or a mapset within that project. This is needed now for testing the created project using the subcommand interface.
…not desc in tests.
This was referenced Oct 3, 2025
This is now a draft because I moves some of the pieces to separate PRs, but this now depends on these PRs and it will also need little more cleanup. |
wenzeslaus
added a commit
that referenced
this pull request
Oct 3, 2025
This adds description parameter to create_project as a full word replacing (but keeping) the desc parameter. The behavior slightly changes so that MYNAME (project description file) is only created when description is provided. This is what the current documentation suggests ('desc...creates MYNAME file'), but it was implemented that MYNAME was always created even if empty. The description file is now created for empty text (description is empty), but not for None (no description). This is a project description specific part of #6437.
wenzeslaus
added a commit
that referenced
this pull request
Oct 3, 2025
The create_project function is readily available for CLI use especially with the new crs parameter (added in #6415), so this is adding the functionality under as `project create` subcommand. All create_project parameters are exposed, so the user is not limited to what crs parameter can currently handle. This will be useful in tests of the subcommand CLI itself if we want to use the other subcommands rather than the Python functions in the tests (of subcommands). It is used for lock and unlock tests in #6437. A --project parameter is added to the run subcommand which now can use existing project instead of creating a new one. This makes subcommand `run --project project/path ...` roughly equivalent to `grass project/path --exec ...`. The functionality is used in the test to check the resulting project CRS. Example subcomands: project create --crs EPSG:3358 /tmp/project_1 run --project /tmp/project_1 g.mapset -p Adds missing documentation for crs parameter of create_project. Also, this uses the description parameter from #6440 not desc. Implementation of the subcommand now uses StackExit context manager to handle the only-sometimes-needed temporary directory.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The lock and unlock subcommands are operating on a mapset and are low-level (they specifically just lock and unlock and don't do anything with any session). So, this is moving them under a new top-level subcommand mapset.
With the lock subcommands being accessible outside of GRASS through CLI without a Python API or a GRASS tools (with or without #6442), other applications which can call subprocesses (such as QGIS) can use GRASS locking when accessing GRASS mapsets.
This is using the new structure in the cli.py file with parser definitions having their own functions (minimizing name conflicts between parses and keeping the main function short), but additionally the interface and execution code are placed together because they would be changed at the same time.
Waiting for #6462: Additionally, for symmetry with project create, this adds a new mapset create subcommand which is used in the test. The creation uses the semi-internal function grass.grassdb.create.create_mapset. The function parameters were adjusted to allow for a single path being provided (which was already supported through path resolution function).
Examples
Assuming #6442 in the examples to simply the commands, but setting up
PYTHONPATH
and usingpython -m grass.app
would work too.grass mapset lock
grass mapset create
(withgrass project create
)