From 4cd6174a228ed52eb696b36586f5b725afc72e71 Mon Sep 17 00:00:00 2001 From: DominikDoom Date: Sun, 14 Apr 2024 12:14:29 +0200 Subject: [PATCH] Trying out a hopefully more robust import fix --- scripts/tag_autocomplete_helper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/tag_autocomplete_helper.py b/scripts/tag_autocomplete_helper.py index c2d2f19..e439288 100644 --- a/scripts/tag_autocomplete_helper.py +++ b/scripts/tag_autocomplete_helper.py @@ -1,7 +1,7 @@ # This helper script scans folders for wildcards and embeddings and writes them # to a temporary file to expose it to the javascript side -import os +import sys import glob import importlib import json @@ -25,7 +25,10 @@ try: try: from scripts import tag_frequency_db as tdb except ModuleNotFoundError: - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "scripts"))) + from inspect import getframeinfo, currentframe + filename = getframeinfo(currentframe()).filename + parent = Path(filename).resolve().parent + sys.path.append(str(parent)) import tag_frequency_db as tdb # Ensure the db dependency is reloaded on script reload