alessandro trinca tornidor
commited on
Commit
·
d33fb86
1
Parent(s):
b1bb633
[feat] samgis package: handle PROJECT_ROOT_FOLDER as an ENV variable
Browse files- samgis/__init__.py +2 -1
- scripts/entrypoint.sh +1 -0
- wrappers/fastapi_wrapper.py +6 -0
samgis/__init__.py
CHANGED
|
@@ -6,7 +6,8 @@ from contextily import tile as contextily_tile
|
|
| 6 |
from pathlib import Path
|
| 7 |
from samgis.utilities.constants import SERVICE_NAME
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
MODEL_FOLDER = Path(PROJECT_ROOT_FOLDER / "machine_learning_models")
|
| 11 |
|
| 12 |
IS_AWS_LAMBDA = bool(os.getenv("IS_AWS_LAMBDA", ""))
|
|
|
|
| 6 |
from pathlib import Path
|
| 7 |
from samgis.utilities.constants import SERVICE_NAME
|
| 8 |
|
| 9 |
+
ROOT = Path(globals().get("__file__", "./_")).absolute().parent.parent
|
| 10 |
+
PROJECT_ROOT_FOLDER = os.getenv("PROJECT_ROOT_FOLDER", ROOT)
|
| 11 |
MODEL_FOLDER = Path(PROJECT_ROOT_FOLDER / "machine_learning_models")
|
| 12 |
|
| 13 |
IS_AWS_LAMBDA = bool(os.getenv("IS_AWS_LAMBDA", ""))
|
scripts/entrypoint.sh
CHANGED
|
@@ -17,6 +17,7 @@ ln -s ${FASTAPI_STATIC} .
|
|
| 17 |
echo "WORKDIR content: ${WORKDIR}, after creating the FASTAPI_STATIC symlink ..."
|
| 18 |
ls -ld ${WORKDIR}
|
| 19 |
ls -lA ${WORKDIR}
|
|
|
|
| 20 |
|
| 21 |
echo "XDG_CACHE_HOME content: ${XDG_CACHE_HOME}, before creating the folders ..."
|
| 22 |
ls -ld ${XDG_CACHE_HOME}/
|
|
|
|
| 17 |
echo "WORKDIR content: ${WORKDIR}, after creating the FASTAPI_STATIC symlink ..."
|
| 18 |
ls -ld ${WORKDIR}
|
| 19 |
ls -lA ${WORKDIR}
|
| 20 |
+
ls -lA ${WORKDIR}/static
|
| 21 |
|
| 22 |
echo "XDG_CACHE_HOME content: ${XDG_CACHE_HOME}, before creating the folders ..."
|
| 23 |
ls -ld ${XDG_CACHE_HOME}/
|
wrappers/fastapi_wrapper.py
CHANGED
|
@@ -17,6 +17,12 @@ app_logger = setup_logging(debug=True)
|
|
| 17 |
app = FastAPI()
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
@app.middleware("http")
|
| 21 |
async def request_middleware(request, call_next):
|
| 22 |
request_id = str(uuid.uuid4())
|
|
|
|
| 17 |
app = FastAPI()
|
| 18 |
|
| 19 |
|
| 20 |
+
try:
|
| 21 |
+
app_logger.info(f"PROJECT_ROOT_FOLDER:{PROJECT_ROOT_FOLDER}.")
|
| 22 |
+
except Exception as e:
|
| 23 |
+
app_logger.error(f"e:{e}.")
|
| 24 |
+
|
| 25 |
+
|
| 26 |
@app.middleware("http")
|
| 27 |
async def request_middleware(request, call_next):
|
| 28 |
request_id = str(uuid.uuid4())
|