mirror of
https://gitea.psi.ch/APOG/acsmnode.git
synced 2025-06-27 12:01:10 +02:00
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:
@ -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
|
from dash import Dash, html, dcc, callback, Output, Input, State, dash_table
|
||||||
import dash_bootstrap_components as dbc
|
import dash_bootstrap_components as dbc
|
||||||
|
|
||||||
import yaml
|
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:
|
try:
|
||||||
flags_dict = yaml.safe_load(stream)["flags"]
|
flags_dict = yaml.safe_load(stream)["flags"]
|
||||||
except yaml.YAMLError as exc:
|
except yaml.YAMLError as exc:
|
||||||
flags_dict = {}
|
flags_dict = {}
|
||||||
print(exc)
|
print(exc)
|
||||||
|
|
||||||
import data_flagging_utils
|
|
||||||
|
|
||||||
flagging_dashboard = dbc.Row([
|
flagging_dashboard = dbc.Row([
|
||||||
html.H3("Create flags"),
|
html.H3("Create flags"),
|
||||||
|
@ -30,7 +30,7 @@ import io
|
|||||||
#sys.path.append(os.path.join(root_dir,'dima'))
|
#sys.path.append(os.path.join(root_dir,'dima'))
|
||||||
|
|
||||||
|
|
||||||
import data_flagging_utils as data_flagging_utils
|
import app.data_flagging_utils as data_flagging_utils
|
||||||
|
|
||||||
from dash import Dash, html, dcc, callback, Output, Input, State, dash_table
|
from dash import Dash, html, dcc, callback, Output, Input, State, dash_table
|
||||||
import plotly.graph_objs as go
|
import plotly.graph_objs as go
|
||||||
@ -50,12 +50,12 @@ import webbrowser
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
from components.instrument_dashboard import instrument_dashboard
|
from app.components.instrument_dashboard import instrument_dashboard
|
||||||
from components.flagging_dashboard import flagging_dashboard
|
from app.components.flagging_dashboard import flagging_dashboard
|
||||||
from components.upload_component import upload_component
|
from app.components.upload_component import upload_component
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
with open('app/flags/ebas_dict.yaml') as stream:
|
with open(os.path.join(projectPath,'app/flags/ebas_dict.yaml')) as stream:
|
||||||
try:
|
try:
|
||||||
flags_dict = yaml.safe_load(stream)["flags"]
|
flags_dict = yaml.safe_load(stream)["flags"]
|
||||||
except yaml.YAMLError as exc:
|
except yaml.YAMLError as exc:
|
||||||
@ -776,9 +776,13 @@ def open_browser():
|
|||||||
if not os.getenv("DOCKER_CONTAINER"):
|
if not os.getenv("DOCKER_CONTAINER"):
|
||||||
webbrowser.open_new("http://127.0.0.1:8050/")
|
webbrowser.open_new("http://127.0.0.1:8050/")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
def main():
|
||||||
# Start the browser-opening function in a separate thread
|
# Start the browser-opening function in a separate thread
|
||||||
threading.Thread(target=open_browser).start()
|
threading.Thread(target=open_browser).start()
|
||||||
|
|
||||||
# Run the Dash app server on 0.0.0.0 to allow external access
|
# Run the Dash app server on 0.0.0.0 to allow external access
|
||||||
app.run_server(host="0.0.0.0", port=8050, debug=True, use_reloader=False)
|
app.run_server(host="0.0.0.0", port=8050, debug=True, use_reloader=False)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Reference in New Issue
Block a user