Re: [GRASS-dev] Which is the correct WIND convention for creating a new mapset?

2019-05-10 Thread Markus Metz
On Thu, May 9, 2019 at 10:01 AM Panagiotis Mavrogiorgos 
wrote:
>
> Thank you markus
>
> On Wed, May 8, 2019 at 10:54 PM Markus Metz 
wrote:
>>
>> It depends. g.mapset changes the current mapset (and location and
database). It might also create a new mapset in an existing location, but
it always switches. If that switch is not desired, GISRC must be adjusted
to the original GRASS session. G_make_mapset() is a C function and should
be used by C modules. Of course you could use it with pygrass, but pygrass
initializes the GRASS C libraries, and you need to take care that
initializations are properly updated when changing mapsets (and locations).
Creating a new mapset in an existing location is not difficult: create the
folder and copy DEFAULT_WIND from PERMANENT to WIND in the new mapset.
Maybe create a new function create_mapset() in lib/python/script/utils.py?
>
>
> Generally speaking, I think it is important that the API comes first.
Once some functionality has been implemented in a library it can then be
exposed to the end users in multiple ways (e.g. CLI, REST, whatever). Among
other things, by implementing the API first, it is much easier to test the
code + you follow DRY.
>
> This is why I mentioned "G_make_mapset()" which seems to already be
implementing this functionality and which, as you mentioned, is exposed to
Python via pygrass. The idea is that if in the future the process of
creating a mapset becomes more complicated, then we would only have to
update "G_make_mapset()". That being said I am not familiar enough with the
initialization process so I can't really argue if a pure python
implementation is needed or not.

In this particular case I think a Python implementation would help because
1) it is really simple to create a new mapset in any existing location, 2)
the overhead of using pygrass is not needed in this case: most important
developer's rule: keep it as simple as possible.
>
> Now to become more specific, as an API user, I think would find it
strange that calling the "create_mapset()" function also changes the
current mapset. I like it when things are explicit + it makes it easier to
document and test. As far as implementing "create_mapset()" in
lib/python/script/utils.py, why not move the relevant functions from
"gui/wxpython/startup/utils.py" and have the GUI code import them from the
"grass" lib?

the suggested new function "create_mapset()" should only create a new
mapset, check if it succeeded in doing so, and not change to the new
mapset. The idea is that any python code that wants to create a new mapset
does not use its own method but instead uses this new function from
lib/python/script/utils.py.

Markus M
___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Re: [GRASS-dev] Which is the correct WIND convention for creating a new mapset?

2019-05-09 Thread Panagiotis Mavrogiorgos
Thank you markus

On Wed, May 8, 2019 at 10:54 PM Markus Metz 
wrote:

> It depends. g.mapset changes the current mapset (and location and
> database). It might also create a new mapset in an existing location, but
> it always switches. If that switch is not desired, GISRC must be adjusted
> to the original GRASS session. G_make_mapset() is a C function and should
> be used by C modules. Of course you could use it with pygrass, but pygrass
> initializes the GRASS C libraries, and you need to take care that
> initializations are properly updated when changing mapsets (and locations).
> Creating a new mapset in an existing location is not difficult: create the
> folder and copy DEFAULT_WIND from PERMANENT to WIND in the new mapset.
> Maybe create a new function create_mapset() in lib/python/script/utils.py?
>

Generally speaking, I think it is important that the API comes first. Once
some functionality has been implemented in a library it can then be exposed
to the end users in multiple ways (e.g. CLI, REST, whatever). Among other
things, by implementing the API first, it is much easier to test the code +
you follow DRY.

This is why I mentioned "G_make_mapset()" which seems to already be
implementing this functionality and which, as you mentioned, is exposed to
Python via pygrass. The idea is that if in the future the process of
creating a mapset becomes more complicated, then we would only have to
update "G_make_mapset()". That being said I am not familiar enough with the
initialization process so I can't really argue if a pure python
implementation is needed or not.

Now to become more specific, as an API user, I think would find it strange
that calling the "create_mapset()" function also changes the current
mapset. I like it when things are explicit + it makes it easier to document
and test. As far as implementing "create_mapset()" in
lib/python/script/utils.py, why not move the relevant functions from
"gui/wxpython/startup/utils.py" and have the GUI code import them from the
"grass" lib?

