Skip to content

Commit

Permalink
feat: add cli
Browse files Browse the repository at this point in the history
  • Loading branch information
RaczeQ committed Oct 13, 2024
1 parent 0a36f97 commit 5026a1c
Show file tree
Hide file tree
Showing 9 changed files with 759 additions and 22 deletions.
4 changes: 2 additions & 2 deletions overturemaestro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
convert_geometry_to_parquet_for_multiple_types,
)
from overturemaestro.release_index import (
get_all_available_release_versions,
get_available_release_versions,
get_available_theme_type_pairs,
get_newest_release_version,
)
Expand All @@ -33,7 +33,7 @@
"convert_geometry_to_geodataframe_for_multiple_types",
"convert_geometry_to_parquet",
"convert_geometry_to_parquet_for_multiple_types",
"get_all_available_release_versions",
"get_available_release_versions",
"get_available_theme_type_pairs",
"get_newest_release_version",
]
20 changes: 20 additions & 0 deletions overturemaestro/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Main CLI module."""


def main() -> None:
"""Run provided CLI."""
try:
from overturemaestro import __app_name__, cli
except ImportError as exc:
raise
error_msg = (
"Missing optional dependencies required for the CLI."
" Please install required packages using `pip install overturemaestro[cli]`."
)
raise ImportError(error_msg) from exc

cli.app(prog_name=__app_name__) # pragma: no cover


if __name__ == "__main__": # pragma: no cover
main()
1 change: 1 addition & 0 deletions overturemaestro/_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class QueryNotGeocodedError(ValueError): ...
6 changes: 3 additions & 3 deletions overturemaestro/_geometry_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
from collections.abc import Generator, Iterable
from typing import Any

import polars as pl
from sklearn.cluster import Birch

EARTH_RADIUS_KM = 6371
CLUSTERING_THRESHOLD = 20 / EARTH_RADIUS_KM # calculate 20 kilometers threshold


def calculate_row_group_bounding_box(
parquet_filename: str, parquet_row_group: int, pyarrow_table: Any
) -> Any:
import polars as pl
from sklearn.cluster import Birch

df = (
pl.from_arrow(pyarrow_table)
.with_row_index(name="row_index")
Expand Down
4 changes: 4 additions & 0 deletions overturemaestro/_geopandas_api_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import geopandas as gpd
from packaging import version

GEOPANDAS_NEW_API = version.parse(gpd.__version__) >= version.parse("1.0.0")
Loading

0 comments on commit 5026a1c

Please sign in to comment.