File tree Expand file tree Collapse file tree 5 files changed +23
-10
lines changed
Expand file tree Collapse file tree 5 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -37,20 +37,24 @@ def check(
3737 fullpath = fullpath ,
3838 with_test_class_names = self .with_test_class_names ,
3939 )
40+ serialized_name = data_name .with_stem (f"serialized_{ data_name .stem } " ).with_suffix (".yml" )
4041
4142 # check the previously registered serialized call from GEE. If it matches the current call,
4243 # we don't need to check the data
4344 with suppress (BaseException ):
4445 check_serialized (
4546 object = ee .Dictionary (data_dict ),
46- path = data_name ,
47+ path = serialized_name ,
4748 datadir = self .datadir ,
4849 original_datadir = self .original_datadir ,
4950 request = self .request ,
5051 with_test_class_names = self .with_test_class_names ,
5152 )
5253 return
5354
55+ # delete the previously created file if wasn't successful
56+ serialized_name .unlink (missing_ok = True )
57+
5458 # if it needs to be checked, we need to round the float values to the same precision as the
5559 # reference file
5660 data = round_data (data_dict .getInfo (), prescision )
Original file line number Diff line number Diff line change @@ -43,20 +43,24 @@ def check(
4343 fullpath = fullpath ,
4444 with_test_class_names = self .with_test_class_names ,
4545 )
46+ serialized_name = data_name .with_stem (f"serialized_{ data_name .stem } " ).with_suffix (".yml" )
4647
4748 # check the previously registered serialized call from GEE. If it matches the current call,
4849 # we don't need to check the data
4950 with suppress (BaseException ):
5051 check_serialized (
5152 object = data_fc ,
52- path = data_name ,
53+ path = serialized_name ,
5354 datadir = self .datadir ,
5455 original_datadir = self .original_datadir ,
5556 request = self .request ,
5657 with_test_class_names = self .with_test_class_names ,
5758 )
5859 return
5960
61+ # delete the previously created file if wasn't successful
62+ serialized_name .unlink (missing_ok = True )
63+
6064 # round the geometry using geopandas to make sre with use the specific number of decimal places
6165 gdf = gpd .GeoDataFrame .from_features (data_fc .getInfo ())
6266 gdf .geometry = gdf .set_precision (grid_size = 10 ** (- prescision )).remove_repeated_points ()
Original file line number Diff line number Diff line change @@ -54,20 +54,24 @@ def check(
5454 fullpath = fullpath ,
5555 with_test_class_names = self .with_test_class_names ,
5656 )
57+ serialized_name = data_name .with_stem (f"serialized_{ data_name .stem } " ).with_suffix (".yml" )
5758
5859 # check the previously registered serialized call from GEE. If it matches the current call,
5960 # we don't need to check the data
6061 with suppress (BaseException ):
6162 check_serialized (
6263 object = data_image ,
63- path = data_name ,
64+ path = serialized_name ,
6465 datadir = self .datadir ,
6566 original_datadir = self .original_datadir ,
6667 request = self .request ,
6768 with_test_class_names = self .with_test_class_names ,
6869 )
6970 return
7071
72+ # delete the previously created file if wasn't successful
73+ serialized_name .unlink (missing_ok = True )
74+
7175 # extract min and max for visualization
7276 minMax = data_image .reduceRegion (ee .Reducer .minMax (), geometry , scale )
7377
Original file line number Diff line number Diff line change @@ -37,20 +37,24 @@ def check(
3737 fullpath = fullpath ,
3838 with_test_class_names = self .with_test_class_names ,
3939 )
40+ serialized_name = data_name .with_stem (f"serialized_{ data_name .stem } " ).with_suffix (".yml" )
4041
4142 # check the previously registered serialized call from GEE. If it matches the current call,
4243 # we don't need to check the data
4344 with suppress (BaseException ):
4445 check_serialized (
4546 object = data_list ,
46- path = data_name ,
47+ path = serialized_name ,
4748 datadir = self .datadir ,
4849 original_datadir = self .original_datadir ,
4950 request = self .request ,
5051 with_test_class_names = self .with_test_class_names ,
5152 )
5253 return
5354
55+ # delete the previously created file if wasn't successful
56+ serialized_name .unlink (missing_ok = True )
57+
5458 # if it needs to be checked, we need to round the float values to the same precision as the
5559 # reference file
5660 data = round_data (data_list .getInfo (), prescision )
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ def check_serialized(
321321
322322 Args:
323323 object: the earthnegine object to check
324- path: the full path to the file to check against. a "serialized" prefix will be added.
324+ path: the full path to the file to check against.
325325 datadir: Fixture embed_data.
326326 original_datadir: Fixture embed_data.
327327 request: Pytest request object.
@@ -334,12 +334,9 @@ def check_serialized(
334334 # serialize the object# extract the data from the computed object
335335 data_dict = json .loads (object .serialize ())
336336
337- # create a filename from the path
338- fullpath = path .with_stem (f"serialized_{ path .stem } " ).with_suffix (".yml" )
339-
340337 # delete the file upstream if force_regen is set
341338 if force_regen is True :
342- fullpath .unlink (missing_ok = True )
339+ path .unlink (missing_ok = True )
343340
344341 def dump (filename : Path ) -> None :
345342 """Dump dict contents to the given filename."""
@@ -362,6 +359,6 @@ def dump(filename: Path) -> None:
362359 check_fn = partial (check_text_files , encoding = "UTF-8" ),
363360 dump_fn = dump ,
364361 extension = ".yml" ,
365- fullpath = fullpath ,
362+ fullpath = path ,
366363 with_test_class_names = with_test_class_names ,
367364 )
You can’t perform that action at this time.
0 commit comments