BTW, those functions do need a few improvements; e.g. rename_mapset()
should fail to rename PERMANENT etc, but let's move them first and we can
do that later.


> >>> I adjusted the wxGUI startup wizard and the tests in trunk r74472,3
> (the tests should use g.mapset -c, not yet implemented)
> >
> >
> > I think that in the nc_spm_full_v2alpha dataset WIND and DEFAULT_WIND
> differ, so 74473 might break any tests that don't explicitly set the region
> themselves (which of course they should). We will see.
>
> IMHO, tests need to set the region themselves, just as users. The current
> region is such a fundamental concept of GRASS (raster processing) that I
> regard it as a mistake if the current region is not explicitly set to
> actual demands.
>

I completely agree that tests that don't set the region themselves should
be fixed.

all the best,
Panos
___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Re: [GRASS-dev] Which is the correct WIND convention for creating a new mapset?

2019-05-08 Thread Markus Metz
On Wed, May 8, 2019 at 10:22 AM Panagiotis Mavrogiorgos 
wrote:
>
>
>
> On Tue, May 7, 2019 at 11:03 PM Markus Metz 
wrote:
>>
>>
>>
>> On Tue, May 7, 2019 at 10:20 AM Panagiotis Mavrogiorgos 
wrote:
>> >
>> >
>> >
>> > On Mon, May 6, 2019 at 9:38 PM Markus Metz <
markus.metz.gisw...@gmail.com> wrote:
>> >>
>> >>
>> >>
>> >> On Mon, May 6, 2019 at 6:21 PM Panagiotis Mavrogiorgos <
pma...@gmail.com> wrote:
>> >> >
>> >> > Hello all,
>> >> >
>> >> > I am a bit confused WRT what the expected WIND should be when you
create a new mapset.
>> >>
>> >> > [...]
>> >>
>> >> > Is there an established convention?
>> >>
>> >> IMHO, new mapsets should use DEFAULT_WIND from PERMANENT.
>> >
>> >
>> > Thank you Markus, that's what I expected, too.
>> >
>> >>
>> >> But the current region of a new mapset is often adjusted, therefore
it does not really matter if DEFAULT_WIND or WIND is used.
>> >
>> >
>> > I don't disagree, but still, I don't see what's the benefit of not
using the same convention everywhere. Furthermore, I truly don't understand
why 4 different implementations are needed.
>>
>> True, g.mapset -c should be used whenever possible.
>
>
> I would argue that it is G_make_mapset() that should be used whenever
possible :)
> (which of course, is being used by g.mapset -c, too)

It depends. g.mapset changes the current mapset (and location and
database). It might also create a new mapset in an existing location, but
it always switches. If that switch is not desired, GISRC must be adjusted
to the original GRASS session. G_make_mapset() is a C function and should
be used by C modules. Of course you could use it with pygrass, but pygrass
initializes the GRASS C libraries, and you need to take care that
initializations are properly updated when changing mapsets (and locations).
Creating a new mapset in an existing location is not difficult: create the
folder and copy DEFAULT_WIND from PERMANENT to WIND in the new mapset.
Maybe create a new function create_mapset() in lib/python/script/utils.py?

>>> I adjusted the wxGUI startup wizard and the tests in trunk r74472,3
(the tests should use g.mapset -c, not yet implemented)
>
>
> I think that in the nc_spm_full_v2alpha dataset WIND and DEFAULT_WIND
differ, so 74473 might break any tests that don't explicitly set the region
themselves (which of course they should). We will see.

IMHO, tests need to set the region themselves, just as users. The current
region is such a fundamental concept of GRASS (raster processing) that I
regard it as a mistake if the current region is not explicitly set to
actual demands.

Markus M
___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Re: [GRASS-dev] Which is the correct WIND convention for creating a new mapset?

2019-05-08 Thread Panagiotis Mavrogiorgos
On Tue, May 7, 2019 at 11:03 PM Markus Metz 
wrote:

