Skip to content

Commit

Permalink
prepare release 0.34 (#270)
Browse files Browse the repository at this point in the history
* bump version; updated changelog

* exclude unreachable or less significant statements from test coverage
  • Loading branch information
ungarj committed Jul 8, 2020
1 parent 599765b commit 845d7d3
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 34 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -2,6 +2,13 @@
Changelog
#########

----
0.34
----
* speed up extension loading by using `importlib-metadata` and `importlib-resources` instead of `pkg_resources` (#267)
* use `boto` paging to reduce requests to S3 bucket (#268)


----
0.33
----
Expand Down
2 changes: 1 addition & 1 deletion mapchete/__init__.py
Expand Up @@ -7,7 +7,7 @@


__all__ = ['open', 'count_tiles', 'Mapchete', 'MapcheteProcess', 'Timer']
__version__ = "0.33"
__version__ = "0.34"


logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions mapchete/_core.py
Expand Up @@ -305,7 +305,7 @@ def execute(self, process_tile, raise_nodata=False):
TileProcess(tile=process_tile, config=self.config).execute()
)
except MapcheteNodataTile:
if raise_nodata:
if raise_nodata: # pragma: no cover
raise
else:
return self.config.output.empty(process_tile)
Expand Down Expand Up @@ -482,7 +482,7 @@ def _execute_using_cache(self, process_tile):
if not process_event:
self.current_processes[process_tile.id] = threading.Event()
# Wait and return.
if process_event:
if process_event: # pragma: no cover
process_event.wait()
return self.process_tile_cache[process_tile.id]
else:
Expand Down
2 changes: 1 addition & 1 deletion mapchete/_processing.py
Expand Up @@ -546,7 +546,7 @@ def _run_multi(

for i, zoom in enumerate(zoom_levels):

if skip_output_check:
if skip_output_check: # pragma: no cover
# don't check outputs and simply proceed
todo = process.get_process_tiles(zoom)
else:
Expand Down
6 changes: 3 additions & 3 deletions mapchete/cli/default/serve.py
Expand Up @@ -53,7 +53,7 @@ def serve(
)
if os.environ.get("MAPCHETE_TEST") == "TRUE":
logger.debug("don't run flask app, MAPCHETE_TEST environment detected")
else:
else: # pragma: no cover
app.run(
threaded=True, debug=True, port=port, host='0.0.0.0',
extra_files=[mapchete_file]
Expand Down Expand Up @@ -127,7 +127,7 @@ def _tile_response(mp, web_tile, debug):
try:
logger.debug("getting web tile %s", str(web_tile.id))
return _valid_tile_response(mp, mp.get_raw_output(web_tile))
except Exception:
except Exception: # pragma: no cover
logger.exception("getting web tile %s failed", str(web_tile.id))
if debug:
raise
Expand All @@ -144,7 +144,7 @@ def _valid_tile_response(mp, data):
response = make_response(send_file(out_data, mime_type))
elif isinstance(out_data, list):
response = make_response(jsonify(data))
else:
else: # pragma: no cover
raise TypeError("invalid response type for web")
response.headers['Content-Type'] = mime_type
response.cache_control.no_write = True
Expand Down
8 changes: 5 additions & 3 deletions mapchete/config.py
Expand Up @@ -666,7 +666,9 @@ def get_zoom_levels(process_zoom_levels=None, init_zoom_levels=None):
return process_zoom_levels
else:
init_zoom_levels = validate_zooms(init_zoom_levels)
if not set(init_zoom_levels).issubset(set(process_zoom_levels)):
if not set(
init_zoom_levels
).issubset(set(process_zoom_levels)): # pragma: no cover
raise ValueError("init zooms must be a subset of process zoom")
return init_zoom_levels

Expand Down Expand Up @@ -932,7 +934,7 @@ def _element_at_zoom(name, element, zoom):
else:
return element
# Return all other types as they are.
else:
else: # pragma: no cover
return element


Expand Down Expand Up @@ -1002,7 +1004,7 @@ def _map_to_new_config(config):
except Exception as e:
raise MapcheteConfigError(e)

if "type" in config["output"]:
if "type" in config["output"]: # pragma: no cover
warnings.warn(DeprecationWarning("'type' is deprecated and should be 'grid'"))
if "grid" not in config["output"]:
config["output"]["grid"] = config["output"].pop("type")
Expand Down
6 changes: 3 additions & 3 deletions mapchete/formats/__init__.py
Expand Up @@ -183,7 +183,7 @@ def params_to_dump(params):
def read_output_metadata(metadata_json):
params = read_json(metadata_json)
grid = params["pyramid"]["grid"]
if grid["type"] == "geodetic" and grid["shape"] == [2, 1]:
if grid["type"] == "geodetic" and grid["shape"] == [2, 1]: # pragma: no cover
warnings.warn(
DeprecationWarning(
"Deprecated grid shape ordering found. "
Expand Down Expand Up @@ -227,14 +227,14 @@ def write_output_metadata(output_params):
current_params = params_to_dump(output_params)
logger.debug("current output parameters: %s", pformat(current_params))
current_tp = BufferedTilePyramid(**current_params["pyramid"])
if existing_tp != current_tp:
if existing_tp != current_tp: # pragma: no cover
raise MapcheteConfigError(
"pyramid definitions between existing and new output do not match: "
"%s != %s" % (existing_tp, current_tp)
)
existing_format = existing_params["driver"]["format"]
current_format = current_params["driver"]["format"]
if existing_format != current_format:
if existing_format != current_format: # pragma: no cover
raise MapcheteConfigError(
"existing output format does not match new output format: "
"%s != %s" % (
Expand Down
6 changes: 3 additions & 3 deletions mapchete/formats/base.py
Expand Up @@ -154,7 +154,7 @@ class OutputDataBaseFunctions():
def __init__(self, output_params, readonly=False, **kwargs):
"""Initialize."""
self.pixelbuffer = output_params["pixelbuffer"]
if "type" in output_params:
if "type" in output_params: # pragma: no cover
warnings.warn(DeprecationWarning("'type' is deprecated and should be 'grid'"))
if "grid" not in output_params:
output_params["grid"] = output_params.pop("type")
Expand Down Expand Up @@ -421,7 +421,7 @@ def tiles_exist(self, process_tile=None, output_tile=None):
-------
exists : bool
"""
if process_tile and output_tile:
if process_tile and output_tile: # pragma: no cover
raise ValueError("just one of 'process_tile' and 'output_tile' allowed")
if process_tile:
return any(
Expand Down Expand Up @@ -504,7 +504,7 @@ def tiles_exist(self, process_tile=None, output_tile=None):
exists : bool
"""
# TODO
raise NotImplementedError
raise NotImplementedError # pragma: no cover


class SingleFileOutputWriter(OutputDataWriter, SingleFileOutputReader):
Expand Down
10 changes: 5 additions & 5 deletions mapchete/formats/default/geojson.py
Expand Up @@ -98,7 +98,7 @@ def read(self, output_tile, **kwargs):
for i in ("does not exist in the file system", "No such file or directory"):
if i in str(e):
return self.empty(output_tile)
else:
else: # pragma: no cover
raise

def is_valid_with_config(self, config):
Expand All @@ -119,7 +119,7 @@ def is_valid_with_config(self, config):
if config["schema"]["geometry"] not in [
"Geometry", "Point", "MultiPoint", "Line", "MultiLine",
"Polygon", "MultiPolygon"
]:
]: # pragma: no cover
raise TypeError("invalid geometry type")
return True

Expand Down Expand Up @@ -179,13 +179,13 @@ def write(self, process_tile, data):
"""
if data is None or len(data) == 0:
return
if not isinstance(data, (list, types.GeneratorType)):
if not isinstance(data, (list, types.GeneratorType)): # pragma: no cover
raise TypeError(
"GeoJSON driver data has to be a list or generator of GeoJSON objects"
)

data = list(data)
if not len(data):
if not len(data): # pragma: no cover
logger.debug("no features to write")
else:
# in case of S3 output, create an boto3 resource
Expand Down Expand Up @@ -243,7 +243,7 @@ def read(self, validity_check=True, no_neighbors=False, **kwargs):
features : list
GeoJSON-like list of features
"""
if no_neighbors:
if no_neighbors: # pragma: no cover
raise NotImplementedError()
return self._from_cache(validity_check=validity_check)

Expand Down
4 changes: 2 additions & 2 deletions mapchete/formats/default/png_hillshade.py
Expand Up @@ -173,7 +173,7 @@ def for_web(self, data):
"""
return (
memory_file(self._prepare_array(data), self.profile()), "image/png"
)
) # pragma: no cover

def empty(self, process_tile):
"""
Expand Down Expand Up @@ -217,7 +217,7 @@ def write(self, process_tile, data):
"""
data = self._prepare_array(data)

if data.mask.all():
if data.mask.all(): # pragma: no cover
logger.debug("data empty, nothing to write")
else:
# in case of S3 output, create an boto3 resource
Expand Down
8 changes: 5 additions & 3 deletions mapchete/formats/default/raster_file.py
Expand Up @@ -126,7 +126,7 @@ def exists(self):
-------
file exists : bool
"""
return os.path.isfile(self.path)
return os.path.isfile(self.path) # pragma: no cover


class InputTile(base.InputTile):
Expand Down Expand Up @@ -218,5 +218,7 @@ def get_segmentize_value(input_file=None, tile_pyramid=None):
segmenize value : float
length suggested of line segmentation to reproject file bounds
"""
warnings.warn(DeprecationWarning("get_segmentize_value() has moved to mapchete.io"))
return io.get_segmentize_value(input_file, tile_pyramid)
warnings.warn(
DeprecationWarning("get_segmentize_value() has moved to mapchete.io")
) # pragma: no cover
return io.get_segmentize_value(input_file, tile_pyramid) # pragma: no cover
2 changes: 1 addition & 1 deletion mapchete/formats/default/tile_directory.py
Expand Up @@ -348,7 +348,7 @@ def is_empty(
matching_precision=matching_precision,
matching_max_zoom=matching_max_zoom,
)
) == 0
) == 0 # pragma: no cover

def _get_tiles_paths(
self,
Expand Down
8 changes: 4 additions & 4 deletions mapchete/io/raster.py
Expand Up @@ -483,7 +483,7 @@ def extract_from_array(in_raster=None, in_affine=None, out_tile=None):
-------
extracted array : array
"""
if isinstance(in_raster, ReferencedRaster):
if isinstance(in_raster, ReferencedRaster): # pragma: no cover
in_affine, in_raster = in_raster.affine, in_raster.data

# get range within array
Expand Down Expand Up @@ -743,7 +743,7 @@ def tiles_to_affine_shape(tiles):
-------
Affine, Shape
"""
if not tiles:
if not tiles: # pragma: no cover
raise TypeError("no tiles provided")
pixel_size = tiles[0].pixel_x_size
left, bottom, right, top = (
Expand Down Expand Up @@ -801,7 +801,7 @@ def gen_groups(items):

groups = list(gen_groups(tile_cols))
# in case there is only one group, don't shift
if len(groups) == 1:
if len(groups) == 1: # pragma: no cover
return False
# distance between first column of first group and last column of last group
normal_distance = groups[-1][-1] - groups[0][0]
Expand All @@ -812,7 +812,7 @@ def gen_groups(items):
) - groups[-1][0]
# return whether distance over antimeridian is shorter
return antimeridian_distance < normal_distance
else:
else: # pragma: no cover
return False


Expand Down
2 changes: 1 addition & 1 deletion mapchete/io/vector.py
Expand Up @@ -233,7 +233,7 @@ def _get_reprojected_features(
# this can be handled quietly
except GeometryTypeError:
pass
except TopologicalError as e:
except TopologicalError as e: # pragma: no cover
logger.warning("feature omitted: %s", e)

except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion mapchete/processes/__init__.py
Expand Up @@ -26,7 +26,7 @@ def _import():
loaded = v.load()
if process_name is None or process_name == loaded.__name__:
yield loaded
except Exception as e:
except Exception as e: # pragma: no cover
logger.warning("%s could not be imported: %s", str(v), str(e))

# sort processes alphabetically
Expand Down
2 changes: 1 addition & 1 deletion mapchete/tile.py
Expand Up @@ -339,7 +339,7 @@ def count_tiles(geometry, pyramid, minzoom, maxzoom, init_zoom=0):
-------
number of tiles
"""
if not 0 <= init_zoom <= minzoom <= maxzoom:
if not 0 <= init_zoom <= minzoom <= maxzoom: # pragma: no cover
raise ValueError("invalid zoom levels given")
# tile buffers are not being taken into account
unbuffered_pyramid = TilePyramid(
Expand Down

0 comments on commit 845d7d3

Please sign in to comment.