[debug] show more details in case of exceptions, again
Browse files- samgis/__init__.py +1 -0
- wrappers/fastapi_wrapper.py +3 -2
samgis/__init__.py
CHANGED
|
@@ -7,6 +7,7 @@ from pathlib import Path
|
|
| 7 |
from samgis.utilities.constants import SERVICE_NAME
|
| 8 |
|
| 9 |
PROJECT_ROOT_FOLDER = Path(globals().get("__file__", "./_")).absolute().parent.parent
|
|
|
|
| 10 |
MODEL_FOLDER = Path(PROJECT_ROOT_FOLDER / "machine_learning_models")
|
| 11 |
|
| 12 |
IS_AWS_LAMBDA = bool(os.getenv("IS_AWS_LAMBDA", ""))
|
|
|
|
| 7 |
from samgis.utilities.constants import SERVICE_NAME
|
| 8 |
|
| 9 |
PROJECT_ROOT_FOLDER = Path(globals().get("__file__", "./_")).absolute().parent.parent
|
| 10 |
+
WORKDIR = os.getenv("WORKDIR", PROJECT_ROOT_FOLDER)
|
| 11 |
MODEL_FOLDER = Path(PROJECT_ROOT_FOLDER / "machine_learning_models")
|
| 12 |
|
| 13 |
IS_AWS_LAMBDA = bool(os.getenv("IS_AWS_LAMBDA", ""))
|
wrappers/fastapi_wrapper.py
CHANGED
|
@@ -9,7 +9,7 @@ from fastapi.staticfiles import StaticFiles
|
|
| 9 |
from fastapi.templating import Jinja2Templates
|
| 10 |
from pydantic import ValidationError
|
| 11 |
|
| 12 |
-
from samgis import PROJECT_ROOT_FOLDER
|
| 13 |
from samgis.io.wrappers_helpers import get_parsed_bbox_points, get_source_name
|
| 14 |
from samgis.utilities.type_hints import ApiRequestBody
|
| 15 |
from samgis_core.utilities.fastapi_logger import setup_logging
|
|
@@ -18,6 +18,7 @@ from samgis.prediction_api.predictors import samexporter_predict
|
|
| 18 |
|
| 19 |
app_logger = setup_logging(debug=True)
|
| 20 |
app_logger.info(f"PROJECT_ROOT_FOLDER:{PROJECT_ROOT_FOLDER}.")
|
|
|
|
| 21 |
app = FastAPI()
|
| 22 |
|
| 23 |
|
|
@@ -87,7 +88,7 @@ def infer_samgis(request_input: ApiRequestBody) -> JSONResponse:
|
|
| 87 |
except Exception as inference_exception:
|
| 88 |
import subprocess
|
| 89 |
home_content = subprocess.run(
|
| 90 |
-
"ls -l {PROJECT_ROOT_FOLDER} {PROJECT_ROOT_FOLDER}/*", shell=True, universal_newlines=True, stdout=subprocess.PIPE
|
| 91 |
)
|
| 92 |
app_logger.error(f"/home/user ls -l: {home_content.stdout}.")
|
| 93 |
app_logger.error(f"inference error:{inference_exception}.")
|
|
|
|
| 9 |
from fastapi.templating import Jinja2Templates
|
| 10 |
from pydantic import ValidationError
|
| 11 |
|
| 12 |
+
from samgis import PROJECT_ROOT_FOLDER, WORKDIR
|
| 13 |
from samgis.io.wrappers_helpers import get_parsed_bbox_points, get_source_name
|
| 14 |
from samgis.utilities.type_hints import ApiRequestBody
|
| 15 |
from samgis_core.utilities.fastapi_logger import setup_logging
|
|
|
|
| 18 |
|
| 19 |
app_logger = setup_logging(debug=True)
|
| 20 |
app_logger.info(f"PROJECT_ROOT_FOLDER:{PROJECT_ROOT_FOLDER}.")
|
| 21 |
+
app_logger.info(f"WORKDIR:{WORKDIR}.")
|
| 22 |
app = FastAPI()
|
| 23 |
|
| 24 |
|
|
|
|
| 88 |
except Exception as inference_exception:
|
| 89 |
import subprocess
|
| 90 |
home_content = subprocess.run(
|
| 91 |
+
"ls -l /var/task {PROJECT_ROOT_FOLDER} {PROJECT_ROOT_FOLDER}/* {WORKDIR} {WORKDIR}/*", shell=True, universal_newlines=True, stdout=subprocess.PIPE
|
| 92 |
)
|
| 93 |
app_logger.error(f"/home/user ls -l: {home_content.stdout}.")
|
| 94 |
app_logger.error(f"inference error:{inference_exception}.")
|