>
>
> On Tue, May 7, 2019 at 10:20 AM Panagiotis Mavrogiorgos 
> wrote:
> >
> >
> >
> > On Mon, May 6, 2019 at 9:38 PM Markus Metz <
> markus.metz.gisw...@gmail.com> wrote:
> >>
> >>
> >>
> >> On Mon, May 6, 2019 at 6:21 PM Panagiotis Mavrogiorgos <
> pma...@gmail.com> wrote:
> >> >
> >> > Hello all,
> >> >
> >> > I am a bit confused WRT what the expected WIND should be when you
> create a new mapset.
> >>
> >> > [...]
> >>
> >> > Is there an established convention?
> >>
> >> IMHO, new mapsets should use DEFAULT_WIND from PERMANENT.
> >
> >
> > Thank you Markus, that's what I expected, too.
> >
> >>
> >> But the current region of a new mapset is often adjusted, therefore it
> does not really matter if DEFAULT_WIND or WIND is used.
> >
> >
> > I don't disagree, but still, I don't see what's the benefit of not using
> the same convention everywhere. Furthermore, I truly don't understand why 4
> different implementations are needed.
>
> True, g.mapset -c should be used whenever possible.
>

I would argue that it is G_make_mapset() that should be used whenever
possible :)
(which of course, is being used by g.mapset -c, too)

I adjusted the wxGUI startup wizard and the tests in trunk r74472,3 (the
> tests should use g.mapset -c, not yet implemented)
>

I think that in the nc_spm_full_v2alpha dataset WIND and DEFAULT_WIND
differ, so 74473 might break any tests that don't explicitly set the region
themselves (which of course they should). We will see.

P.
___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Re: [GRASS-dev] Which is the correct WIND convention for creating a new mapset?

2019-05-07 Thread Markus Metz
On Tue, May 7, 2019 at 10:20 AM Panagiotis Mavrogiorgos 
wrote:
>
>
>
> On Mon, May 6, 2019 at 9:38 PM Markus Metz 
wrote:
>>
>>
>>
>> On Mon, May 6, 2019 at 6:21 PM Panagiotis Mavrogiorgos 
wrote:
>> >
>> > Hello all,
>> >
>> > I am a bit confused WRT what the expected WIND should be when you
create a new mapset.
>>
>> > [...]
>>
>> > Is there an established convention?
>>
>> IMHO, new mapsets should use DEFAULT_WIND from PERMANENT.
>
>
> Thank you Markus, that's what I expected, too.
>
>>
>> But the current region of a new mapset is often adjusted, therefore it
does not really matter if DEFAULT_WIND or WIND is used.
>
>
> I don't disagree, but still, I don't see what's the benefit of not using
the same convention everywhere. Furthermore, I truly don't understand why 4
different implementations are needed.

True, g.mapset -c should be used whenever possible. I adjusted the wxGUI
startup wizard and the tests in trunk r74472,3 (the tests should use
g.mapset -c, not yet implemented)

Markus M
___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Re: [GRASS-dev] Which is the correct WIND convention for creating a new mapset?

2019-05-07 Thread Panagiotis Mavrogiorgos
On Mon, May 6, 2019 at 9:38 PM Markus Metz 
wrote:

>
>
> On Mon, May 6, 2019 at 6:21 PM Panagiotis Mavrogiorgos 
> wrote:
> >
> > Hello all,
> >
> > I am a bit confused WRT what the expected WIND should be when you create
> a new mapset.
>
> [...]
>
> Is there an established convention?
>
> IMHO, new mapsets should use DEFAULT_WIND from PERMANENT.
>

Thank you Markus, that's what I expected, too.


> But the current region of a new mapset is often adjusted, therefore it
> does not really matter if DEFAULT_WIND or WIND is used.
>

I don't disagree, but still, I don't see what's the benefit of not using
the same convention everywhere. Furthermore, I truly don't understand why 4
different implementations are needed.

with kind regards,
P.
___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Re: [GRASS-dev] Which is the correct WIND convention for creating a new mapset?

2019-05-06 Thread Markus Metz
On Mon, May 6, 2019 at 6:21 PM Panagiotis Mavrogiorgos 
wrote:
>
> Hello all,
>
> I am a bit confused WRT what the expected WIND should be when you create
a new mapset.
>
> Some functions copy DEFAULT_WIND from PERMANENT. E.g.:
>
> lib/gis/make_mapset.c
> pygrass.gis.make_mapset()
> the grass executable
>
> While others copy WIND from PERMANENT. E.g.
>
> the tests
> gui.wxpython.startup.create_mapset()
>
> Is there an established convention?

IMHO, new mapsets should use DEFAULT_WIND from PERMANENT. But the current
region of a new mapset is often adjusted, therefore it does not really
matter if DEFAULT_WIND or WIND is used.

my2c

Markus M
___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev