Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/python/impactx/dashboard/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
License: BSD-3-Clause-LBNL
"""

import asyncio

from . import server, state
from .app import application
from .Input.defaults import DashboardDefaults
Expand Down Expand Up @@ -42,6 +44,18 @@ class DashboardApp:

def start(self):
setup_dashboard()

# Ensure an event loop exists for Python 3.10+ (required on macOS)
# This prevents RuntimeError when server.start() tries to get_event_loop()
# In Python 3.10+, get_event_loop() raises RuntimeError if no loop exists
# We create and set one if needed
try:
asyncio.get_event_loop()
except RuntimeError:
# No event loop exists in this thread, create and set one
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

server.start()
return 0

Expand Down
7 changes: 6 additions & 1 deletion tests/python/dashboard/test_python_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ def test_python_import(dashboard):

# Check input values
for element_id, expected_value in DISTRIBUTION_VALUES + LATTICE_CONFIGURATION:
actual_value = float(dashboard.sb.get_value(element_id))
# Wait for element to be present in the DOM (doesn't require visibility)
# This is important for CI environments where rendering may be slower
dashboard.sb.wait_for_element_present(element_id, timeout=10)

# Get the value attribute - this works even if the element isn't visible
actual_value = float(dashboard.sb.get_attribute(element_id, "value"))
assert actual_value == pytest.approx(expected_value, **APPROX_TOL), (
f"{element_id}: expected {expected_value}, got {actual_value}"
)
14 changes: 7 additions & 7 deletions tests/python/dashboard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def wait_for_interaction_ready(sb, timeout=TIMEOUT):
https://github.com/Kitware/trame-client/blob/master/trame_client/utils/testing.py#L132

"""
for i in range(timeout):
print(f"Waiting for dashboard to load - ({i + 1}s elapsed)")
if sb.is_element_present(".trame__loader"):
sb.sleep(1)
else:
print("Ready to interact with.")
return
print("Waiting for dashboard to load...")

# Wait for the dashboard to finish loading.
# This ensures all UI elements are rendered before we manipulate or check their values
sb.wait_for_element_present("#Input_route", timeout=10)

print("Ready to interact with.")


def wait_for_server_ready(process, timeout=TIMEOUT):
Expand Down
Loading