Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: typing for processes #623

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions mapchete/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
from fsspec import AbstractFileSystem

from mapchete.config import MapcheteConfig
from mapchete.errors import MapcheteNodataTile
from mapchete.executor import Executor, MFuture
from mapchete.formats import read_output_metadata
from mapchete.formats.protocols import (
RasterInput,
RasterInputGroup,
VectorInput,
VectorInputGroup,
)
from mapchete.path import MPath, fs_from_path
from mapchete.processing import Mapchete, MapcheteProcess
from mapchete.tile import count_tiles
Expand All @@ -19,7 +26,12 @@
"MapcheteProcess",
"Timer",
"Executor",
"MapcheteNodataTile",
"MFuture",
"RasterInput",
"RasterInputGroup",
"VectorInput",
"VectorInputGroup",
]
__version__ = "2024.2.1"

Expand Down
4 changes: 2 additions & 2 deletions mapchete/commands/_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from contextlib import AbstractContextManager
from multiprocessing import cpu_count
from pprint import pformat
from typing import List, NoReturn, Optional, Tuple, Type, Union
from typing import List, Optional, Tuple, Type, Union

import tilematrix
from rasterio.crs import CRS
Expand Down Expand Up @@ -63,7 +63,7 @@ def convert(
retry_on_exception: Tuple[Type[Exception], Type[Exception]] = Exception,
cancel_on_exception: Type[Exception] = JobCancelledError,
retries: int = 0,
) -> NoReturn:
) -> None:
"""
Convert mapchete outputs or other geodata.

Expand Down
8 changes: 0 additions & 8 deletions mapchete/commons/__init__.py

This file was deleted.

72 changes: 0 additions & 72 deletions mapchete/commons/clip.py

This file was deleted.

69 changes: 0 additions & 69 deletions mapchete/commons/contours.py

This file was deleted.

142 changes: 0 additions & 142 deletions mapchete/commons/hillshade.py

This file was deleted.

15 changes: 12 additions & 3 deletions mapchete/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
guess_geometry,
parse_config,
raw_conf_at_zoom,
zoom_parameters,
)
from mapchete.config.process_func import ProcessFunc
from mapchete.enums import ProcessingMode
Expand Down Expand Up @@ -140,7 +141,7 @@ def __init__(

# (2) check user process
self.config_dir = self.parsed_config.config_dir
if self.mode != "readonly":
if self.mode != ProcessingMode.READONLY:
if self.parsed_config.process is None:
raise MapcheteConfigError(
f"process must be provided on {self.mode} mode"
Expand Down Expand Up @@ -205,6 +206,15 @@ def __init__(
self._params_at_zoom = raw_conf_at_zoom(
self.parsed_config, self.init_zoom_levels
)
# TODO: check execute function parameters and provide warnings in case parameters
# have been omitted, are not defined in the config, or have the wrong type
if self.process:
self.process.analyze_parameters(
{
zoom: zoom_parameters(self.parsed_config, zoom)
for zoom in self.init_zoom_levels
}
)

# (6) determine process area and process boundaries both from config as well
# as from initialization.
Expand Down Expand Up @@ -423,8 +433,7 @@ def output(self):
except Exception as e:
logger.exception(e)
raise MapcheteConfigError(
"driver %s not compatible with configuration: %s"
% (writer.METADATA["driver_name"], e)
"driver %s not compatible with configuration: %s" % (writer, e)
)
return writer

Expand Down
Loading