Fix import problem. The app didn't run from a notebooks/<>.ipynb. This however may not be needed any longer. Is it good practice to run dashboards from a jupyter notebook?

This commit is contained in:
2025-03-18 07:14:44 +01:00
parent 395b734cd6
commit f3010bff47
2 changed files with 27 additions and 9 deletions

View File

@ -1,17 +1,31 @@
import sys, os
try:
thisFilePath = os.path.abspath(__file__)
print(thisFilePath)
except NameError:
print("[Notice] The __file__ attribute is unavailable in this environment (e.g., Jupyter or IDLE).")
print("When using a terminal, make sure the working directory is set to the script's location to prevent path issues (for the DIMA submodule)")
#print("Otherwise, path to submodule DIMA may not be resolved properly.")
thisFilePath = os.getcwd() # Use current directory or specify a default
projectPath = os.path.normpath(os.path.join(thisFilePath, "..","..", ".."))
from dash import Dash, html, dcc, callback, Output, Input, State, dash_table
import dash_bootstrap_components as dbc
import yaml
from app import data_flagging_utils
with open('app/flags/ebas_dict.yaml') as stream:
with open(os.path.join(projectPath,'app/flags/ebas_dict.yaml')) as stream:
try:
flags_dict = yaml.safe_load(stream)["flags"]
except yaml.YAMLError as exc:
flags_dict = {}
print(exc)
import data_flagging_utils
flagging_dashboard = dbc.Row([
html.H3("Create flags"),