Fix bug where seed.py won't fail if no spreadsheet is present.
This commit is contained in:
+6
-1
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ TENANT_ID = "hunter-premium-produce"
|
|||||||
WORKBOOK_EFFECTIVE_DATE = date(2025, 9, 1)
|
WORKBOOK_EFFECTIVE_DATE = date(2025, 9, 1)
|
||||||
WORKBOOK_SENTINEL_ITEM_ID = "404266"
|
WORKBOOK_SENTINEL_ITEM_ID = "404266"
|
||||||
WORKBOOK_PATH = Path(__file__).resolve().parents[2] / "Input Cost Spreadsheet(1).xlsx"
|
WORKBOOK_PATH = Path(__file__).resolve().parents[2] / "Input Cost Spreadsheet(1).xlsx"
|
||||||
|
logger = logging.getLogger("data_entry_app.seed")
|
||||||
|
|
||||||
|
|
||||||
def _text(value) -> str | None:
|
def _text(value) -> str | None:
|
||||||
@@ -681,7 +683,10 @@ def seed_costing_workspace(db):
|
|||||||
def seed_if_empty():
|
def seed_if_empty():
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
with SessionLocal() as db:
|
with SessionLocal() as db:
|
||||||
seed_costing_workspace(db)
|
if WORKBOOK_PATH.exists():
|
||||||
|
seed_costing_workspace(db)
|
||||||
|
else:
|
||||||
|
logger.warning("Skipping costing workspace seed because workbook is missing at %s", WORKBOOK_PATH)
|
||||||
seed_client_access(db)
|
seed_client_access(db)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user