alessandro trinca tornidor commited on
Commit
7c49edb
1 Parent(s): 0677d1d

feat: now all logging instances are based on logging, removed logging dependency

Browse files
poetry.lock CHANGED
@@ -4074,4 +4074,4 @@ files = [
4074
  [metadata]
4075
  lock-version = "2.0"
4076
  python-versions = "~3.10"
4077
- content-hash = "54a69094c5b62a8e766dbcba310e0d11aca34a546bfd2ef293441b31a3b781db"
 
4074
  [metadata]
4075
  lock-version = "2.0"
4076
  python-versions = "~3.10"
4077
+ content-hash = "2e4a00a9ef0e444d2f23419f8b5cf8ddb9fbadeba0974a8f28e835bed0997b4f"
pyproject.toml CHANGED
@@ -14,7 +14,6 @@ version = "1.4.0"
14
  bson = "^0.5.10"
15
  contextily = "^1.6.0"
16
  geopandas = "^1.0.1"
17
- loguru = "^0.7.2"
18
  numpy = "1.25.2"
19
  opencv-python-headless = "^4.8.1.78"
20
  pillow = "^10.4.0"
@@ -31,7 +30,6 @@ optional = true
31
 
32
  [tool.poetry.group.fastapi.dependencies]
33
  fastapi = "^0.111.0"
34
- loguru = "^0.7.2"
35
  pydantic = "^2.8.2"
36
  uvicorn = "^0.30.1"
37
 
 
14
  bson = "^0.5.10"
15
  contextily = "^1.6.0"
16
  geopandas = "^1.0.1"
 
17
  numpy = "1.25.2"
18
  opencv-python-headless = "^4.8.1.78"
19
  pillow = "^10.4.0"
 
30
 
31
  [tool.poetry.group.fastapi.dependencies]
32
  fastapi = "^0.111.0"
 
33
  pydantic = "^2.8.2"
34
  uvicorn = "^0.30.1"
35
 
requirements.txt CHANGED
@@ -3,7 +3,6 @@ contextily==1.6.0
3
  fastapi==0.111.0
4
  geopandas==1.0.1
5
  lisa-on-cuda==1.3.3
6
- loguru==0.7.2
7
  numpy==1.25.2
8
  opencv-python-headless==4.8.1.78
9
  pillow==10.4.0
 
3
  fastapi==0.111.0
4
  geopandas==1.0.1
5
  lisa-on-cuda==1.3.3
 
6
  numpy==1.25.2
7
  opencv-python-headless==4.8.1.78
8
  pillow==10.4.0
samgis_lisa_on_zero/__init__.py CHANGED
@@ -4,24 +4,16 @@ import os
4
  # not used here but contextily_tile is imported in samgis_lisa_on_zero.io_package.tms2geotiff
5
  from contextily import tile as contextily_tile
6
  from pathlib import Path
 
 
 
7
  from samgis_lisa_on_zero.utilities.constants import SERVICE_NAME
8
 
 
9
  ROOT = Path(globals().get("__file__", "./_")).absolute().parent.parent
10
  PROJECT_ROOT_FOLDER = Path(os.getenv("PROJECT_ROOT_FOLDER", ROOT))
11
  WORKDIR = Path(os.getenv("WORKDIR", ROOT))
12
  MODEL_FOLDER_PROJECT_ROOT_FOLDER = Path(PROJECT_ROOT_FOLDER / "machine_learning_models")
13
  MODEL_FOLDER = Path(os.getenv("MODEL_FOLDER", MODEL_FOLDER_PROJECT_ROOT_FOLDER))
14
-
15
- IS_AWS_LAMBDA = bool(os.getenv("IS_AWS_LAMBDA", ""))
16
-
17
- if IS_AWS_LAMBDA:
18
- try:
19
- from aws_lambda_powertools import Logger
20
-
21
- app_logger = Logger(service=SERVICE_NAME)
22
- except ModuleNotFoundError:
23
- print("this should be AWS LAMBDA environment but we miss the required aws lambda powertools package")
24
- else:
25
- from samgis_core.utilities.fastapi_logger import setup_logging
26
-
27
- app_logger = setup_logging(debug=True)
 
4
  # not used here but contextily_tile is imported in samgis_lisa_on_zero.io_package.tms2geotiff
5
  from contextily import tile as contextily_tile
6
  from pathlib import Path
7
+
8
+ from lisa_on_cuda.utils import session_logger
9
+
10
  from samgis_lisa_on_zero.utilities.constants import SERVICE_NAME
11
 
12
+
13
  ROOT = Path(globals().get("__file__", "./_")).absolute().parent.parent
14
  PROJECT_ROOT_FOLDER = Path(os.getenv("PROJECT_ROOT_FOLDER", ROOT))
15
  WORKDIR = Path(os.getenv("WORKDIR", ROOT))
16
  MODEL_FOLDER_PROJECT_ROOT_FOLDER = Path(PROJECT_ROOT_FOLDER / "machine_learning_models")
17
  MODEL_FOLDER = Path(os.getenv("MODEL_FOLDER", MODEL_FOLDER_PROJECT_ROOT_FOLDER))
18
+ loglevel = os.getenv('LOGLEVEL', 'INFO').upper()
19
+ session_logger.change_logging(loglevel)
 
 
 
 
 
 
 
 
 
 
 
 
samgis_lisa_on_zero/io_package/coordinates_pixel_conversion.py CHANGED
@@ -1,12 +1,16 @@
1
  """functions useful to convert to/from latitude-longitude coordinates to pixel image coordinates"""
 
 
2
  from lisa_on_cuda.utils import session_logger
3
  from samgis_core.utilities.type_hints import TupleFloat, TupleFloatAny
4
- from samgis_lisa_on_zero import app_logger
5
  from samgis_lisa_on_zero.utilities.constants import TILE_SIZE, EARTH_EQUATORIAL_RADIUS
6
  from samgis_lisa_on_zero.utilities.type_hints import ImagePixelCoordinates
7
  from samgis_lisa_on_zero.utilities.type_hints import LatLngDict
8
 
9
 
 
 
 
10
  @session_logger.set_uuid_logging
11
  def _get_latlng2pixel_projection(latlng: LatLngDict) -> ImagePixelCoordinates:
12
  from math import log, pi, sin
 
1
  """functions useful to convert to/from latitude-longitude coordinates to pixel image coordinates"""
2
+ import logging
3
+
4
  from lisa_on_cuda.utils import session_logger
5
  from samgis_core.utilities.type_hints import TupleFloat, TupleFloatAny
 
6
  from samgis_lisa_on_zero.utilities.constants import TILE_SIZE, EARTH_EQUATORIAL_RADIUS
7
  from samgis_lisa_on_zero.utilities.type_hints import ImagePixelCoordinates
8
  from samgis_lisa_on_zero.utilities.type_hints import LatLngDict
9
 
10
 
11
+ app_logger = logging.getLogger(__name__)
12
+
13
+
14
  @session_logger.set_uuid_logging
15
  def _get_latlng2pixel_projection(latlng: LatLngDict) -> ImagePixelCoordinates:
16
  from math import log, pi, sin
samgis_lisa_on_zero/io_package/geo_helpers.py CHANGED
@@ -1,10 +1,14 @@
1
  """handle geo-referenced raster images"""
 
 
2
  from affine import Affine
3
  from numpy import ndarray as np_ndarray
4
 
5
  from lisa_on_cuda.utils import session_logger
6
  from samgis_core.utilities.type_hints import ListFloat, TupleFloat, DictStrInt
7
- from samgis_lisa_on_zero import app_logger
 
 
8
 
9
 
10
  @session_logger.set_uuid_logging
 
1
  """handle geo-referenced raster images"""
2
+ import logging
3
+
4
  from affine import Affine
5
  from numpy import ndarray as np_ndarray
6
 
7
  from lisa_on_cuda.utils import session_logger
8
  from samgis_core.utilities.type_hints import ListFloat, TupleFloat, DictStrInt
9
+
10
+
11
+ app_logger = logging.getLogger(__name__)
12
 
13
 
14
  @session_logger.set_uuid_logging
samgis_lisa_on_zero/io_package/raster_helpers.py CHANGED
@@ -1,14 +1,18 @@
1
  """helpers for computer vision duties"""
 
 
2
  import numpy as np
3
  from numpy import ndarray, bitwise_not
4
  from rasterio import open as rasterio_open
5
 
6
  from lisa_on_cuda.utils import session_logger
7
- from samgis_lisa_on_zero import app_logger
8
  from samgis_lisa_on_zero.utilities.constants import OUTPUT_CRS_STRING
9
  from samgis_lisa_on_zero.utilities.type_hints import XYZTerrainProvidersNames
10
 
11
 
 
 
 
12
  def get_nextzen_terrain_rgb_formula(red: ndarray, green: ndarray, blue: ndarray) -> ndarray:
13
  """
14
  Compute a 32-bits 2d digital elevation model from a nextzen 'terrarium' (terrain-rgb) raster.
 
1
  """helpers for computer vision duties"""
2
+ import logging
3
+
4
  import numpy as np
5
  from numpy import ndarray, bitwise_not
6
  from rasterio import open as rasterio_open
7
 
8
  from lisa_on_cuda.utils import session_logger
 
9
  from samgis_lisa_on_zero.utilities.constants import OUTPUT_CRS_STRING
10
  from samgis_lisa_on_zero.utilities.type_hints import XYZTerrainProvidersNames
11
 
12
 
13
+ app_logger = logging.getLogger(__name__)
14
+
15
+
16
  def get_nextzen_terrain_rgb_formula(red: ndarray, green: ndarray, blue: ndarray) -> ndarray:
17
  """
18
  Compute a 32-bits 2d digital elevation model from a nextzen 'terrarium' (terrain-rgb) raster.
samgis_lisa_on_zero/io_package/tms2geotiff.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
 
3
  from numpy import ndarray
@@ -5,13 +6,13 @@ from samgis_core.utilities.type_hints import TupleFloat
5
  from xyzservices import TileProvider
6
 
7
  from lisa_on_cuda.utils import session_logger
8
- from samgis_lisa_on_zero import app_logger
9
  from samgis_lisa_on_zero.utilities.constants import (OUTPUT_CRS_STRING, DRIVER_RASTERIO_GTIFF, N_MAX_RETRIES,
10
  N_CONNECTION, N_WAIT,
11
  ZOOM_AUTO, BOOL_USE_CACHE)
12
  from samgis_lisa_on_zero.utilities.type_hints import tuple_ndarray_transform
13
 
14
 
 
15
  bool_use_cache = int(os.getenv("BOOL_USE_CACHE", BOOL_USE_CACHE))
16
  n_connection = int(os.getenv("N_CONNECTION", N_CONNECTION))
17
  n_max_retries = int(os.getenv("N_MAX_RETRIES", N_MAX_RETRIES))
 
1
+ import logging
2
  import os
3
 
4
  from numpy import ndarray
 
6
  from xyzservices import TileProvider
7
 
8
  from lisa_on_cuda.utils import session_logger
 
9
  from samgis_lisa_on_zero.utilities.constants import (OUTPUT_CRS_STRING, DRIVER_RASTERIO_GTIFF, N_MAX_RETRIES,
10
  N_CONNECTION, N_WAIT,
11
  ZOOM_AUTO, BOOL_USE_CACHE)
12
  from samgis_lisa_on_zero.utilities.type_hints import tuple_ndarray_transform
13
 
14
 
15
+ app_logger = logging.getLogger(__name__)
16
  bool_use_cache = int(os.getenv("BOOL_USE_CACHE", BOOL_USE_CACHE))
17
  n_connection = int(os.getenv("N_CONNECTION", N_CONNECTION))
18
  n_max_retries = int(os.getenv("N_MAX_RETRIES", N_MAX_RETRIES))
samgis_lisa_on_zero/io_package/wrappers_helpers.py CHANGED
@@ -1,17 +1,20 @@
1
  """lambda helper functions"""
 
2
  from typing import Dict
3
 
4
  from xyzservices import providers, TileProvider
5
 
6
  from lisa_on_cuda.utils import session_logger
7
  from lisa_on_cuda.utils.app_helpers import get_cleaned_input
8
- from samgis_lisa_on_zero import app_logger
9
  from samgis_lisa_on_zero.io_package.coordinates_pixel_conversion import get_latlng_to_pixel_coordinates
10
  from samgis_lisa_on_zero.utilities.constants import COMPLETE_URL_TILES_MAPBOX, COMPLETE_URL_TILES_NEXTZEN
11
  from samgis_lisa_on_zero.utilities.type_hints import (
12
  ApiRequestBody, XYZTerrainProvidersNames, XYZDefaultProvidersNames, StringPromptApiRequestBody)
13
 
14
 
 
 
 
15
  @session_logger.set_uuid_logging
16
  def get_parsed_bbox_points_with_string_prompt(request_input: StringPromptApiRequestBody) -> Dict:
17
  """
 
1
  """lambda helper functions"""
2
+ import logging
3
  from typing import Dict
4
 
5
  from xyzservices import providers, TileProvider
6
 
7
  from lisa_on_cuda.utils import session_logger
8
  from lisa_on_cuda.utils.app_helpers import get_cleaned_input
 
9
  from samgis_lisa_on_zero.io_package.coordinates_pixel_conversion import get_latlng_to_pixel_coordinates
10
  from samgis_lisa_on_zero.utilities.constants import COMPLETE_URL_TILES_MAPBOX, COMPLETE_URL_TILES_NEXTZEN
11
  from samgis_lisa_on_zero.utilities.type_hints import (
12
  ApiRequestBody, XYZTerrainProvidersNames, XYZDefaultProvidersNames, StringPromptApiRequestBody)
13
 
14
 
15
+ app_logger = logging.getLogger(__name__)
16
+
17
+
18
  @session_logger.set_uuid_logging
19
  def get_parsed_bbox_points_with_string_prompt(request_input: StringPromptApiRequestBody) -> Dict:
20
  """
samgis_lisa_on_zero/prediction_api/lisa.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from datetime import datetime
2
 
3
  from lisa_on_cuda.utils import session_logger
@@ -11,11 +12,11 @@ from samgis_lisa_on_zero.utilities.constants import DEFAULT_URL_TILES, LISA_INFE
11
 
12
 
13
  msg_write_tmp_on_disk = "found option to write images and geojson output..."
 
14
 
15
 
16
  @session_logger.set_uuid_logging
17
  def load_model_and_inference_fn(inference_function_name_key: str):
18
- from samgis_lisa_on_zero import app_logger
19
  from lisa_on_cuda.utils import app_helpers
20
  from samgis_lisa_on_zero.prediction_api.global_models import models_dict
21
 
@@ -61,7 +62,6 @@ def lisa_predict(
61
  Affine transform
62
  """
63
  from os import getenv
64
- from samgis_lisa_on_zero import app_logger
65
  from samgis_lisa_on_zero.prediction_api.global_models import models_dict
66
 
67
  if source_name is None:
 
1
+ import logging
2
  from datetime import datetime
3
 
4
  from lisa_on_cuda.utils import session_logger
 
12
 
13
 
14
  msg_write_tmp_on_disk = "found option to write images and geojson output..."
15
+ app_logger = logging.getLogger(__name__)
16
 
17
 
18
  @session_logger.set_uuid_logging
19
  def load_model_and_inference_fn(inference_function_name_key: str):
 
20
  from lisa_on_cuda.utils import app_helpers
21
  from samgis_lisa_on_zero.prediction_api.global_models import models_dict
22
 
 
62
  Affine transform
63
  """
64
  from os import getenv
 
65
  from samgis_lisa_on_zero.prediction_api.global_models import models_dict
66
 
67
  if source_name is None:
samgis_lisa_on_zero/prediction_api/predictors.py CHANGED
@@ -1,10 +1,12 @@
1
  """functions using machine learning instance model(s)"""
 
 
2
  from lisa_on_cuda.utils import session_logger
3
  from samgis_core.prediction_api import sam_onnx2, sam_onnx_inference
4
  from samgis_core.utilities.constants import MODEL_ENCODER_NAME, MODEL_DECODER_NAME, DEFAULT_INPUT_SHAPE
5
  from samgis_core.utilities.type_hints import LlistFloat, DictStrInt, ListDict
6
 
7
- from samgis_lisa_on_zero import app_logger, MODEL_FOLDER
8
  from samgis_lisa_on_zero.io_package.geo_helpers import get_vectorized_raster_as_geojson
9
  from samgis_lisa_on_zero.io_package.raster_helpers import get_raster_terrain_rgb_like, get_rgb_prediction_image
10
  from samgis_lisa_on_zero.io_package.tms2geotiff import download_extent
@@ -12,6 +14,8 @@ from samgis_lisa_on_zero.io_package.wrappers_helpers import check_source_type_is
12
  from samgis_lisa_on_zero.prediction_api.global_models import models_dict, embedding_dict
13
  from samgis_lisa_on_zero.utilities.constants import DEFAULT_URL_TILES, SLOPE_CELLSIZE
14
 
 
 
15
 
16
  @session_logger.set_uuid_logging
17
  def samexporter_predict(
 
1
  """functions using machine learning instance model(s)"""
2
+ import logging
3
+
4
  from lisa_on_cuda.utils import session_logger
5
  from samgis_core.prediction_api import sam_onnx2, sam_onnx_inference
6
  from samgis_core.utilities.constants import MODEL_ENCODER_NAME, MODEL_DECODER_NAME, DEFAULT_INPUT_SHAPE
7
  from samgis_core.utilities.type_hints import LlistFloat, DictStrInt, ListDict
8
 
9
+ from samgis_lisa_on_zero import MODEL_FOLDER
10
  from samgis_lisa_on_zero.io_package.geo_helpers import get_vectorized_raster_as_geojson
11
  from samgis_lisa_on_zero.io_package.raster_helpers import get_raster_terrain_rgb_like, get_rgb_prediction_image
12
  from samgis_lisa_on_zero.io_package.tms2geotiff import download_extent
 
14
  from samgis_lisa_on_zero.prediction_api.global_models import models_dict, embedding_dict
15
  from samgis_lisa_on_zero.utilities.constants import DEFAULT_URL_TILES, SLOPE_CELLSIZE
16
 
17
+ app_logger = logging.getLogger(__name__)
18
+
19
 
20
  @session_logger.set_uuid_logging
21
  def samexporter_predict(