[refactor] always re-create the folder using WRITE_TMP_ON_DISK env
Browse files
wrappers/fastapi_wrapper.py
CHANGED
@@ -131,14 +131,12 @@ write_tmp_on_disk = os.getenv("WRITE_TMP_ON_DISK", "")
|
|
131 |
app_logger.info(f"write_tmp_on_disk:{write_tmp_on_disk}.")
|
132 |
if bool(write_tmp_on_disk):
|
133 |
try:
|
134 |
-
app.mount("/vis_output", StaticFiles(directory=write_tmp_on_disk), name="vis_output")
|
135 |
-
except RuntimeError:
|
136 |
-
app_logger.info(f"missing folder write_tmp_on_disk:{write_tmp_on_disk}, try to remove if it's a file or symlink...")
|
137 |
pathlib.Path.unlink(write_tmp_on_disk, missing_ok=True)
|
138 |
-
app_logger.info(f"try to create the folder write_tmp_on_disk:{write_tmp_on_disk}.")
|
139 |
os.makedirs(write_tmp_on_disk, exist_ok=True)
|
140 |
app.mount("/vis_output", StaticFiles(directory=write_tmp_on_disk), name="vis_output")
|
141 |
-
|
|
|
|
|
142 |
templates = Jinja2Templates(directory=PROJECT_ROOT_FOLDER / "static")
|
143 |
|
144 |
|
|
|
131 |
app_logger.info(f"write_tmp_on_disk:{write_tmp_on_disk}.")
|
132 |
if bool(write_tmp_on_disk):
|
133 |
try:
|
|
|
|
|
|
|
134 |
pathlib.Path.unlink(write_tmp_on_disk, missing_ok=True)
|
|
|
135 |
os.makedirs(write_tmp_on_disk, exist_ok=True)
|
136 |
app.mount("/vis_output", StaticFiles(directory=write_tmp_on_disk), name="vis_output")
|
137 |
+
except RuntimeError as rerr:
|
138 |
+
app_logger.error(f"{rerr} while loading the folder write_tmp_on_disk:{write_tmp_on_disk}...")
|
139 |
+
raise rerr
|
140 |
templates = Jinja2Templates(directory=PROJECT_ROOT_FOLDER / "static")
|
141 |
|
142 |
|