pythonlib: fix pygrass Module tests by making it picklable#1407
Merged
Conversation
Slightly changes API by making popen a private variable
Contributor
Author
|
This should fix https://trac.osgeo.org/grass/ticket/3799 |
wenzeslaus
requested changes
Mar 14, 2021
wenzeslaus
left a comment
Member
There was a problem hiding this comment.
I think some related fixes are needed in t.rast.accumulate code which now fails with AttributeError: 'Module' object has no attribute 'popen', for example in this context:
Running test.t.rast.accdetect.reverse (./temporal/t.rast.accdetect)...
========================================================================
+ g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 -p
+ export GRASS_OVERWRITE=1
+ r.mapcalc expr=temp_6 = 5
+ r.mapcalc expr=temp_5 = 10
+ r.mapcalc expr=temp_4 = 15
+ r.mapcalc expr=temp_3 = 20
+ r.mapcalc expr=temp_2 = 25
+ r.mapcalc expr=temp_1 = 30
+ t.create type=strds temporaltype=absolute output=temp_abs1 title=A test descr=A test
Default TGIS driver / database set to:
driver: sqlite
database: $GISDBASE/$LOCATION_NAME/$MAPSET/tgis/sqlite.db
WARNING: Temporal database connection defined as:
/home/runner/nc_spm_full_v2alpha2/__temporal_t_rast_accdetect_test.t.rast.accdetect.reverse/tgis/sqlite.db
But database file does not exist.
Creating temporal database: /home/runner/nc_spm_full_v2alpha2/__temporal_t_rast_accdetect_test.t.rast.accdetect.reverse/tgis/sqlite.db
+ t.register -i type=raster input=temp_abs1 maps=temp_1,temp_2,temp_3,temp_4,temp_5,temp_6 start=2001-01-01 increment=2 months
Gathering map information...
0..ERROR: Unable to read band reference file for raster map <temp_1@__temporal_t_rast_accdetect_test.t.rast.accdetect.reverse>
ERROR: Unable to read band reference file for raster map <temp_2@__temporal_t_rast_accdetect_test.t.rast.accdetect.reverse>
ERROR: Unable to read band reference file for raster map <temp_3@__temporal_t_rast_accdetect_test.t.rast.accdetect.reverse>
ERROR: Unable to read band reference file for raster map <temp_4@__temporal_t_rast_accdetect_test.t.rast.accdetect.reverse>
ERROR: Unable to read band reference file for raster map <temp_5@__temporal_t_rast_accdetect_test.t.rast.accdetect.reverse>
ERROR: Unable to read band reference file for raster map <temp_6@__temporal_t_rast_accdetect_test.t.rast.accdetect.reverse>
100
Registering maps in the temporal database...
Registering maps in the space time dataset...
0..Updating space time dataset...
100
+ t.rast.accumulate -r input=temp_abs1 output=temp_accumulation base=temp_acc limits=10,25 start=2001-01-01 gran=2 months cycle=12 months suffix=num%03
Processing cycle 2001-01-01 00:00:00 - 2002-01-01 00:00:00
0..12..25..37..50..62..75..87..100
Traceback (most recent call last):
File "scripts/t.rast.accumulate", line 569, in <module>
main()
File "scripts/t.rast.accumulate", line 499, in main
if accmod.popen.returncode != 0:
AttributeError: 'Module' object has no attribute 'popen'
========================================================================
test.t.rast.accdetect.reverse from ./temporal/t.rast.accdetect failed
Running test.t.rast.accdetect (./temporal/t.rast.accdetect)...
========================================================================
+ g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 -p
+ export GRASS_OVERWRITE=1
+ r.mapcalc expr=temp_1 = 5
+ r.mapcalc expr=temp_2 = 10
+ r.mapcalc expr=temp_3 = 15
+ r.mapcalc expr=temp_4 = 20
+ r.mapcalc expr=temp_5 = 25
+ r.mapcalc expr=temp_6 = 30
+ t.create type=strds temporaltype=absolute output=temp_abs1 title=A test descr=A test
Default TGIS driver / database set to:
driver: sqlite
database: $GISDBASE/$LOCATION_NAME/$MAPSET/tgis/sqlite.db
WARNING: Temporal database connection defined as:
/home/runner/nc_spm_full_v2alpha2/__temporal_t_rast_accdetect_test.t.rast.accdetect/tgis/sqlite.db
But database file does not exist.
Creating temporal database: /home/runner/nc_spm_full_v2alpha2/__temporal_t_rast_accdetect_test.t.rast.accdetect/tgis/sqlite.db
+ t.register -i type=raster input=temp_abs1 maps=temp_1,temp_2,temp_3,temp_4,temp_5,temp_6 start=2001-01-01 increment=2 months
Gathering map information...
0..ERROR: Unable to read band reference file for raster map <temp_1@__temporal_t_rast_accdetect_test.t.rast.accdetect>
ERROR: Unable to read band reference file for raster map <temp_2@__temporal_t_rast_accdetect_test.t.rast.accdetect>
ERROR: Unable to read band reference file for raster map <temp_3@__temporal_t_rast_accdetect_test.t.rast.accdetect>
ERROR: Unable to read band reference file for raster map <temp_4@__temporal_t_rast_accdetect_test.t.rast.accdetect>
ERROR: Unable to read band reference file for raster map <temp_5@__temporal_t_rast_accdetect_test.t.rast.accdetect>
ERROR: Unable to read band reference file for raster map <temp_6@__temporal_t_rast_accdetect_test.t.rast.accdetect>
100
Registering maps in the temporal database...
Registering maps in the space time dataset...
0..Updating space time dataset...
100
+ t.rast.accumulate input=temp_abs1 output=temp_accumulation base=temp_acc limits=10,25 start=2001-01-01 gran=2 months cycle=12 months suffix=num%03
Processing cycle 2001-01-01 00:00:00 - 2002-01-01 00:00:00
0..12..25..37..50..62..75..87..100
Traceback (most recent call last):
File "scripts/t.rast.accumulate", line 569, in <module>
main()
File "scripts/t.rast.accumulate", line 499, in main
if accmod.popen.returncode != 0:
AttributeError: 'Module' object has no attribute 'popen'
========================================================================
wenzeslaus
approved these changes
Mar 15, 2021
lindakarlovska
pushed a commit
to lindakarlovska/grass
that referenced
this pull request
Mar 15, 2021
Slightly changes API by making popen a private variable
marisn
pushed a commit
to marisn/grass
that referenced
this pull request
Mar 22, 2021
Slightly changes API by making popen a private variable
petrasovaa
added a commit
to petrasovaa/grass
that referenced
this pull request
May 31, 2021
petrasovaa
added a commit
that referenced
this pull request
May 31, 2021
ninsbl
pushed a commit
to ninsbl/grass
that referenced
this pull request
Oct 26, 2022
Slightly changes API by making popen a private variable
ninsbl
pushed a commit
to ninsbl/grass
that referenced
this pull request
Feb 17, 2023
Slightly changes API by making popen a private variable
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
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.
To make it picklable, set popen attribute to None and add
__reduce__to TypeDict.Slightly changes API by making popen a private variable.