Notify user if fastai does not exist and exit early if there are no transactions to predict.

This commit is contained in:
felixm 2024-06-15 18:14:03 -04:00
parent c6b3e121b6
commit 886bcdbdd1

View File

@ -16,15 +16,17 @@ def get_sort_categories():
from fastai.text.all import load_learner
learn = load_learner("export.pkl")
except ModuleNotFoundError:
pass
except FileNotFoundError:
pass
user_input = input("No fastai module. Type yes to continue anyway.")
if user_input.strip().lower() != "yes":
raise Exception("fastai module missing")
return sort_categories
def add_account2(transactions: List[Transaction], categories: List[str]):
unmapped_transactions = filter(lambda t: t.account2 == UNKNOWN_CATEGORY, transactions)
unmapped_transactions = list(filter(lambda t: t.account2 == UNKNOWN_CATEGORY, transactions))
if len(unmapped_transactions) == 0:
return
sort_categories = get_sort_categories()
for t in unmapped_transactions:
sort_categories(t.row, categories)