Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion align_browser/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@contextmanager
def wait_for_new_experiment_result(page, timeout=5000):
def wait_for_new_experiment_result(page, timeout=10000):
"""
Context manager that waits for a new experiment result to load after a parameter change.

Expand Down
13 changes: 11 additions & 2 deletions align_browser/experiment_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
from pathlib import Path
from typing import List, Dict, Any, Optional
from pydantic import BaseModel, Field, ConfigDict
from pydantic import BaseModel, Field, ConfigDict, field_validator


def calculate_file_checksum(file_path: Path) -> str:
Expand Down Expand Up @@ -363,14 +363,18 @@ def has_required_files(cls, experiment_dir: Path) -> bool:
return all((experiment_dir / f).exists() for f in required_files)


# Enhanced Manifest Models for New Structure
class SceneInfo(BaseModel):
"""Information about a scene within a scenario."""

source_index: int # Index in the source input_output.json file
scene_id: str # Scene ID from meta_info.scene_id
timing_s: float # Timing from timing.json raw_times_s[source_index]

@field_validator("scene_id", mode="before")
@classmethod
def convert_scene_id_to_str(cls, v):
return str(v) if isinstance(v, int) else v


class InputOutputFileInfo(BaseModel):
"""File information for input_output data."""
Expand Down Expand Up @@ -487,6 +491,11 @@ def add_experiment(
meta_info = item.input.full_state.get("meta_info", {})
if isinstance(meta_info, dict):
scene_id = meta_info.get("scene_id", f"scene_{source_index}")
scene_id = (
str(scene_id)
if scene_id is not None
else f"scene_{source_index}"
)

if scenario_id not in scenarios_dict:
scores_path = None
Expand Down
54 changes: 28 additions & 26 deletions align_browser/test_frontend_real_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,15 @@ def test_kdma_combination_default_value_issue(page, real_data_test_server):
# Set initial KDMA dropdown to a valid value to enable adding another KDMA
initial_kdma_dropdown = page.locator(".table-kdma-value-select").first

with wait_for_new_experiment_result(page):
# Select option with value '1' if available
options = initial_kdma_dropdown.locator("option").all_text_contents()
for i, option in enumerate(options):
if option.strip() in ["1", "1.0"]:
initial_kdma_dropdown.select_option(index=i)
break
# Wait for results to load after KDMA change
# Select option with value '1' if available
options = initial_kdma_dropdown.locator("option").all_text_contents()
for i, option in enumerate(options):
if option.strip() in ["1", "1.0"]:
initial_kdma_dropdown.select_option(index=i)
break

# Wait for network to settle after KDMA change
page.wait_for_load_state("networkidle", timeout=10000)

# Check initial KDMA dropdowns - should have affiliation already
kdma_dropdowns = page.locator(".table-kdma-value-select")
Expand All @@ -375,13 +376,12 @@ def test_kdma_combination_default_value_issue(page, real_data_test_server):
"Add KDMA button must be available for this test"
)
# Click Add KDMA button to add second KDMA
with wait_for_new_experiment_result(page):
add_kdma_button.click()
add_kdma_button.click()

# Wait for new KDMA dropdown to be added by checking for count increase
page.wait_for_function(
f"document.querySelectorAll('.table-kdma-value-select').length > {initial_count}",
timeout=5000,
timeout=10000,
)

# Check that a new KDMA dropdown was added
Expand Down Expand Up @@ -464,15 +464,15 @@ def test_kdma_delete_button_enabled_after_adding_second_kdma(
# Set initial KDMA dropdown to a valid value to enable adding another KDMA
initial_kdma_dropdown = page.locator(".table-kdma-value-select").first

with wait_for_new_experiment_result(page):
# Select option with value '1' if available
options = initial_kdma_dropdown.locator("option").all_text_contents()
for i, option in enumerate(options):
if option.strip() in ["1", "1.0"]:
initial_kdma_dropdown.select_option(index=i)
break
# Select option with value '1' if available
options = initial_kdma_dropdown.locator("option").all_text_contents()
for i, option in enumerate(options):
if option.strip() in ["1", "1.0"]:
initial_kdma_dropdown.select_option(index=i)
break

page.wait_for_load_state("networkidle")
# Wait for network to settle after KDMA change
page.wait_for_load_state("networkidle", timeout=10000)

# Check initial KDMA delete buttons - should be disabled with single KDMA
initial_delete_buttons = page.locator(".table-kdma-remove-btn")
Expand Down Expand Up @@ -502,12 +502,12 @@ def test_kdma_delete_button_enabled_after_adding_second_kdma(
expect(add_kdma_button).to_be_enabled()

# Click Add KDMA button to add second KDMA
with wait_for_new_experiment_result(page):
add_kdma_button.click()
add_kdma_button.click()

# Wait for new KDMA dropdown to be added
page.wait_for_function(
"document.querySelectorAll('.table-kdma-value-select').length > 1", timeout=5000
"document.querySelectorAll('.table-kdma-value-select').length > 1",
timeout=10000,
)

# Now check delete buttons after adding second KDMA
Expand Down Expand Up @@ -631,7 +631,8 @@ def test_kdma_add_remove_updates_experiment_results(page, real_data_test_server)

# Wait for new KDMA dropdown to be added
page.wait_for_function(
"document.querySelectorAll('.table-kdma-value-select').length > 1", timeout=5000
"document.querySelectorAll('.table-kdma-value-select').length > 1",
timeout=10000,
)

# # Check if there's a KDMA type dropdown for the new KDMA and select merit
Expand Down Expand Up @@ -686,7 +687,7 @@ def test_kdma_add_remove_updates_experiment_results(page, real_data_test_server)
# Wait for KDMA to be removed
page.wait_for_function(
"document.querySelectorAll('.table-kdma-value-select').length === 1",
timeout=5000,
timeout=10000,
)

# Wait for results to reload after removal
Expand Down Expand Up @@ -782,7 +783,8 @@ def test_add_kdma_button_always_visible(page, real_data_test_server):

# Wait for KDMA to be added
page.wait_for_function(
"document.querySelectorAll('.table-kdma-value-select').length > 1", timeout=5000
"document.querySelectorAll('.table-kdma-value-select').length > 1",
timeout=10000,
)

# Check that Add KDMA button is still visible
Expand Down Expand Up @@ -832,7 +834,7 @@ def test_run_variant_dropdown_functionality(page, real_data_test_server):

# Wait for initial auto-pin to complete
page.wait_for_function(
"document.querySelectorAll('.comparison-table tr').length > 2", timeout=5000
"document.querySelectorAll('.comparison-table tr').length > 2", timeout=10000
)

# Look for run variant row
Expand Down
Loading