From 22d9599bef86e97e544d886f1cdc9c4025218118 Mon Sep 17 00:00:00 2001 From: Juho Inkinen <34240031+juhoinkinen@users.noreply.github.com> Date: Mon, 18 Mar 2024 12:47:34 +0200 Subject: [PATCH] Include files in subdirs but ignore dirs as model data files (#778) --- annif/backend/backend.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/annif/backend/backend.py b/annif/backend/backend.py index 6a63c86b2..be49e79fa 100644 --- a/annif/backend/backend.py +++ b/annif/backend/backend.py @@ -53,14 +53,15 @@ def params(self) -> dict[str, Any]: @property def _model_file_paths(self) -> list: - all_paths = glob(os.path.join(self.datadir, "*")) + all_paths = glob(os.path.join(self.datadir, "**"), recursive=True) + file_paths = [p for p in all_paths if os.path.isfile(p)] ignore_patterns = ("*-train*", "tmp-*", "vectorizer") ignore_paths = [ path for igp in ignore_patterns for path in glob(os.path.join(self.datadir, igp)) ] - return list(set(all_paths) - set(ignore_paths)) + return list(set(file_paths) - set(ignore_paths)) @property def is_trained(self) -> bool: