Skip to content

Comments

grass.script: Use description parameter in create_project#6440

Merged
wenzeslaus merged 4 commits intoOSGeo:mainfrom
wenzeslaus:polish-description-parameter-in-create_project
Oct 3, 2025
Merged

grass.script: Use description parameter in create_project#6440
wenzeslaus merged 4 commits intoOSGeo:mainfrom
wenzeslaus:polish-description-parameter-in-create_project

Conversation

@wenzeslaus
Copy link
Member

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.

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.
@github-actions github-actions bot added Python Related code is in Python libraries tests Related to Test Suite labels Oct 3, 2025
@wenzeslaus wenzeslaus merged commit a399ea3 into OSGeo:main Oct 3, 2025
27 checks passed
@wenzeslaus wenzeslaus deleted the polish-description-parameter-in-create_project branch October 3, 2025 20:05
@github-actions github-actions bot added this to the 8.5.0 milestone Oct 3, 2025
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

Labels

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.

2 participants