Skip to content

Commit 5f54a6c

Browse files
committed
Catch missing missing files when building app
1 parent 374cfc1 commit 5f54a6c

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

mlip_testing/app/build_app.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from importlib import import_module
66
from pathlib import Path
7+
import warnings
78

89
from dash import Dash, Input, Output, callback
910
from dash.dash_table import DataTable
@@ -40,23 +41,39 @@ def get_all_tests(
4041

4142
# Build all layouts, and register all callbacks to main app.
4243
for test in tests:
43-
# Import tab application layout/callbacks
44-
test_name = test.parent.name
45-
category_name = test.parent.parent.name
46-
test_module = import_module(
47-
f"mlip_testing.app.{category_name}.{test_name}.app_{test_name}"
48-
)
49-
test_app = test_module.get_app()
50-
51-
# Get layouts and tables for each category/test
52-
if category_name not in layouts:
53-
layouts[category_name] = {}
54-
tables[category_name] = {}
55-
layouts[category_name][test_app.name] = test_app.layout
56-
tables[category_name][test_app.name] = test_app.table
44+
try:
45+
# Import tab application layout/callbacks
46+
test_name = test.parent.name
47+
category_name = test.parent.parent.name
48+
test_module = import_module(
49+
f"mlip_testing.app.{category_name}.{test_name}.app_{test_name}"
50+
)
51+
test_app = test_module.get_app()
52+
53+
# Get layouts and tables for each category/test
54+
if category_name not in layouts:
55+
layouts[category_name] = {}
56+
tables[category_name] = {}
57+
layouts[category_name][test_app.name] = test_app.layout
58+
tables[category_name][test_app.name] = test_app.table
59+
except FileNotFoundError as err:
60+
warnings.warn(
61+
f"Unable to load layout for {test_name} in {category_name} category. "
62+
f"Full error:\n{err}",
63+
stacklevel=2,
64+
)
65+
continue
5766

5867
# Register tab callbacks
59-
test_app.register_callbacks()
68+
try:
69+
test_app.register_callbacks()
70+
except FileNotFoundError as err:
71+
warnings.warn(
72+
f"Unable to register callbacks for {test_name} in {category_name} "
73+
f"category. Full error:\n{err}",
74+
stacklevel=2,
75+
)
76+
continue
6077

6178
return layouts, tables
6279

0 commit comments

Comments
 (0)