Skip to content

Commit a09b413

Browse files
feat: add logging and directory creation for output and input paths in training process
1 parent 8ae02eb commit a09b413

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

backend/core/tasks.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ def run_tippecanoe(out):
405405
def finalize(inst, out, prep, acc):
406406
for f in ["aois.geojson", "labels.geojson"]:
407407
copyfile(os.path.join(out, f), os.path.join(prep, f))
408+
logger = logging.getLogger(__name__)
409+
logger.info(f"Setting up output path {out}")
410+
os.makedirs(out, exist_ok=True)
408411
xz_folder(prep, os.path.join(out, "preprocessed.tar.xz"), remove_original=True)
409412
if settings.USE_S3_TO_UPLOAD_MODELS:
410413
upload_to_s3(out, parent=f"{settings.PARENT_BUCKET_FOLDER}/training_{inst.id}")
@@ -458,6 +461,8 @@ def train_model(
458461
"input",
459462
f"training_{training_id}",
460463
)
464+
logger.info(f"Setting up input path {input_path}")
465+
os.makedirs(input_path, exist_ok=True)
461466

462467
input_path, aoi_ser, labels = prepare_data(
463468
inst,
@@ -495,6 +500,7 @@ def train_model(
495500
result["preprocess_output"],
496501
result["accuracy"],
497502
)
503+
logger.info(f"Cleaning up input path {input_path}")
498504
safe_rmtree(input_path)
499505
logger.info("Training completed successfully")
500506
send_notification(inst, "Completed")
@@ -529,6 +535,7 @@ def predict_area(prediction_request_id):
529535
try:
530536
logger.info("Starting model prediction task")
531537
with capture_output_to_file(log_file):
538+
# send_notification(inst, "Failed")
532539
inst.status, inst.started_at, inst.task_id = (
533540
"RUNNING",
534541
timezone.now(),

0 commit comments

Comments
 (0)