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: add create_project() with same functionality as create_location() #3513

Merged
merged 7 commits into from
Apr 3, 2024

Conversation

chaedri
Copy link
Contributor

@chaedri chaedri commented Mar 18, 2024

As we begin renaming location to project, it would be nice to have a create_project() function that works the same as create_location.

This is particularly nice in notebooks because these function work without an active GRASS session so users can use a work flow that I think is very intuitive:

  1. import grass.script and grass.jupyter
  2. create_project() to make a new project
  3. gj.init() to start the session in the new project

This PR also includes additional path support. For example, all the following lines will create a new project:

# just project name (creates project in current working directory)
gs.create_project("nags_head", epsg="32119") 

# grassdata path and name of project
gs.create_project("~/grassdata", name="nags_head", epsg="32119") 

# full path to new project
gs.create_project("~/grassdata/nags_head", epsg="32119") # full path to new project

@chaedri chaedri requested a review from wenzeslaus March 18, 2024 17:49
@chaedri chaedri changed the title grass.script: add create_project() with same function as create_location() grass.script: add create_project() with same functionality as create_location() Mar 18, 2024
@chaedri chaedri added Python Related code is in Python enhancement New feature or request labels Mar 18, 2024
@chaedri chaedri requested a review from veroandreo March 18, 2024 17:52
veroandreo
veroandreo previously approved these changes Mar 19, 2024
Copy link
Contributor

@veroandreo veroandreo left a comment

Choose a reason for hiding this comment

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

This is a nice addition! Works as expected, at least in the tests I did :)

python/grass/script/core.py Outdated Show resolved Hide resolved
@echoix
Copy link
Member

echoix commented Mar 19, 2024

I approve the concept, read through it, but I'm leaving reviewing the fine details for someone else. I'm not confident enough in the implications, or if there is something missing with in regards to the transition to "project".

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.

Ultimately, we need to have something like resolve_mapset_path but oriented towards project, specifically. However, at this point, this is the best implementation.

Given the need to support the two different API, a test would be helpful here to check that the different combinations of parameters work. It also seems that a test for existing project is missing.

@chaedri
Copy link
Contributor Author

chaedri commented Apr 2, 2024

Given the need to support the two different API, a test would be helpful here to check that the different combinations of parameters work. It also seems that a test for existing project is missing.

I added two more tests, one that tests providing the full path (i.e. gs.create_project("~/grassdata/nags_head", epsg="32119") and one that tests create_project directly.

@petrasovaa petrasovaa merged commit d32ece4 into OSGeo:main Apr 3, 2024
26 checks passed
@neteler neteler added this to the 8.4.0 milestone Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request libraries Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants