[GRASS-dev] gunittest test temporal dataset

Hi devs,

is there a way to test if a temporal dataset exists or not?
something like assertRasterExists

in the case it doesn't exist it could be useful?

--
ciao
Luca

www.lucadelu.org

Hi Luca,

Not that I am aware of. I use to parse output from t.list to check if a STDS exists…

Cheers
Stefan

Gesendet: Montag, 27. März 2023 um 11:31 Uhr
Von: “Luca Delucchi” lucadeluge@gmail.com
An: “GRASS-dev” grass-dev@lists.osgeo.org
Betreff: [GRASS-dev] gunittest test temporal dataset
Hi devs,

is there a way to test if a temporal dataset exists or not?
something like assertRasterExists

in the case it doesn’t exist it could be useful?


ciao
Luca

www.lucadelu.org


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

Il lun 27 mar 2023, 13:21 Stefan Blumentrath <Stefan.Blumentrath@gmx.de> ha scritto:

Hi Luca,

Hi Stefan,

Not that I am aware of. I use to parse output from t.list to check if a STDS exists…

Yes this was my idea too. Do you have an example?

Cheers
Stefan

Cheers
Luca

Hi again,

Looking at my example I see that there is in fact a possibility to check existence of an STDS without t.list. See:
https://github.com/NVE/actinia_modules_nve/blob/036a4c85664a9015d5ca13ed6f40bdcc79bbfcb2/src/temporal/t.rast.reclass/t.rast.reclass.py#L294-L316

You could basically do:

import grass.temporal as tgis
# Initialize TGIS
tgis.init()
# Connect to TGIS DB
dbif = tgis.SQLDatabaseInterfaceConnection()
dbif.connect()

output_strds = tgis.factory.dataset_factory("strds", "MY_STRDS_NAME")
output_strds_exists = output_strds.is_in_db(dbif)
assertTrue(output_strds_exists)

Maybe worth considering to add a method for that in the unittest module!?!

Cheers,
Stefan

Gesendet: Montag, 27. März 2023 um 14:15 Uhr
Von: "Luca Delucchi" <lucadeluge@gmail.com>
An: "Stefan Blumentrath" <Stefan.Blumentrath@gmx.de>
Cc: "GRASS-dev" <grass-dev@lists.osgeo.org>
Betreff: Re: [GRASS-dev] gunittest test temporal dataset

Il lun 27 mar 2023, 13:21 Stefan Blumentrath <Stefan.Blumentrath@gmx.de[mailto:Stefan.Blumentrath@gmx.de]> ha scritto:

Hi Luca,

Hi Stefan,

Not that I am aware of. I use to parse output from t.list to check if a STDS exists...

Yes this was my idea too. Do you have an example?

Cheers
Stefan

Cheers
Luca