diff --git a/app/apps/core/tasks.py b/app/apps/core/tasks.py index e0b37852df101755f1c90a5450114252ade8c9dc..7d5732bedc51145a64030969e9652a74b9a73c62 100644 --- a/app/apps/core/tasks.py +++ b/app/apps/core/tasks.py @@ -3,6 +3,7 @@ import json import logging import numpy as np import os.path +import pathlib import shutil from itertools import groupby @@ -352,8 +353,7 @@ def train_(qs, document, transcription, model=None, user=None): filename = slugify(model.name) + '.mlmodel' upload_to = model.file.field.upload_to(model, filename) fulldir = os.path.join(settings.MEDIA_ROOT, os.path.split(upload_to)[0], '') - if not os.path.exists(fulldir): - os.mkdir(fulldir) + pathlib.Path(fulldir).mkdir(parents=True, exist_ok=True) modelpath = os.path.join(fulldir, filename) model.file = upload_to model.save()