diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..81561687 --- /dev/null +++ b/.env.example @@ -0,0 +1,17 @@ +# Database Configuration +# Copy this file to .env and fill in your values + +# Database Backend Selection +# Options: 'postgres' or 'duckdb' +DB_BACKEND=duckdb + +# PostgreSQL Configuration (used when DB_BACKEND=postgres) +POSTGRES_DB=tracking_analytics +POSTGRES_USER=dima +POSTGRES_PASSWORD= +POSTGRES_HOST=localhost +POSTGRES_PORT=5432 + +# DuckDB Configuration (used when DB_BACKEND=duckdb) +DUCKDB_PATH=tracking.duckdb +DUCKDB_READ_ONLY=false diff --git a/.gcloudignore b/.gcloudignore new file mode 100644 index 00000000..ee68fa40 --- /dev/null +++ b/.gcloudignore @@ -0,0 +1,87 @@ +# .gcloudignore - Exclude files from Cloud Build uploads +# This works like .dockerignore but for gcloud builds submit + +# Data directories (IMPORTANT - exclude large data files) +# Use / prefix to match only at root level +/data/ +/simulated_data/ +/trained_models/ +/meshes/ +*.duckdb +*.duckdb.wal + +# Git +.git/ +.gitignore + +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +*.egg-info/ +dist/ +build/ + +# Virtual environments +.venv/ +.venv-*/ +venv/ +env/ +ENV/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# Documentation +docs/ +*.md +*.rst + +# Tests +tests/ +.pytest_cache/ + +# Notebooks +*.ipynb +.ipynb_checkpoints/ + +# Cache +.cache/ +*.cache + +# Models and weights (if you have any) +*.pth +*.pt +*.pkl +*.h5 +*.onnx + +# Docker (keep only what we need) +Dockerfile +.dockerignore + +# Misc +.DS_Store +*.log +*.tmp + +# Keep only essential files for dashboard deployment +!requirements-db.txt +!pyproject.toml +!README.rst +!collab_env/ +!schema/ +!scripts/deploy/ + +.mypy_cache/ +submodules/ +sim-output/ +config-local/ +results/ +analysis/ +.ruff_cache/ \ No newline at end of file diff --git a/TESTING_SAFETY_README.md b/TESTING_SAFETY_README.md new file mode 100644 index 00000000..75f28fd0 --- /dev/null +++ b/TESTING_SAFETY_README.md @@ -0,0 +1,59 @@ +# 🚨 TESTING SAFETY - READ THIS FIRST! 🚨 + +## CRITICAL WARNING + +**Database tests will DROP ALL TABLES and DELETE ALL DATA!** + +## Before Running Tests + +### ✅ SAFE: Using Test Database +```bash +export POSTGRES_DB=tracking_analytics_test # Ends with _test +pytest tests/db/ +``` + +### ❌ DANGEROUS: Using Production Database +```bash +export POSTGRES_DB=tracking_analytics # Production database! +pytest tests/db/ # ← This will DELETE ALL YOUR DATA! +``` + +## Safety Checks + +Tests include automatic safety checks that will REFUSE to run if: + +1. Database name is `tracking_analytics`, `production`, `prod`, or `main` +2. Database name doesn't end with `_test` + +**If tests are skipped, this is PROTECTING YOUR DATA!** + +## Setup Test Database + +```bash +# Create test database +createdb tracking_analytics_test + +# Configure environment +export POSTGRES_DB=tracking_analytics_test +export POSTGRES_USER=your_user +export POSTGRES_PASSWORD=your_password + +# Now tests are safe to run +pytest tests/db/ -v +``` + +## Full Documentation + +See [docs/data/db/testing_safety.md](docs/data/db/testing_safety.md) for complete testing guidelines. + +## Quick Reference + +| Database Name | Tests Will Run? | Safe? | +|---------------|-----------------|-------| +| `tracking_analytics_test` | ✅ Yes | ✅ Safe | +| `mydb_test` | ✅ Yes | ✅ Safe | +| `tracking_analytics` | ❌ BLOCKED | 🚨 Would destroy data | +| `production` | ❌ BLOCKED | 🚨 Would destroy data | +| `mydb` | ❌ BLOCKED | 🚨 No _test suffix | + +**When in doubt, tests being skipped is GOOD - it means your production data is protected!** diff --git a/collab_env/dashboard/analysis_widgets.yaml b/collab_env/dashboard/analysis_widgets.yaml new file mode 100644 index 00000000..ba61578b --- /dev/null +++ b/collab_env/dashboard/analysis_widgets.yaml @@ -0,0 +1,58 @@ +# Analysis Widget Configuration +# +# This file defines which analysis widgets are enabled and their default parameters. +# Widgets are loaded in order and appear as tabs in the spatial analysis GUI. + +# Default shared parameters (used across all widgets unless overridden) +defaults: + spatial_bin_size: 10.0 # Spatial discretization for heatmaps + temporal_window_size: 10 # Time window for windowed analyses + min_samples: 100 # Minimum samples for statistical validity (matches QueryBackend default) + +# Widget registry +# Each widget must specify: +# - class: Full Python module path to widget class +# - enabled: true/false to enable/disable widget +# - order: Display order (lower numbers appear first) +# - category: Grouping category (spatial, temporal, behavioral) + +widgets: + - class: collab_env.dashboard.widgets.basic_data_viewer_widget.BasicDataViewerWidget + enabled: true + order: 0 + category: visualization + description: "Episode viewer with animated agent tracks and spatial density heatmap" + + - class: collab_env.dashboard.widgets.extended_properties_viewer_widget.ExtendedPropertiesViewerWidget + enabled: true + order: 1 + category: visualization + description: "Time series and histogram visualization of extended properties" + + - class: collab_env.dashboard.widgets.velocity_widget.VelocityStatsWidget + enabled: true + order: 2 + category: temporal + description: "Comprehensive velocity statistics: individual speed, mean velocity magnitude, relative velocity magnitude" + + - class: collab_env.dashboard.widgets.distance_widget.DistanceStatsWidget + enabled: true + order: 3 + category: spatial + description: "Relative locations: pairwise distances between agents" + + - class: collab_env.dashboard.widgets.correlation_widget.CorrelationWidget + enabled: false + order: 4 + category: behavioral + description: "Agent velocity correlations" + +# Example: To disable a widget, set enabled to false +# - class: collab_env.dashboard.widgets.correlation_widget.CorrelationWidget +# enabled: false + +# Example: To add a custom widget +# - class: my_package.widgets.custom_widget.CustomWidget +# enabled: true +# order: 5 +# category: custom diff --git a/collab_env/dashboard/spatial_analysis_app.py b/collab_env/dashboard/spatial_analysis_app.py new file mode 100644 index 00000000..7932faa5 --- /dev/null +++ b/collab_env/dashboard/spatial_analysis_app.py @@ -0,0 +1,24 @@ +""" +Entry point for Spatial Analysis Dashboard. + +Run with: + panel serve collab_env/dashboard/spatial_analysis_app.py --show --port 5008 --static-dirs dashboard-static=collab_env/dashboard/static + +Development mode with autoreload: + panel serve collab_env/dashboard/spatial_analysis_app.py --dev --show --port 5008 --static-dirs dashboard-static=collab_env/dashboard/static + +Note: The --static-dirs argument maps the dashboard's static files (JS/CSS) + to the /dashboard-static/ URL route. This is required for the animation viewer. +""" + +import panel as pn +import holoviews as hv +from collab_env.dashboard.spatial_analysis_gui import create_app + +# Enable Panel extensions (removed "modal" - not needed for HTML-based overlay) +pn.extension("tabulator", "plotly") +hv.extension("plotly", "bokeh") # plotly first for Scatter3D support + +# Create and serve the app +app = create_app() +app.servable() diff --git a/collab_env/dashboard/spatial_analysis_gui.py b/collab_env/dashboard/spatial_analysis_gui.py new file mode 100644 index 00000000..1fed18c2 --- /dev/null +++ b/collab_env/dashboard/spatial_analysis_gui.py @@ -0,0 +1,586 @@ +""" +Spatial Analysis GUI for 3D Boids Data - Refactored with Widget System. + +Panel/HoloViz-based web dashboard for interactive spatial analysis using +modular widget architecture. +""" + +import panel as pn +import param +import logging +from pathlib import Path +from typing import Optional + +from collab_env.data.db.query_backend import QueryBackend +from collab_env.dashboard.widgets import WidgetRegistry, AnalysisContext, QueryScope + +import holoviews as hv + + +# Set up logging +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + +# Enable Panel extensions +pn.extension("tabulator", "plotly") +hv.extension("plotly", "bokeh") # plotly first for Scatter3D support + + +class SpatialAnalysisGUI(param.Parameterized): + """ + Main GUI for spatial analysis of 3D boids data with modular widgets. + + Provides: + - Flexible data scope selection (episode, session, custom) + - Shared analysis parameters + - Plugin-based analysis widgets loaded from config + """ + + # Reactive parameters for scope selection + selected_category = param.String(default="", doc="Selected category ID") + selected_session = param.String(default="", doc="Selected session ID") + selected_episode = param.String(default="", doc="Selected episode ID") + scope_type = param.Selector( + default="Episode", objects=["Episode", "Session"], doc="Analysis scope type" + ) + + def __init__(self, widget_config: Optional[str] = None, **params): + super().__init__(**params) + + # Initialize query backend + try: + self.query = QueryBackend() + logger.info(f"Connected to {self.query.config.backend} database") + except Exception as e: + logger.error(f"Failed to connect to database: {e}") + raise + + # Load widgets from registry + if widget_config is None: + # Default config location + config_path = Path(__file__).parent / "analysis_widgets.yaml" + widget_config = str(config_path) + + self.registry = WidgetRegistry(widget_config) + self.widgets = self.registry.get_enabled_widgets() + logger.info(f"Loaded {len(self.widgets)} widgets") + + # Create UI components + self._create_widgets() + + # Wire callbacks + self._wire_callbacks() + + # Load initial data + self._load_categories() + self._load_sessions() + + # Initialize widget contexts + self._update_widget_contexts() + + def _create_widgets(self): + """Create all UI widgets.""" + + # === Data Scope Selection === + self.scope_type_select = pn.widgets.RadioButtonGroup( + name="Analysis Scope", + options=["Episode", "Session"], + value="Episode", + button_type="success", + ) + + self.category_select = pn.widgets.Select( + name="Category", options=[], min_width=350, sizing_mode="stretch_width" + ) + + self.session_select = pn.widgets.Select( + name="Session", options=[], min_width=350, sizing_mode="stretch_width" + ) + + self.episode_select = pn.widgets.Select( + name="Episode", options=[], min_width=350, sizing_mode="stretch_width" + ) + + # === Agent Filtering === + self.agent_type_select = pn.widgets.RadioButtonGroup( + name="Agent Type", + options=["agent", "target", "all"], + value="agent", + button_type="success", + ) + + # === Time Range Controls === + self.start_time_slider = pn.widgets.IntSlider( + name="Start Time", value=0, start=0, end=3000, step=10, width=350 + ) + + self.end_time_slider = pn.widgets.IntSlider( + name="End Time", value=3000, start=0, end=3000, step=10, width=350 + ) + + # Quick time range buttons + self.btn_before_500 = pn.widgets.Button( + name="Before t=500", button_type="default", width=110 + ) + + self.btn_after_500 = pn.widgets.Button( + name="After t=500", button_type="default", width=110 + ) + + self.btn_full_range = pn.widgets.Button( + name="Full Range", button_type="default", width=110 + ) + + # === Shared Analysis Parameters === + defaults = self.registry.get_defaults() + + self.spatial_bin_input = pn.widgets.FloatInput( + name="Spatial Bin Size", + value=defaults.get("spatial_bin_size", 10.0), + start=1.0, + end=100.0, + step=1.0, + width=350, + ) + + self.temporal_window_input = pn.widgets.IntInput( + name="Time Window Size", + value=defaults.get("temporal_window_size", 10), + start=2, + end=1000, + step=2, + width=350, + ) + + self.min_samples_input = pn.widgets.IntInput( + name="Min Samples", + value=defaults.get("min_samples", 10), + start=1, + end=1000, + width=350, + ) + + # === Status and Loading Indicators === + self.status_pane = pn.pane.HTML( + "

Ready. Select a session to begin.

", sizing_mode="stretch_width" + ) + + self.loading_indicator = pn.indicators.LoadingSpinner( + value=False, width=50, height=50 + ) + + def _wire_callbacks(self): + """Wire widget callbacks.""" + + # Category/Session/Episode selection + self.category_select.param.watch(self._on_category_change, "value") + self.session_select.param.watch(self._on_session_change, "value") + self.episode_select.param.watch(self._on_episode_change, "value") + + # Quick time range buttons + self.btn_before_500.on_click(self._set_before_500) + self.btn_after_500.on_click(self._set_after_500) + self.btn_full_range.on_click(self._set_full_range) + + # Update contexts when scope parameters change + self.scope_type_select.param.watch( + lambda e: self._update_widget_contexts(), "value" + ) + self.agent_type_select.param.watch( + lambda e: self._update_widget_contexts(), "value" + ) + self.start_time_slider.param.watch( + lambda e: self._update_widget_contexts(), "value" + ) + self.end_time_slider.param.watch( + lambda e: self._update_widget_contexts(), "value" + ) + + # Shared parameter changes + self.spatial_bin_input.param.watch( + lambda e: self._update_widget_contexts(), "value" + ) + self.temporal_window_input.param.watch( + lambda e: self._update_widget_contexts(), "value" + ) + self.min_samples_input.param.watch( + lambda e: self._update_widget_contexts(), "value" + ) + + # ==================== Status Helpers ==================== + + def _show_loading(self, message: str = "Loading..."): + """Show loading indicator with message.""" + self.loading_indicator.value = True + self.status_pane.object = f"

{message}

" + + def _hide_loading(self): + """Hide loading indicator.""" + self.loading_indicator.value = False + + def _show_success(self, message: str): + """Show success message.""" + self._hide_loading() + self.status_pane.object = f"

✅ {message}

" + + def _show_error(self, message: str): + """Show error message.""" + self._hide_loading() + self.status_pane.object = f"

❌ Error: {message}

" + + # ==================== Data Loading ==================== + + def _load_categories(self): + """Load available categories.""" + try: + categories_df = self.query.get_categories() + if len(categories_df) == 0: + self.category_select.options = [""] + self.status_pane.object = ( + "

⚠️ No categories found in database.

" + ) + else: + # Create display names (category_name) + category_options = { + row["category_name"]: row["category_id"] + for _, row in categories_df.iterrows() + } + self.category_select.options = [""] + list(category_options.keys()) + self.category_select.param.trigger("options") + self._category_map = category_options + logger.info(f"Loaded {len(categories_df)} categories") + except Exception as e: + logger.error(f"Failed to load categories: {e}") + self._show_error(f"Failed to load categories: {e}") + + def _load_sessions(self): + """Load available sessions for the selected category.""" + # Get current category selection (None if not selected) + category_id = self.selected_category if self.selected_category else None + + try: + sessions_df = self.query.get_sessions(category_id=category_id) + if len(sessions_df) == 0: + self.session_select.options = [""] + if category_id: + self.status_pane.object = f"

⚠️ No sessions found for category '{category_id}'.

" + else: + self.status_pane.object = "

⚠️ No sessions found. Load data first.

" + else: + # Create display names (session_name) + session_options = { + row["session_name"]: row["session_id"] + for _, row in sessions_df.iterrows() + } + self.session_select.options = [""] + list(session_options.keys()) + self.session_select.param.trigger("options") + self._session_map = session_options + logger.info(f"Loaded {len(sessions_df)} sessions") + except Exception as e: + logger.error(f"Failed to load sessions: {e}") + self._show_error(f"Failed to load sessions: {e}") + + def _on_category_change(self, event): + """Handle category selection.""" + category_name = event.new + if not category_name or category_name == "": + self.session_select.options = [""] + self.episode_select.options = [""] + return + + try: + # Get the category ID from the category map + category_id = self._category_map[category_name] + self.selected_category = category_id + + # Load sessions for this category + self._load_sessions() + + # Clear episode selection + self.episode_select.options = [""] + + except Exception as e: + logger.error(f"Failed to load category: {e}") + self._show_error(f"Failed to load category: {e}") + + def _on_session_change(self, event): + """Handle session selection.""" + session_name = event.new + if not session_name or session_name == "": + self.episode_select.options = [""] + return + + try: + session_id = self._session_map[session_name] + self.selected_session = session_id + + # Load episodes + episodes_df = self.query.get_episodes(session_id) + if len(episodes_df) == 0: + self.episode_select.options = [""] + self._show_error("No episodes found for this session") + else: + # Create display names (episode_id for clarity, especially for GNN rollouts) + episode_options = { + row["episode_id"]: row["episode_id"] + for _, row in episodes_df.iterrows() + } + self.episode_select.options = [""] + list(episode_options.keys()) + self.episode_select.param.trigger("options") + self._episode_map = episode_options + + # Update time range sliders based on session's episodes + # Use the maximum num_frames across all episodes in the session + max_frames = int(episodes_df["num_frames"].max()) + self.start_time_slider.end = max_frames + self.end_time_slider.end = max_frames + self.end_time_slider.value = max_frames + logger.info(f"Updated time range for session: 0 to {max_frames} frames") + + # Get agent types from session + agent_types_df = self.query.get_agent_types_for_session(session_id) + if len(agent_types_df) > 0: + agent_types = agent_types_df["agent_type_id"].tolist() + # Always include 'all' option + agent_types_with_all = agent_types + ["all"] + self.agent_type_select.options = agent_types_with_all + # Set default to first agent type + self.agent_type_select.value = ( + agent_types[0] if agent_types else "all" + ) + logger.info( + f"Loaded {len(agent_types)} agent types for session: {agent_types}" + ) + + self._show_success( + f"Loaded {len(episodes_df)} episodes (max {max_frames} frames, {len(agent_types_df)} agent types)" + ) + logger.info(f"Loaded {len(episodes_df)} episodes") + + # Update widget contexts for session scope + self._update_widget_contexts() + + except Exception as e: + logger.error(f"Failed to load episodes: {e}") + self._show_error(f"Failed to load episodes: {e}") + + def _on_episode_change(self, event): + """Handle episode selection.""" + episode_name = event.new + if not episode_name or episode_name == "": + return + + try: + episode_id = self._episode_map[episode_name] + self.selected_episode = episode_id + + # Get episode metadata to update time range + metadata = self.query.get_episode_metadata(episode_id) + if len(metadata) > 0: + num_frames = int(metadata.iloc[0]["num_frames"]) + self.start_time_slider.end = num_frames + self.end_time_slider.end = num_frames + self.end_time_slider.value = num_frames + + # Get agent types from episode + agent_types_df = self.query.get_agent_types(episode_id) + if len(agent_types_df) > 0: + agent_types = agent_types_df["agent_type_id"].tolist() + # Always include 'all' option + agent_types_with_all = agent_types + ["all"] + self.agent_type_select.options = agent_types_with_all + # Set default to first agent type + self.agent_type_select.value = ( + agent_types[0] if agent_types else "all" + ) + logger.info(f"Loaded {len(agent_types)} agent types: {agent_types}") + + self._show_success( + f"Episode selected ({num_frames} frames, {len(agent_types_df)} agent types)" + ) + logger.info(f"Selected episode {episode_id} ({num_frames} frames)") + + # Update widget contexts for episode scope + self._update_widget_contexts() + + except Exception as e: + logger.error(f"Failed to load episode metadata: {e}") + self._show_error(f"Failed to load episode metadata: {e}") + + # ==================== Time Range Controls ==================== + + def _set_before_500(self, event): + """Set time range to before t=500.""" + self.start_time_slider.value = 0 + self.end_time_slider.value = 500 + + def _set_after_500(self, event): + """Set time range to after t=500.""" + self.start_time_slider.value = 500 + self.end_time_slider.value = self.end_time_slider.end + + def _set_full_range(self, event): + """Set time range to full episode.""" + self.start_time_slider.value = 0 + self.end_time_slider.value = self.end_time_slider.end + + # ==================== Context Management ==================== + + def _get_current_scope(self) -> Optional[QueryScope]: + """Build QueryScope from current UI state.""" + scope_type_str = self.scope_type_select.value.lower() + + if scope_type_str == "episode": + if not self.selected_episode: + return None + + return QueryScope.from_episode( + episode_id=self.selected_episode, + start_time=self.start_time_slider.value, + end_time=self.end_time_slider.value, + agent_type=self.agent_type_select.value, + ) + + elif scope_type_str == "session": + if not self.selected_session: + return None + + return QueryScope.from_session( + session_id=self.selected_session, + start_time=self.start_time_slider.value, + end_time=self.end_time_slider.value, + agent_type=self.agent_type_select.value, + ) + + return None + + def _get_context(self) -> Optional[AnalysisContext]: + """Build AnalysisContext from current UI state.""" + scope = self._get_current_scope() + if scope is None: + return None + + return AnalysisContext( + query_backend=self.query, + scope=scope, + spatial_bin_size=self.spatial_bin_input.value, + temporal_window_size=self.temporal_window_input.value, + min_samples=self.min_samples_input.value, + on_loading=self._show_loading, + on_success=self._show_success, + on_error=self._show_error, + ) + + def _update_widget_contexts(self): + """Update context for all widgets when scope changes.""" + context = self._get_context() + if context: + for widget in self.widgets: + widget.context = context + logger.debug(f"Updated widget contexts: {context.scope}") + + @param.depends("scope_type_select.value") + def _get_data_selectors(self): + """Get data selection widgets based on current scope type.""" + scope = self.scope_type_select.value + + if scope == "Episode": + # Episode scope: show category, session, and episode selectors + return pn.Column( + self.category_select, self.session_select, self.episode_select + ) + else: # Session scope + # Session scope: show only category and session selectors (no episode) + return pn.Column( + self.category_select, + self.session_select, + pn.pane.Markdown( + "_Episode selection not required for session-level analysis_", + styles={"font-size": "0.9em", "color": "#666"}, + ), + ) + + @param.depends("scope_type_select.value") + def _get_time_range_controls(self): + """Get time range controls (available for both Episode and Session scope).""" + scope = self.scope_type_select.value + + if scope == "Episode": + # Episode scope: show time range controls with quick action buttons + return pn.Column( + "## Time Range", + self.start_time_slider, + self.end_time_slider, + pn.Row(self.btn_before_500, self.btn_after_500, self.btn_full_range), + pn.layout.Divider(), + ) + else: # Session scope + # Session scope: show time range controls (filters across all episodes) + return pn.Column( + "## Time Range (applies to all episodes in session)", + self.start_time_slider, + self.end_time_slider, + pn.pane.Markdown( + "_Filter data across all episodes in the session_", + styles={"font-size": "0.9em", "color": "#666"}, + ), + pn.layout.Divider(), + ) + + # ==================== Layout ==================== + + def create_layout(self): + """Create the dashboard layout with dynamic widget tabs.""" + + # Sidebar with scope selection + shared parameters + sidebar = pn.Column( + "## Data Selection", + self.scope_type_select, + self._get_data_selectors, + pn.layout.Divider(), + "## Agent Type", + self.agent_type_select, + pn.layout.Divider(), + self._get_time_range_controls, + "## Shared Parameters", + self.spatial_bin_input, + self.temporal_window_input, + self.min_samples_input, + width=400, + sizing_mode="stretch_height", + ) + + # Main content: Dynamic tabs from widgets + tabs = pn.Tabs( + *[(w.widget_name, w.get_tab_content()) for w in self.widgets], + sizing_mode="stretch_both", + ) + + # Status bar with loading indicator + status_bar = pn.Row( + self.loading_indicator, self.status_pane, sizing_mode="stretch_width" + ) + + # Create template + template = pn.template.MaterialTemplate( + title="CIS Analysis Dashboard", + sidebar=[sidebar], + main=[status_bar, tabs], + header_background="#2596be", + sidebar_width=400, + ) + + return template + + +def create_app(): + """ + Create and return the spatial analysis app. + + Returns + ------- + pn.template.MaterialTemplate + Panel template ready to serve + """ + gui = SpatialAnalysisGUI() + return gui.create_layout() diff --git a/collab_env/dashboard/static/js/viewers/episode_animation_viewer.js b/collab_env/dashboard/static/js/viewers/episode_animation_viewer.js new file mode 100644 index 00000000..e39e4052 --- /dev/null +++ b/collab_env/dashboard/static/js/viewers/episode_animation_viewer.js @@ -0,0 +1,317 @@ +/** + * Episode Animation Viewer - client-side 2D animation for episode tracks + * + * Handles 2D visualization with smooth playback using Canvas API. + * Data is embedded directly from Panel - no HTTP requests needed. + */ + +import { FrameManager } from '../utils/frame_manager.js'; + +export class EpisodeAnimationViewer { + constructor(animationData, canvasId) { + console.log('🚀 Starting Episode Animation Viewer'); + + this.data = animationData; + this.canvasId = canvasId; + + // Validate data + if (!this.data || !this.data.tracks || this.data.tracks.length === 0) { + console.error('No track data available'); + return; + } + + // Canvas and context + this.canvas = document.getElementById(canvasId); + if (!this.canvas) { + console.error(`Canvas element not found: ${canvasId}`); + return; + } + this.ctx = this.canvas.getContext('2d'); + + // Frame management + const timeRange = this.data.time_range || [0, 100]; + this.frameManager = new FrameManager(timeRange[1] - timeRange[0]); + this.frameManager.setSpeed(this.data.settings.playback_speed || 1.0); + + // Settings from Panel + this.trailLength = this.data.settings.trail_length || 50; + this.showIds = this.data.settings.show_agent_ids !== false; + + // Bounds from data + this.xRange = this.data.bounds.x_range || [0, 1]; + this.yRange = this.data.bounds.y_range || [0, 1]; + + // Agent colors + this.agentColors = this.data.agent_colors || {}; + + // Organize tracks by time and agent for efficient lookup + this.tracksByTime = this._organizeTracks(); + + // Trail history: {agent_id: [{x, y, time}, ...]} + this.trailHistory = {}; + + // Agent appearance + this.agentRadius = 8; + + // Animation state + this.animationId = null; + + // Initialize + this.init(); + } + + init() { + this.setupCanvas(); + this.setupFrameListener(); + this.startAnimation(); + + console.log('✅ Episode Animation Viewer ready'); + console.log(` Tracks: ${this.data.tracks.length} points`); + console.log(` Time range: ${this.data.time_range[0]} - ${this.data.time_range[1]}`); + console.log(` Bounds: X[${this.xRange[0]}, ${this.xRange[1]}], Y[${this.yRange[0]}, ${this.yRange[1]}]`); + } + + setupCanvas() { + // Set canvas size to match container + const resizeCanvas = () => { + const rect = this.canvas.getBoundingClientRect(); + this.canvas.width = rect.width; + this.canvas.height = rect.height; + this.render(); // Re-render after resize + }; + + resizeCanvas(); + window.addEventListener('resize', resizeCanvas); + this.resizeHandler = resizeCanvas; + } + + _organizeTracks() { + /** + * Organize tracks by time_index for fast lookup + * Returns: {time_index: {agent_id: {x, y, speed, ...}, ...}, ...} + */ + const tracksByTime = {}; + + for (const track of this.data.tracks) { + const time = track.time_index; + if (!tracksByTime[time]) { + tracksByTime[time] = {}; + } + tracksByTime[time][track.agent_id] = track; + } + + return tracksByTime; + } + + setupFrameListener() { + // Register callback for frame changes + this.frameManager.onFrameChange((frame) => { + this.updateTrailHistory(frame); + }); + } + + updateTrailHistory(frame) { + /** + * Update trail history for the current frame + * Maintains a sliding window of trail_length frames + */ + const currentTime = this.data.time_range[0] + frame; + const startTime = Math.max(this.data.time_range[0], currentTime - this.trailLength); + + // Clear trail history + this.trailHistory = {}; + + // Build trail history from startTime to currentTime + for (let t = startTime; t <= currentTime; t++) { + const tracksAtTime = this.tracksByTime[t]; + if (!tracksAtTime) continue; + + for (const agentId in tracksAtTime) { + const track = tracksAtTime[agentId]; + + if (!this.trailHistory[agentId]) { + this.trailHistory[agentId] = []; + } + + this.trailHistory[agentId].push({ + x: track.x, + y: track.y, + time: t + }); + } + } + } + + startAnimation() { + // Start render loop + const animate = () => { + this.render(); + this.animationId = requestAnimationFrame(animate); + }; + animate(); + } + + render() { + if (!this.ctx) return; + + // Clear canvas + this.ctx.fillStyle = '#1a1a1a'; + this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); + + // Get current frame and time + const frame = this.frameManager.currentFrame; + const currentTime = this.data.time_range[0] + frame; + + // Draw grid + this.drawGrid(); + + // Draw trails + this.drawTrails(); + + // Draw current positions + this.drawCurrentPositions(currentTime); + } + + drawGrid() { + /** + * Draw background grid for reference + */ + this.ctx.strokeStyle = 'rgba(255, 255, 255, 0.1)'; + this.ctx.lineWidth = 1; + + // Vertical lines + const numVerticalLines = 10; + for (let i = 0; i <= numVerticalLines; i++) { + const x = (i / numVerticalLines) * this.canvas.width; + this.ctx.beginPath(); + this.ctx.moveTo(x, 0); + this.ctx.lineTo(x, this.canvas.height); + this.ctx.stroke(); + } + + // Horizontal lines + const numHorizontalLines = 10; + for (let i = 0; i <= numHorizontalLines; i++) { + const y = (i / numHorizontalLines) * this.canvas.height; + this.ctx.beginPath(); + this.ctx.moveTo(0, y); + this.ctx.lineTo(this.canvas.width, y); + this.ctx.stroke(); + } + } + + drawTrails() { + /** + * Draw trails for all agents + */ + for (const agentId in this.trailHistory) { + const trail = this.trailHistory[agentId]; + if (trail.length < 2) continue; + + const color = this.agentColors[agentId] || '#888888'; + + this.ctx.strokeStyle = color; + this.ctx.lineWidth = 2; + this.ctx.globalAlpha = 0.6; + + this.ctx.beginPath(); + const firstPoint = trail[0]; + const [x0, y0] = this.worldToCanvas(firstPoint.x, firstPoint.y); + this.ctx.moveTo(x0, y0); + + for (let i = 1; i < trail.length; i++) { + const point = trail[i]; + const [x, y] = this.worldToCanvas(point.x, point.y); + this.ctx.lineTo(x, y); + } + + this.ctx.stroke(); + this.ctx.globalAlpha = 1.0; + } + } + + drawCurrentPositions(currentTime) { + /** + * Draw current agent positions as colored circles + */ + const tracksAtTime = this.tracksByTime[currentTime]; + if (!tracksAtTime) return; + + for (const agentId in tracksAtTime) { + const track = tracksAtTime[agentId]; + const color = this.agentColors[agentId] || '#888888'; + + const [x, y] = this.worldToCanvas(track.x, track.y); + + // Draw circle + this.ctx.fillStyle = color; + this.ctx.beginPath(); + this.ctx.arc(x, y, this.agentRadius, 0, 2 * Math.PI); + this.ctx.fill(); + + // Draw border + this.ctx.strokeStyle = '#ffffff'; + this.ctx.lineWidth = 2; + this.ctx.stroke(); + + // Draw agent ID if enabled + if (this.showIds) { + this.ctx.fillStyle = '#ffffff'; + this.ctx.font = 'bold 12px sans-serif'; + this.ctx.textAlign = 'center'; + this.ctx.textBaseline = 'middle'; + this.ctx.fillText(agentId.toString(), x, y); + } + } + } + + worldToCanvas(x, y) { + /** + * Convert world coordinates to canvas coordinates + * World coordinates are in the range [xRange, yRange] + * Canvas coordinates are in pixels + */ + const xNorm = (x - this.xRange[0]) / (this.xRange[1] - this.xRange[0]); + const yNorm = (y - this.yRange[0]) / (this.yRange[1] - this.yRange[0]); + + const canvasX = xNorm * this.canvas.width; + // Flip Y axis (canvas Y increases downward, world Y increases upward) + const canvasY = (1 - yNorm) * this.canvas.height; + + return [canvasX, canvasY]; + } + + setAgentSize(radius) { + /** + * Set the agent circle radius + */ + console.log(`2D setAgentSize called with radius: ${radius}`); + this.agentRadius = radius; + } + + destroy() { + /** + * Clean up resources + */ + console.log('🛑 Destroying Episode Animation Viewer'); + + // Stop animation + if (this.animationId) { + cancelAnimationFrame(this.animationId); + this.animationId = null; + } + + // Stop frame manager + if (this.frameManager) { + this.frameManager.destroy(); + } + + // Remove resize handler + if (this.resizeHandler) { + window.removeEventListener('resize', this.resizeHandler); + } + + console.log('✅ Episode Animation Viewer destroyed'); + } +} +// Cache bust: 1736812800 diff --git a/collab_env/dashboard/static/js/viewers/episode_animation_viewer_3d.js b/collab_env/dashboard/static/js/viewers/episode_animation_viewer_3d.js new file mode 100644 index 00000000..5c16297a --- /dev/null +++ b/collab_env/dashboard/static/js/viewers/episode_animation_viewer_3d.js @@ -0,0 +1,517 @@ +/** + * Episode Animation Viewer 3D - client-side 3D animation for episode tracks + * + * Handles 3D visualization with smooth playback using Three.js WebGL. + * Data is embedded directly from Panel - no HTTP requests needed. + */ + +import * as THREE from 'three'; +import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; +import { CSS2DRenderer, CSS2DObject } from 'three/addons/renderers/CSS2DRenderer.js'; +import { FrameManager } from '../utils/frame_manager.js'; + +export class EpisodeAnimationViewer { + constructor(animationData, canvasId) { + console.log('🚀 Starting Episode Animation Viewer 3D'); + + this.data = animationData; + this.canvasId = canvasId; + + // Validate data + if (!this.data || !this.data.tracks || this.data.tracks.length === 0) { + console.error('No track data available'); + return; + } + + // Canvas element (or container) + this.canvasElement = document.getElementById(canvasId); + if (!this.canvasElement) { + console.error(`Canvas element not found: ${canvasId}`); + return; + } + + // Determine if we have a canvas or container + this.isCanvasElement = this.canvasElement.tagName.toLowerCase() === 'canvas'; + + // Three.js components + this.scene = null; + this.camera = null; + this.renderer = null; + this.labelRenderer = null; + this.controls = null; + + // Scene objects + this.spheres = {}; // agent_id -> sphere mesh + this.trails = {}; // agent_id -> line/tube mesh + this.labels = {}; // agent_id -> CSS2D label + this.trailPositions = {}; // agent_id -> [{x, y, z, time}, ...] + + // Frame management + const timeRange = this.data.time_range || [0, 100]; + this.frameManager = new FrameManager(timeRange[1] - timeRange[0]); + this.frameManager.setSpeed(this.data.settings.playback_speed || 1.0); + + // Settings from Panel + this.trailLength = this.data.settings.trail_length || 50; + this.showIds = this.data.settings.show_agent_ids !== false; + + // Bounds from data + this.xRange = this.data.bounds.x_range || [0, 1]; + this.yRange = this.data.bounds.y_range || [0, 1]; + this.zRange = this.data.bounds.z_range || [0, 1]; + + // Agent colors + this.agentColors = this.data.agent_colors || {}; + + // Organize tracks by time and agent for efficient lookup + this.tracksByTime = this._organizeTracks(); + + // Calculate scene parameters + this.sceneCenter = new THREE.Vector3( + (this.xRange[0] + this.xRange[1]) / 2, + (this.yRange[0] + this.yRange[1]) / 2, + (this.zRange[0] + this.zRange[1]) / 2 + ); + this.sceneSize = Math.max( + this.xRange[1] - this.xRange[0], + this.yRange[1] - this.yRange[0], + this.zRange[1] - this.zRange[0] + ); + + // Calculate appropriate sphere size (0.5% of scene size) + this.sphereSize = this.sceneSize * 0.005; + + // Agent appearance scale (1.0 = default, adjustable via setAgentSize) + this.currentScale = 1.0; + + // Animation state + this.animationId = null; + + // Initialize + this.init(); + } + + init() { + this.setupScene(); + this.setupCamera(); + this.setupRenderer(); + this.setupLights(); + this.setupHelpers(); + this.initializeAgents(); + this.setupFrameListener(); + this.startAnimation(); + + console.log('✅ Episode Animation Viewer 3D ready'); + console.log(` Canvas mode: ${this.isCanvasElement ? 'Using existing ' : 'Created new canvas in container'}`); + console.log(` Tracks: ${this.data.tracks.length} points`); + console.log(` Time range: ${this.data.time_range[0]} - ${this.data.time_range[1]}`); + console.log(` Bounds: X[${this.xRange[0]}, ${this.xRange[1]}], Y[${this.yRange[0]}, ${this.yRange[1]}], Z[${this.zRange[0]}, ${this.zRange[1]}]`); + console.log(` Scene size: ${this.sceneSize.toFixed(2)}, Sphere size: ${this.sphereSize.toFixed(4)}`); + } + + setupScene() { + this.scene = new THREE.Scene(); + this.scene.background = new THREE.Color(0x1a1a1a); + } + + setupCamera() { + const rect = this.canvasElement.getBoundingClientRect(); + this.camera = new THREE.PerspectiveCamera( + 60, + rect.width / rect.height, + this.sceneSize * 0.001, + this.sceneSize * 10 + ); + + // Position camera to view the entire scene + const distance = this.sceneSize * 1.5; + this.camera.position.set( + this.sceneCenter.x + distance * 0.5, + this.sceneCenter.y + distance * 0.5, + this.sceneCenter.z + distance * 0.5 + ); + this.camera.lookAt(this.sceneCenter); + } + + setupRenderer() { + const rect = this.canvasElement.getBoundingClientRect(); + + // WebGL renderer - use existing canvas if available + if (this.isCanvasElement) { + // Use the existing canvas element + this.renderer = new THREE.WebGLRenderer({ + canvas: this.canvasElement, + antialias: true + }); + } else { + // Create new canvas and append to container + this.renderer = new THREE.WebGLRenderer({ antialias: true }); + this.canvasElement.appendChild(this.renderer.domElement); + } + + this.renderer.setSize(rect.width, rect.height); + this.renderer.setPixelRatio(window.devicePixelRatio); + + // CSS2D renderer for labels + this.labelRenderer = new CSS2DRenderer(); + this.labelRenderer.setSize(rect.width, rect.height); + this.labelRenderer.domElement.style.position = 'absolute'; + this.labelRenderer.domElement.style.top = '0px'; + this.labelRenderer.domElement.style.left = '0px'; + this.labelRenderer.domElement.style.pointerEvents = 'none'; + this.labelRenderer.domElement.style.width = '100%'; + this.labelRenderer.domElement.style.height = '100%'; + + // Append label renderer to parent (works for both canvas and container) + const parent = this.isCanvasElement ? this.canvasElement.parentElement : this.canvasElement; + if (parent) { + // Ensure parent has relative positioning for absolute child + if (parent.style.position !== 'absolute' && parent.style.position !== 'relative') { + parent.style.position = 'relative'; + } + parent.appendChild(this.labelRenderer.domElement); + } + + // OrbitControls + this.controls = new OrbitControls(this.camera, this.renderer.domElement); + this.controls.enableDamping = true; + this.controls.dampingFactor = 0.05; + this.controls.target.copy(this.sceneCenter); + this.controls.update(); + + // Handle window resize + this.resizeHandler = () => this.onWindowResize(); + window.addEventListener('resize', this.resizeHandler); + } + + setupLights() { + // Ambient light + const ambientLight = new THREE.AmbientLight(0xffffff, 0.6); + this.scene.add(ambientLight); + + // Directional light + const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8); + directionalLight.position.set( + this.sceneCenter.x + this.sceneSize, + this.sceneCenter.y + this.sceneSize, + this.sceneCenter.z + this.sceneSize + ); + this.scene.add(directionalLight); + } + + setupHelpers() { + // Grid helper on XY plane + const gridSize = this.sceneSize * 1.2; + const gridDivisions = 20; + const gridHelper = new THREE.GridHelper(gridSize, gridDivisions, 0x444444, 0x222222); + gridHelper.position.copy(this.sceneCenter); + // Rotate to XY plane (grid is normally on XZ) + gridHelper.rotation.x = Math.PI / 2; + this.scene.add(gridHelper); + + // Axes helper + const axesHelper = new THREE.AxesHelper(this.sceneSize * 0.2); + axesHelper.position.copy(this.sceneCenter); + this.scene.add(axesHelper); + } + + _organizeTracks() { + /** + * Organize tracks by time_index for fast lookup + * Returns: {time_index: {agent_id: {x, y, z, speed, ...}, ...}, ...} + */ + const tracksByTime = {}; + + for (const track of this.data.tracks) { + const time = track.time_index; + if (!tracksByTime[time]) { + tracksByTime[time] = {}; + } + tracksByTime[time][track.agent_id] = track; + } + + return tracksByTime; + } + + initializeAgents() { + /** + * Create spheres and labels for all unique agents + */ + // Extract all unique agent IDs + const uniqueAgentIds = new Set(); + for (const track of this.data.tracks) { + uniqueAgentIds.add(track.agent_id); + } + + console.log(`Creating ${uniqueAgentIds.size} agent spheres`); + + // Shared geometry for efficiency + const sphereGeometry = new THREE.SphereGeometry(this.sphereSize, 16, 12); + + for (const agentId of uniqueAgentIds) { + const colorHex = this.agentColors[agentId] || '#888888'; + const color = new THREE.Color(colorHex); + + // Create sphere + const material = new THREE.MeshPhongMaterial({ + color: color, + emissive: color, + emissiveIntensity: 0.3, + shininess: 100 + }); + + const sphere = new THREE.Mesh(sphereGeometry, material); + sphere.castShadow = true; + sphere.visible = false; + this.spheres[agentId] = sphere; + this.scene.add(sphere); + + // Create label + if (this.showIds) { + const labelDiv = document.createElement('div'); + labelDiv.className = 'agent-label'; + labelDiv.textContent = agentId.toString(); + labelDiv.style.color = colorHex; + labelDiv.style.fontFamily = 'Arial, sans-serif'; + labelDiv.style.fontSize = '12px'; + labelDiv.style.fontWeight = 'bold'; + labelDiv.style.textShadow = '1px 1px 2px rgba(0,0,0,0.8)'; + labelDiv.style.pointerEvents = 'none'; + labelDiv.style.userSelect = 'none'; + + const label = new CSS2DObject(labelDiv); + label.visible = this.showIds; + this.labels[agentId] = label; + this.scene.add(label); + } + } + } + + setupFrameListener() { + // Register callback for frame changes + this.frameManager.onFrameChange((frame) => { + this.updateTrailHistory(frame); + this.updateFrame(frame); + }); + } + + updateTrailHistory(frame) { + /** + * Update trail history for the current frame + * Maintains a sliding window of trail_length frames + */ + const currentTime = this.data.time_range[0] + frame; + const startTime = Math.max(this.data.time_range[0], currentTime - this.trailLength); + + // Clear trail history + this.trailPositions = {}; + + // Build trail history from startTime to currentTime + for (let t = startTime; t <= currentTime; t++) { + const tracksAtTime = this.tracksByTime[t]; + if (!tracksAtTime) continue; + + for (const agentId in tracksAtTime) { + const track = tracksAtTime[agentId]; + + if (!this.trailPositions[agentId]) { + this.trailPositions[agentId] = []; + } + + this.trailPositions[agentId].push({ + x: track.x, + y: track.y, + z: track.z, + time: t + }); + } + } + } + + updateFrame(frame) { + /** + * Update scene for the current frame + */ + const currentTime = this.data.time_range[0] + frame; + const tracksAtTime = this.tracksByTime[currentTime]; + + // Hide all spheres and labels first + Object.values(this.spheres).forEach(sphere => { + if (sphere) sphere.visible = false; + }); + Object.values(this.labels).forEach(label => { + if (label) label.visible = false; + }); + + let visibleCount = 0; + + // Update visible tracks + if (tracksAtTime) { + for (const agentId in tracksAtTime) { + const track = tracksAtTime[agentId]; + const sphere = this.spheres[agentId]; + + if (sphere && track.x !== null && track.y !== null && track.z !== null) { + sphere.position.set(track.x, track.y, track.z); + sphere.visible = true; + visibleCount++; + + // Update label position + const label = this.labels[agentId]; + if (label && this.showIds) { + // Center label on the agent + label.position.copy(sphere.position); + label.visible = true; + } + } + } + } + + // Update trails + this.updateTrails(); + } + + updateTrails() { + /** + * Update trail geometries for all agents with trail data + */ + // Remove old trails + Object.values(this.trails).forEach(trail => { + if (trail) { + this.scene.remove(trail); + trail.geometry.dispose(); + trail.material.dispose(); + } + }); + this.trails = {}; + + // Create new trails + for (const agentId in this.trailPositions) { + const positions = this.trailPositions[agentId]; + if (positions.length < 2) continue; + + const colorHex = this.agentColors[agentId] || '#888888'; + const color = new THREE.Color(colorHex); + + // Create curve from positions + const points = positions.map(pos => new THREE.Vector3(pos.x, pos.y, pos.z)); + const curve = new THREE.CatmullRomCurve3(points); + + // Use TubeGeometry for visible 3D trails + const tubeRadius = (this.sphereSize * this.currentScale) / 3; + const tubeGeometry = new THREE.TubeGeometry(curve, 32, tubeRadius, 8, false); + const tubeMaterial = new THREE.MeshBasicMaterial({ + color: color, + opacity: 0.6, + transparent: true + }); + + const trail = new THREE.Mesh(tubeGeometry, tubeMaterial); + this.trails[agentId] = trail; + this.scene.add(trail); + } + } + + onWindowResize() { + const rect = this.canvasElement.getBoundingClientRect(); + this.camera.aspect = rect.width / rect.height; + this.camera.updateProjectionMatrix(); + this.renderer.setSize(rect.width, rect.height); + this.labelRenderer.setSize(rect.width, rect.height); + } + + startAnimation() { + // Start render loop + const animate = () => { + this.controls.update(); + this.renderer.render(this.scene, this.camera); + this.labelRenderer.render(this.scene, this.camera); + this.animationId = requestAnimationFrame(animate); + }; + animate(); + } + + setAgentSize(scaleFactor) { + /** + * Set the agent sphere scale + * scaleFactor: 1.0 = default size, 2.0 = double, 0.5 = half + */ + // Convert slider value (2-30) to scale factor (0.25x to 3.75x) + // Default slider value 8 should give scale 1.0 + this.currentScale = scaleFactor / 8; + console.log(`3D setAgentSize called with scaleFactor: ${scaleFactor}, currentScale: ${this.currentScale}`); + + // Scale all spheres efficiently using scale transform + for (const agentId in this.spheres) { + this.spheres[agentId].scale.set(this.currentScale, this.currentScale, this.currentScale); + } + console.log(`Scaled ${Object.keys(this.spheres).length} spheres`); + } + + destroy() { + /** + * Clean up resources + */ + console.log('🛑 Destroying Episode Animation Viewer 3D'); + + // Stop animation + if (this.animationId) { + cancelAnimationFrame(this.animationId); + this.animationId = null; + } + + // Stop frame manager + if (this.frameManager) { + this.frameManager.destroy(); + } + + // Dispose geometries and materials + Object.values(this.spheres).forEach(sphere => { + if (sphere) { + this.scene.remove(sphere); + sphere.geometry.dispose(); + sphere.material.dispose(); + } + }); + + Object.values(this.trails).forEach(trail => { + if (trail) { + this.scene.remove(trail); + trail.geometry.dispose(); + trail.material.dispose(); + } + }); + + Object.values(this.labels).forEach(label => { + if (label) { + this.scene.remove(label); + } + }); + + // Dispose renderer + if (this.renderer) { + this.renderer.dispose(); + // Only remove renderer's canvas if we created it (not using existing canvas) + if (!this.isCanvasElement && this.renderer.domElement) { + this.renderer.domElement.remove(); + } + } + + if (this.labelRenderer && this.labelRenderer.domElement) { + this.labelRenderer.domElement.remove(); + } + + // Remove resize handler + if (this.resizeHandler) { + window.removeEventListener('resize', this.resizeHandler); + } + + // Dispose controls + if (this.controls) { + this.controls.dispose(); + } + + console.log('✅ Episode Animation Viewer 3D destroyed'); + } +} +// Cache bust: 1736812801 diff --git a/collab_env/dashboard/templates/animation_modal.html b/collab_env/dashboard/templates/animation_modal.html new file mode 100644 index 00000000..51eb5706 --- /dev/null +++ b/collab_env/dashboard/templates/animation_modal.html @@ -0,0 +1,169 @@ + + + diff --git a/collab_env/dashboard/widgets/__init__.py b/collab_env/dashboard/widgets/__init__.py new file mode 100644 index 00000000..04fa63c1 --- /dev/null +++ b/collab_env/dashboard/widgets/__init__.py @@ -0,0 +1,20 @@ +""" +Analysis widgets for spatial analysis dashboard. + +This package provides a modular plugin architecture for analysis widgets. +Each widget is self-contained and registered via YAML configuration. +""" + +from .query_scope import QueryScope, ScopeType +from .analysis_context import AnalysisContext +from .base_analysis_widget import BaseAnalysisWidget, Dimensionality +from .widget_registry import WidgetRegistry + +__all__ = [ + "QueryScope", + "ScopeType", + "AnalysisContext", + "BaseAnalysisWidget", + "Dimensionality", + "WidgetRegistry", +] diff --git a/collab_env/dashboard/widgets/analysis_context.py b/collab_env/dashboard/widgets/analysis_context.py new file mode 100644 index 00000000..8ebcb665 --- /dev/null +++ b/collab_env/dashboard/widgets/analysis_context.py @@ -0,0 +1,113 @@ +""" +Analysis context for sharing state across widgets. + +Provides shared query backend, scope, parameters, and status callbacks. +""" + +from dataclasses import dataclass +from typing import Callable, Optional, Dict, Any + +from collab_env.data.db.query_backend import QueryBackend +from .query_scope import QueryScope + + +@dataclass +class AnalysisContext: + """ + Shared context passed to all analysis widgets. + + Provides access to: + - Query backend for data access + - Query scope (what data to analyze) + - Shared analysis parameters (bin sizes, thresholds, etc.) + - Status callback hooks for UI updates + + Widgets access this context to query data and report status. + + Examples + -------- + >>> context = AnalysisContext( + ... query_backend=backend, + ... scope=QueryScope.from_episode("ep_123"), + ... spatial_bin_size=10.0, + ... on_loading=lambda msg: print(f"Loading: {msg}") + ... ) + >>> params = context.get_query_params() + >>> df = context.query_backend.get_spatial_heatmap(**params) + """ + + # Core components + query_backend: QueryBackend + scope: QueryScope + + # Shared analysis parameters (commonly used across widgets) + spatial_bin_size: float = 10.0 # For spatial discretization + temporal_window_size: int = 10 # For time-windowed analyses + + # Additional shared parameters + min_samples: int = ( + 100 # Minimum samples for statistics (matches QueryBackend default) + ) + confidence_level: float = 0.95 # For confidence intervals + + # Callback hooks for status updates (optional) + on_loading: Optional[Callable[[str], None]] = None + on_success: Optional[Callable[[str], None]] = None + on_error: Optional[Callable[[str], None]] = None + + def get_query_params(self, **extra_params) -> Dict[str, Any]: + """ + Get combined query parameters from scope + shared params + extras. + + Merges: + 1. Scope parameters (episode_id, time range, agent filters) + 2. Shared analysis parameters (bin sizes, thresholds) + 3. Widget-specific overrides (passed as kwargs) + + Parameters + ---------- + **extra_params + Additional widget-specific parameters to merge + + Returns + ------- + dict + Complete set of query parameters + + Examples + -------- + >>> # Widget uses shared params + >>> params = context.get_query_params() + >>> df = backend.get_spatial_heatmap(**params) + + >>> # Widget overrides specific param + >>> params = context.get_query_params(bin_size=5.0) + >>> df = backend.get_spatial_heatmap(**params) + """ + # Start with scope parameters + params = self.scope.to_query_params() + + # Add shared analysis parameters + params["bin_size"] = self.spatial_bin_size + params["window_size"] = self.temporal_window_size + params["min_samples"] = self.min_samples + + # Widget-specific overrides + params.update(extra_params) + + return params + + def report_loading(self, message: str): + """Report loading status via callback.""" + if self.on_loading: + self.on_loading(message) + + def report_success(self, message: str): + """Report success status via callback.""" + if self.on_success: + self.on_success(message) + + def report_error(self, message: str): + """Report error status via callback.""" + if self.on_error: + self.on_error(message) diff --git a/collab_env/dashboard/widgets/base_analysis_widget.py b/collab_env/dashboard/widgets/base_analysis_widget.py new file mode 100644 index 00000000..f7711294 --- /dev/null +++ b/collab_env/dashboard/widgets/base_analysis_widget.py @@ -0,0 +1,495 @@ +""" +Base class for analysis widgets. + +Provides common infrastructure for widget lifecycle, error handling, +and interaction with the analysis context. +""" + +import json +from enum import IntEnum +from html import escape +from typing import Optional +import logging + +import numpy as np +import param +import panel as pn +import pandas as pd + +from .analysis_context import AnalysisContext +from .query_scope import ScopeType + +logger = logging.getLogger(__name__) + +# Threshold for detecting constant columns (near-zero variance) +_CONSTANT_STD_THRESHOLD = 1e-10 + + +class Dimensionality(IntEnum): + """Spatial dimensionality of loaded movement data.""" + + ONE_D = 1 + TWO_D = 2 + THREE_D = 3 + + +class BaseAnalysisWidget(param.Parameterized): + """ + Abstract base class for analysis widgets. + + Subclasses must implement: + - create_custom_controls(): Widget-specific parameter controls + - create_display_pane(): Visualization pane + - load_data(): Query and visualization logic + + The base class provides: + - Load button with error handling + - Context validation + - Helper method for querying with context + - Tab content layout + + Examples + -------- + >>> class MyWidget(BaseAnalysisWidget): + ... widget_name = "My Analysis" + ... widget_category = "custom" + ... + ... threshold = param.Number(default=0.5) + ... + ... def create_custom_controls(self): + ... return pn.Column( + ... pn.widgets.FloatSlider.from_param(self.param.threshold) + ... ) + ... + ... def create_display_pane(self): + ... return pn.pane.HoloViews(hv.Curve([])) + ... + ... def load_data(self): + ... df = self.query_with_context('get_my_data') + ... self.display_pane.object = hv.Curve(df) + """ + + # Metadata (subclasses should override) + # Note: Using widget_name instead of name to avoid conflict with param.Parameterized.name + widget_name: str = "" # Display name for tab + widget_description: str = "" # Widget description + widget_category: str = "general" # For grouping/filtering + + # Shared context (injected by main GUI) + context: Optional[AnalysisContext] = param.Parameter(default=None) + + def __init__(self, **params): + super().__init__(**params) + self._load_total_rows = 0 + self._load_agents = set() + self._create_ui() + + # ========== Abstract methods (must implement) ========== + + def create_custom_controls(self) -> Optional[pn.Column]: + """ + Create widget-specific parameter controls. + + These are controls that are NOT in the shared context. + Return None if no custom controls needed. + + Returns + ------- + pn.Column or None + Column of custom controls, or None + + Examples + -------- + >>> def create_custom_controls(self): + ... return pn.Column( + ... "### Custom Parameters", + ... pn.widgets.Select.from_param(self.param.color_scale), + ... pn.widgets.Checkbox.from_param(self.param.show_grid) + ... ) + """ + raise NotImplementedError("Subclasses must implement create_custom_controls()") + + def create_display_pane(self) -> pn.pane.PaneBase: + """ + Create the visualization pane (empty state). + + Returns the pane that will be updated by load_data(). + + Returns + ------- + pn.pane.PaneBase + Empty visualization pane + + Examples + -------- + >>> def create_display_pane(self): + ... return pn.pane.HoloViews( + ... hv.Curve([]).opts(width=700, height=500), + ... sizing_mode="stretch_both" + ... ) + """ + raise NotImplementedError("Subclasses must implement create_display_pane()") + + def load_data(self) -> None: + """ + Query data using self.context and update visualization. + + Access shared parameters via: + - self.context.scope (QueryScope) + - self.context.spatial_bin_size + - self.context.temporal_window_size + - etc. + + Access widget-specific parameters via self attributes. + + Should update self.display_pane.object with new visualization. + + Raises + ------ + ValueError + If no data found or invalid parameters + + Examples + -------- + >>> def load_data(self): + ... # Query using shared context parameters + ... df = self.query_with_context('get_spatial_heatmap') + ... + ... if len(df) == 0: + ... raise ValueError("No data found") + ... + ... # Create visualization + ... scatter = hv.Scatter3D(df, kdims=['x', 'y', 'z'], vdims='density') + ... self.display_pane.object = scatter + """ + raise NotImplementedError("Subclasses must implement load_data()") + + # ========== Concrete methods (provided by base) ========== + + def _create_ui(self): + """Create UI components (called by __init__).""" + # Scope display (shows current session/episode) + self.scope_display = pn.pane.Markdown( + "**No data loaded**", + sizing_mode="stretch_width", + styles={"background": "#f0f0f0", "padding": "10px", "border-radius": "5px"}, + ) + + # Info button for config/metadata popup + self.info_btn = pn.widgets.Button( + name="Info", button_type="light", width=70, height=35 + ) + self.info_btn.on_click(self._toggle_info_popup) + + # Info popup (hidden by default) + self._info_content = pn.pane.HTML("", sizing_mode="stretch_width") + self._info_close_btn = pn.widgets.Button( + name="Close", button_type="light", width=70 + ) + self._info_close_btn.on_click(lambda e: self._hide_info_popup()) + + self.info_popup = pn.Column( + pn.Row( + pn.pane.Markdown("### Session & Episode Info"), + self._info_close_btn, + sizing_mode="stretch_width", + ), + self._info_content, + visible=False, + sizing_mode="stretch_width", + styles={ + "background": "white", + "border": "2px solid #2596be", + "border-radius": "8px", + "padding": "15px", + "box-shadow": "0 4px 12px rgba(0, 0, 0, 0.15)", + "margin": "10px 0", + }, + ) + + # Load button (standard for all widgets) + self.load_btn = pn.widgets.Button( + name=f"Load {self.widget_name}", button_type="primary", width=200 + ) + self.load_btn.on_click(self._on_load_click) + + # Display pane (subclass creates) + self.display_pane = self.create_display_pane() + + # Custom controls (subclass creates) + self.custom_controls = self.create_custom_controls() + + def _on_load_click(self, event): + """Handle load button click (with error handling).""" + if not self._validate_context(): + return + + try: + self.context.report_loading(f"Loading {self.widget_name}...") + + # Reset counters before load (tracked by query_with_context) + self._load_total_rows = 0 + self._load_agents = set() + + self.load_data() + + # Update scope display after successful load + self._update_scope_display() + + self.context.report_success(f"{self.widget_name} loaded successfully") + + except Exception as e: + logger.error(f"Failed to load {self.widget_name}: {e}", exc_info=True) + self.context.report_error(f"Failed to load {self.widget_name}: {e}") + + def _validate_context(self) -> bool: + """ + Validate that context has required data scope. + + Returns + ------- + bool + True if context is valid, False otherwise + """ + if not self.context: + logger.error("No context set") + return False + + scope = self.context.scope + + if scope.scope_type == ScopeType.EPISODE and not scope.episode_id: + self.context.report_error("Please select an episode first") + return False + + if scope.scope_type == ScopeType.SESSION and not scope.session_id: + self.context.report_error("Please select a session first") + return False + + return True + + def _update_scope_display(self): + """Update the scope display with current session/episode information.""" + if self.context and self.context.scope: + scope = self.context.scope + scope_str = str(scope) + + # Use counts tracked during load_data via query_with_context + num_rows = getattr(self, "_load_total_rows", 0) + num_agents = len(getattr(self, "_load_agents", set())) + if num_rows > 0: + scope_str += f" | {num_agents} agents, {num_rows:,} data points" + + self.scope_display.object = f"**Current Scope:** {scope_str}" + else: + self.scope_display.object = "**No data loaded**" + + def get_tab_content(self) -> pn.Column: + """ + Return complete tab content (controls + display). + + Layout: + - Scope display with info button (current session/episode) + - Info popup (hidden by default) + - Load button + - Custom controls (if any) + - Display pane + + Returns + ------- + pn.Column + Complete widget content for tab + """ + scope_row = pn.Row( + self.scope_display, + self.info_btn, + sizing_mode="stretch_width", + align="center", + ) + components = [scope_row, self.info_popup, self.load_btn] + + if self.custom_controls: + components.append(pn.layout.Divider()) + components.append(self.custom_controls) + + components.append(self.display_pane) + + return pn.Column(*components, sizing_mode="stretch_both") + + # ========== Info popup methods ========== + + def _toggle_info_popup(self, event=None): + """Toggle the config/metadata info popup.""" + if self.info_popup.visible: + self._hide_info_popup() + else: + self._show_info_popup() + + def _show_info_popup(self): + """Show popup with session config and metadata JSONs.""" + if not self.context or not self.context.scope: + return + + scope = self.context.scope + config_json = "" + metadata_json = "" + + try: + if scope.scope_type == ScopeType.EPISODE and scope.episode_id: + meta_df = self.context.query_backend.get_episode_metadata( + scope.episode_id + ) + if len(meta_df) > 0: + row = meta_df.iloc[0] + config_data = row.get("config", {}) + if isinstance(config_data, str): + config_data = json.loads(config_data) + config_json = json.dumps(config_data, indent=2, default=str) + + metadata = { + k: row.get(k) + for k in [ + "episode_id", + "session_id", + "session_name", + "category_id", + "episode_number", + "num_frames", + "num_agents", + "frame_rate", + "file_path", + ] + } + metadata_json = json.dumps(metadata, indent=2, default=str) + + elif scope.scope_type == ScopeType.SESSION and scope.session_id: + sessions_df = self.context.query_backend.get_sessions() + session_row = sessions_df[sessions_df["session_id"] == scope.session_id] + if len(session_row) > 0: + row = session_row.iloc[0] + config_data = row.get("config", {}) + if isinstance(config_data, str): + config_data = json.loads(config_data) + config_json = json.dumps(config_data, indent=2, default=str) + + metadata = { + k: row.get(k) + for k in [ + "session_id", + "session_name", + "category_id", + "created_at", + ] + } + metadata_json = json.dumps(metadata, indent=2, default=str) + + # Also include episode summary + episodes_df = self.context.query_backend.get_episodes(scope.session_id) + if len(episodes_df) > 0: + episodes_summary = episodes_df[ + ["episode_id", "episode_number", "num_frames", "num_agents"] + ].to_dict("records") + base = json.loads(metadata_json) if metadata_json else {} + base["episodes"] = episodes_summary + metadata_json = json.dumps(base, indent=2, default=str) + + except Exception as e: + logger.warning(f"Failed to load info: {e}") + config_json = config_json or f"Error: {e}" + metadata_json = metadata_json or f"Error: {e}" + + pre_style = ( + "background: #f8f8f8; padding: 10px; border-radius: 4px; " + "overflow-x: auto; max-height: 400px; overflow-y: auto; " + "font-size: 12px; white-space: pre-wrap; word-break: break-word;" + ) + html = ( + f"
" + f"

Config

" + f"
{escape(config_json)}
" + f"

Metadata

" + f"
{escape(metadata_json)}
" + f"
" + ) + self._info_content.object = html + self.info_popup.visible = True + + def _hide_info_popup(self): + """Hide the config/metadata info popup.""" + self.info_popup.visible = False + + # ========== Helper methods ========== + + @staticmethod + def detect_dimensionality(df: pd.DataFrame) -> Dimensionality: + """Detect spatial dimensionality from a DataFrame with x, y, z columns. + + Detection logic: + - 1D: y column missing, all NULL, or constant (near-zero std) + - 2D: y varies; z column missing, all NULL, or constant + - 3D: both y and z vary + """ + + def _has_variance(col_name: str) -> bool: + if col_name not in df.columns: + return False + series = pd.to_numeric(df[col_name], errors="coerce") + if series.isna().all(): + return False + return float(np.nanstd(series.values)) > _CONSTANT_STD_THRESHOLD + + if not _has_variance("y"): + return Dimensionality.ONE_D + if not _has_variance("z"): + return Dimensionality.TWO_D + return Dimensionality.THREE_D + + def query_with_context(self, query_method: str, **extra_params) -> pd.DataFrame: + """ + Helper to query backend with merged parameters. + + Supports both episode-level and session-level queries. + Session aggregation is handled at the SQL level in QueryBackend. + + Merges context parameters (scope + shared) with widget-specific + parameters and calls the specified query method. + + Parameters + ---------- + query_method : str + Name of QueryBackend method to call + **extra_params + Widget-specific parameters to add/override + + Returns + ------- + pd.DataFrame + Query results + + Examples + -------- + >>> # Use shared parameters only + >>> df = self.query_with_context('get_spatial_heatmap') + + >>> # Override specific parameter + >>> df = self.query_with_context( + ... 'get_spatial_heatmap', + ... bin_size=5.0 # Override shared bin size + ... ) + + >>> # Add widget-specific parameter + >>> df = self.query_with_context( + ... 'get_velocity_correlations', + ... method=self.correlation_method + ... ) + """ + assert self.context is not None + query_fn = getattr(self.context.query_backend, query_method) + params = self.context.get_query_params(**extra_params) + result = query_fn(**params) + + # Track loaded data counts + self._load_total_rows += len(result) + if "agent_id" in result.columns: + self._load_agents.update(result["agent_id"].unique()) + + return result diff --git a/collab_env/dashboard/widgets/basic_data_viewer_widget.py b/collab_env/dashboard/widgets/basic_data_viewer_widget.py new file mode 100644 index 00000000..8592d1be --- /dev/null +++ b/collab_env/dashboard/widgets/basic_data_viewer_widget.py @@ -0,0 +1,772 @@ +""" +Basic Data Viewer widget - episode visualization with animation and heatmap. + +Provides a 2-panel synchronized view combining: +- Animation panel: Animated 2D/3D scatter plot of agent tracks with trails +- Spatial heatmap panel: Density heatmap of agent positions + +Both panels are synchronized by time window and current time. +""" + +import logging +import json +from typing import Any, Optional + +import param +import panel as pn +import numpy as np +import holoviews as hv +from bokeh.palettes import Category20_20 + +from collab_env.data.file_utils import get_project_root +from .base_analysis_widget import BaseAnalysisWidget, Dimensionality +from .query_scope import ScopeType + +logger = logging.getLogger(__name__) + +# Initialize HoloViews extension (plotly for 3D support, bokeh for 2D) +hv.extension("plotly", "bokeh") + + +class BasicDataViewerWidget(BaseAnalysisWidget): + """ + Data viewer with animation (episode only) and spatial heatmap (episode or session). + + Features: + - Animation of agent tracks with configurable playback and trails (episode scope only) + - 2D/3D spatial density heatmap with configurable colormap (episode or session scope) + - Synchronized time control across both panels + + Scope Support: + - Episode scope: Both animation and heatmap available + - Session scope: Only heatmap available (aggregated across all episodes) + """ + + widget_name = "Basic Data Viewer" + widget_description = "Animated agent tracks (episode) and spatial density heatmap (episode or session)" + widget_category = "visualization" + + # Playback controls + current_time = param.Integer( + default=0, bounds=(0, None), doc="Current playback time index" + ) + playback_speed = param.Number( + default=1.0, bounds=(0.1, 10.0), doc="Default playback speed for modal viewer" + ) + trail_length = param.Integer( + default=50, bounds=(0, 500), doc="Number of frames to show in trail" + ) + + # Visualization options + show_agent_ids = param.Boolean(default=True, doc="Show agent ID labels") + color_scale = param.Selector( + default="viridis", + objects=["viridis", "plasma", "inferno", "magma", "cividis"], + doc="Color scale for heatmap", + ) + + def __init__(self, **params): + # Initialize data storage + self.tracks_df = None + + # UI components (will be created in _create_ui) + self.animation_pane = None + self.heatmap_pane = None + self.play_button = None + + # Data dimensionality (detected from loaded data) + self.dimensionality = Dimensionality.THREE_D # Updated on data load + + # Spatial bounds and color map (set during load_data) + self.x_range: tuple[float, float] = (0.0, 1.0) + self.y_range: tuple[float, float] = (0.0, 1.0) + self.z_range: Optional[tuple[float, float]] = None + self.agent_color_map: Optional[dict[Any, str]] = None + + # Animation modal - will hold the HTML overlay when shown + self.animation_modal_pane = pn.Column(sizing_mode="stretch_both") + + super().__init__(**params) + + def create_custom_controls(self) -> Optional[pn.Column]: + """Create playback controls and visualization options.""" + + # Playback controls + self.play_button = pn.widgets.Button( + name="▶ Play", button_type="success", width=80 + ) + self.play_button.on_click(self._toggle_playback) + + speed_slider = pn.widgets.FloatSlider.from_param( + self.param.playback_speed, name="Speed", width=150 + ) + + time_slider = pn.widgets.IntSlider.from_param( + self.param.current_time, name="Time", width=300 + ) + + trail_slider = pn.widgets.IntSlider.from_param( + self.param.trail_length, name="Trail", width=150 + ) + + show_ids_checkbox = pn.widgets.Checkbox.from_param( + self.param.show_agent_ids, name="IDs", width=60 + ) + + color_select = pn.widgets.Select.from_param( + self.param.color_scale, name="Colormap", width=150 + ) + + # Compact single-row layout + return pn.Column( + pn.Row( + self.play_button, + speed_slider, + time_slider, + trail_slider, + show_ids_checkbox, + color_select, + sizing_mode="stretch_width", + ), + sizing_mode="stretch_width", + ) + + def create_display_pane(self) -> pn.pane.PaneBase: + """Create 2-panel layout for animation and heatmap.""" + + # Create persistent panes that we'll update via .object property + # This avoids recreating widgets every frame (much more efficient) + self.animation_viz_pane = pn.pane.HoloViews( + sizing_mode="stretch_both", min_height=500 + ) + + self.heatmap_viz_pane = pn.pane.HoloViews( + sizing_mode="stretch_both", min_height=500 + ) + + # Wrap in columns with loading messages + self.animation_pane = pn.Column( + pn.pane.Markdown( + "**Animation Panel**\n\nClick 'Load Basic Data Viewer' to load data." + ), + self.animation_viz_pane, + sizing_mode="stretch_both", + ) + + self.heatmap_pane = pn.Column( + pn.pane.Markdown( + "**Spatial Heatmap Panel**\n\nClick 'Load Basic Data Viewer' to load data." + ), + self.heatmap_viz_pane, + sizing_mode="stretch_both", + ) + + # Layout: side-by-side panels + return pn.Row( + self.animation_pane, self.heatmap_pane, sizing_mode="stretch_both" + ) + + def _detect_dimensionality(self): + """Detect if loaded data is 1D, 2D, or 3D based on coordinate variance.""" + if self.tracks_df is None or len(self.tracks_df) == 0: + self.dimensionality = Dimensionality.THREE_D + return + self.dimensionality = self.detect_dimensionality(self.tracks_df) + + def load_data(self) -> None: + """Load data for animation and heatmap panels. + + Animation is only available for episode scope. + Heatmap is available for both episode and session scope. + """ + assert self.context is not None + scope_type = self.context.scope.scope_type + scope_label = "episode" if scope_type == ScopeType.EPISODE else "session" + logger.info(f"Loading Basic Data Viewer for {scope_label} scope") + + if scope_type == ScopeType.EPISODE: + # Episode scope: Load tracks for animation + heatmap + logger.info("Loading episode tracks for animation and heatmap...") + self.tracks_df = self.query_with_context("get_episode_tracks") + + if len(self.tracks_df) == 0: + raise ValueError("No track data found for selected episode") + + # Validate required columns exist and have valid data + required_cols = ["time_index", "agent_id", "x"] + for col in required_cols: + if col not in self.tracks_df.columns: + raise ValueError(f"Missing required column '{col}' in track data") + if self.tracks_df[col].isna().all(): + raise ValueError(f"Column '{col}' contains only NULL values") + + # Detect if data is 1D, 2D, or 3D + self._detect_dimensionality() + + # Compute and store fixed spatial bounds for consistent axis limits + self.x_range = ( + float(self.tracks_df["x"].min()), + float(self.tracks_df["x"].max()), + ) + if self.dimensionality >= Dimensionality.TWO_D: + self.y_range = ( + float(self.tracks_df["y"].min()), + float(self.tracks_df["y"].max()), + ) + else: + self.y_range = (-0.5, 0.5) + if self.dimensionality == Dimensionality.THREE_D: + self.z_range = ( + float(self.tracks_df["z"].min()), + float(self.tracks_df["z"].max()), + ) + else: + self.z_range = None + + # Create color mapping for agent IDs (consistent colors across all frames) + unique_agents = sorted(self.tracks_df["agent_id"].unique()) + self.agent_color_map = { + agent_id: Category20_20[i % len(Category20_20)] + for i, agent_id in enumerate(unique_agents) + } + + logger.info( + f"Loaded {len(self.tracks_df)} track observations for {self.tracks_df['agent_id'].nunique()} agents" + ) + dim_label = {1: "1D", 2: "2D", 3: "3D"}[self.dimensionality] + logger.info(f"Data dimensionality: {dim_label}") + logger.info( + f"Spatial bounds - X: {self.x_range}" + + ( + f", Y: {self.y_range}" + if self.dimensionality >= Dimensionality.TWO_D + else "" + ) + + ( + f", Z: {self.z_range}" + if self.dimensionality == Dimensionality.THREE_D + else "" + ) + ) + + # Update time slider bounds based on data + min_time = int(self.tracks_df["time_index"].min()) + max_time = int(self.tracks_df["time_index"].max()) + self.param.current_time.bounds = (min_time, max_time) + self.current_time = min_time + + logger.info(f"Time range: {min_time} to {max_time}") + + # Convert placeholder panes to proper visualization panes + self._init_visualization_panes() + + # Restore animation pane structure (in case it was replaced by session scope) + self.animation_pane.objects = [ + pn.pane.Markdown("**Animation Panel**"), + self.animation_viz_pane, + ] + + # Update both panels + self._update_animation_panel() + self._update_heatmap_panel() + + logger.info("Basic Data Viewer loaded successfully (episode scope)") + + else: + # Session scope: Only heatmap available (no animation tracks) + logger.info("Loading session scope heatmap (animation not available)") + + # Clear track data (not available for session) + self.tracks_df = None + self.agent_color_map = None + + # Load heatmap data to determine spatial bounds and dimensionality + heatmap_df = self.query_with_context("get_spatial_heatmap") + + if len(heatmap_df) == 0: + raise ValueError("No heatmap data found for selected session") + + # Detect dimensionality from heatmap bin variance + self.dimensionality = self.detect_dimensionality( + heatmap_df.rename(columns={"x_bin": "x", "y_bin": "y", "z_bin": "z"}) + ) + + # Compute spatial bounds from heatmap bins + bin_size = self.context.spatial_bin_size + self.x_range = ( + float(heatmap_df["x_bin"].min()), + float(heatmap_df["x_bin"].max() + bin_size), + ) + if self.dimensionality >= Dimensionality.TWO_D: + self.y_range = ( + float(heatmap_df["y_bin"].min()), + float(heatmap_df["y_bin"].max() + bin_size), + ) + else: + self.y_range = (-0.5, 0.5) + + if self.dimensionality == Dimensionality.THREE_D: + self.z_range = ( + float(heatmap_df["z_bin"].min()), + float(heatmap_df["z_bin"].max() + bin_size), + ) + else: + self.z_range = None + + dim_label = {1: "1D", 2: "2D", 3: "3D"}[self.dimensionality] + logger.info(f"Detected {dim_label} data for session heatmap") + + # Convert placeholder panes to proper visualization panes + self._init_visualization_panes() + + # Update animation panel to show "not available" message + self.animation_pane.objects = [ + pn.pane.Markdown( + "**Animation Panel**\n\n" + "_Animation is only available for episode-level analysis._\n\n" + "Switch to 'Episode' scope to view animated agent tracks.", + styles={"color": "#666", "font-style": "italic"}, + ) + ] + + # Restore heatmap pane structure + self.heatmap_pane.objects = [ + pn.pane.Markdown("**Spatial Heatmap Panel**"), + self.heatmap_viz_pane, + ] + + # Update heatmap panel + self._update_heatmap_panel() + + logger.info( + "Basic Data Viewer loaded successfully (session scope - heatmap only)" + ) + + def get_animation_data_json(self): + """Return JSON-serializable animation data for client-side rendering. + + This method prepares all data needed for the client-side viewer. + No HTTP requests needed - data is embedded directly in the modal HTML. + """ + if self.tracks_df is None: + return {} + + # Convert agent_color_map keys to native Python int (from numpy.int64) + agent_colors_serializable = { + int(agent_id): color for agent_id, color in self.agent_color_map.items() + } + + return { + "tracks": self.tracks_df.to_dict("records"), # List of all track points + "settings": { + "trail_length": int(self.trail_length), + "show_agent_ids": bool(self.show_agent_ids), + "playback_speed": float(self.playback_speed), + }, + "bounds": { + "x_range": [float(self.x_range[0]), float(self.x_range[1])], + "y_range": [float(self.y_range[0]), float(self.y_range[1])], + "z_range": [float(self.z_range[0]), float(self.z_range[1])] + if self.z_range + else None, + }, + "is_3d": self.dimensionality == Dimensionality.THREE_D, + "dimensionality": int(self.dimensionality), + "agent_colors": agent_colors_serializable, + "time_range": [ + int(self.tracks_df["time_index"].min()), + int(self.tracks_df["time_index"].max()), + ], + } + + def _init_visualization_panes(self): + """Remove loading messages, keep visualization panes.""" + # Remove loading markdown messages (first element in each Column) + # The viz panes are persistent and will be updated via .object property + if len(self.animation_pane.objects) > 1: + self.animation_pane.pop(0) # Remove markdown + if len(self.heatmap_pane.objects) > 1: + self.heatmap_pane.pop(0) + + def _update_animation_panel(self): + """Update animation panel with current time and trails.""" + if self.tracks_df is None or len(self.tracks_df) == 0: + return + + # Filter to current time window (current_time - trail_length to current_time) + start_time = max( + self.current_time - self.trail_length, self.tracks_df["time_index"].min() + ) + end_time = self.current_time + + window_df = self.tracks_df[ + (self.tracks_df["time_index"] >= start_time) + & (self.tracks_df["time_index"] <= end_time) + ] + + if len(window_df) == 0: + # Set to None to show empty state + self.animation_viz_pane.object = None + return + + # Create scatter plot with trails (2D or 3D based on data) + # Current positions (at current_time) + current_df = window_df[window_df["time_index"] == self.current_time] + + if self.dimensionality == Dimensionality.THREE_D: + # 3D visualization + if len(current_df) > 0: + # For 3D Plotly plots, map agent IDs to actual color hex values + current_df = current_df.copy() + current_df["agent_color"] = current_df["agent_id"].map( + self.agent_color_map + ) + + scatter = hv.Scatter3D( + current_df, + kdims=["x", "y", "z"], + vdims=["agent_id", "agent_color", "speed"], + ).opts( + color="agent_color", + size=5, + width=450, + height=450, + title=f"Agent Positions (t={self.current_time})", + colorbar=False, + xlim=self.x_range, + ylim=self.y_range, + zlim=self.z_range, + ) + else: + scatter = hv.Scatter3D([]).opts( + width=450, + height=450, + title="Animation", + xlim=self.x_range, + ylim=self.y_range, + zlim=self.z_range, + ) + + # Add trails if trail_length > 0 + if self.trail_length > 0 and len(window_df) > 0: + paths = [] + for agent_id in window_df["agent_id"].unique(): + agent_trail = window_df[ + window_df["agent_id"] == agent_id + ].sort_values("time_index") + if len(agent_trail) > 1: + # Ensure continuous trail (no gaps/jumps in time) + # Only include consecutive time points to avoid "looping back" + time_indices = agent_trail["time_index"].values + continuous_mask = np.ones(len(time_indices), dtype=bool) + continuous_mask[1:] = np.diff(time_indices) == 1 + + # Find continuous segments + segment_starts = np.where(~continuous_mask)[0] + if len(segment_starts) > 0: + # Only use the most recent continuous segment + last_break = segment_starts[-1] + agent_trail = agent_trail.iloc[last_break:] + + if len(agent_trail) > 1: + agent_color = self.agent_color_map.get(agent_id, "gray") + path = hv.Path3D(agent_trail, kdims=["x", "y", "z"]).opts( + color=agent_color, line_width=2 + ) + paths.append(path) + + if paths: + trails = hv.Overlay(paths) + scatter = trails * scatter + else: + # 2D visualization (use PLOTLY backend for consistency) + if len(current_df) > 0: + # Map agent IDs to actual color hex values (same as 3D approach) + current_df = current_df.copy() + current_df["agent_color"] = current_df["agent_id"].map( + self.agent_color_map + ) + + scatter = hv.Scatter( + current_df, + kdims=["x", "y"], + vdims=["agent_id", "agent_color", "speed"], + ).opts( + color="agent_color", + size=8, + # width=450, + # height=450, + title=f"Agent Positions (t={self.current_time})", + colorbar=False, + xlim=self.x_range, + ylim=self.y_range, + ) + else: + scatter = hv.Scatter([]).opts( + # width=450, + # height=450, + title="Animation", + xlim=self.x_range, + ylim=self.y_range, + ) + + # Add trails if trail_length > 0 + if self.trail_length > 0 and len(window_df) > 0: + paths = [] + for agent_id in window_df["agent_id"].unique(): + agent_trail = window_df[ + window_df["agent_id"] == agent_id + ].sort_values("time_index") + if len(agent_trail) > 1: + # Ensure continuous trail (no gaps/jumps in time) + # Only include consecutive time points to avoid "looping back" + time_indices = agent_trail["time_index"].values + continuous_mask = np.ones(len(time_indices), dtype=bool) + continuous_mask[1:] = np.diff(time_indices) == 1 + + # Find continuous segments + segment_starts = np.where(~continuous_mask)[0] + if len(segment_starts) > 0: + # Only use the most recent continuous segment + last_break = segment_starts[-1] + agent_trail = agent_trail.iloc[last_break:] + + if len(agent_trail) > 1: + agent_color = self.agent_color_map.get(agent_id, "gray") + path = hv.Path(agent_trail, kdims=["x", "y"]).opts( + color=agent_color, line_width=2 + ) + paths.append(path) + + if paths: + trails = hv.Overlay(paths) + scatter = trails * scatter + + # Update pane content (efficient - just updates object, doesn't recreate widget) + self.animation_viz_pane.object = scatter + + def _update_heatmap_panel(self): + """Update spatial heatmap panel.""" + # Query spatial heatmap using shared context + df = self.query_with_context("get_spatial_heatmap") + + if len(df) == 0: + self.heatmap_viz_pane.object = None + return + + # Convert bin lower bounds to bin centers + # Note: x_bin, y_bin, z_bin from the SQL query are already coordinates (lower bounds), + # not indices. The query does: floor(x / bin_size) * bin_size + # So x_bin is the left edge of the bin, and we just add half the bin size for center + bin_size = self.context.spatial_bin_size + df = df.copy() + + # Calculate bin centers from bin lower bounds + df["x_center"] = df["x_bin"] + (bin_size / 2) + + if self.dimensionality == Dimensionality.ONE_D: + # 1D density histogram — aggregate over y/z bins + density_1d = df.groupby("x_center", as_index=False)["density"].sum() + + viz = hv.Bars( + density_1d, + kdims="x_center", + vdims="density", + ).opts( + color="steelblue", + colorbar=False, + title=f"1D Spatial Density (bin={bin_size})", + xlabel="X Position", + ylabel="Density", + xlim=self.x_range, + ) + elif self.dimensionality == Dimensionality.THREE_D: + df["y_center"] = df["y_bin"] + (bin_size / 2) + df["z_center"] = df["z_bin"] + (bin_size / 2) + + # 3D scatter plot with density (PLOTLY) + # Use fixed moderate opacity to help with overlapping points + viz = hv.Scatter3D( + df, kdims=["x_center", "y_center", "z_center"], vdims="density" + ).opts( + color="density", + cmap=self.color_scale, + size=5, + alpha=0.6, + colorbar=True, + title=f"Spatial Density (bin={bin_size})", + xlim=self.x_range, + ylim=self.y_range, + zlim=self.z_range, + ) + else: + df["y_center"] = df["y_bin"] + (bin_size / 2) + # 2D heatmap using Image (PLOTLY for consistency) + # Create a proper 2D grid from the binned data + x_unique = sorted(df["x_center"].unique()) + y_unique = sorted(df["y_center"].unique()) + + # Check if we have enough bins for a proper heatmap + # Need at least 2 unique values in both x and y, and non-zero range + x_range_ok = len(x_unique) >= 2 and (max(x_unique) - min(x_unique)) > 0 + y_range_ok = len(y_unique) >= 2 and (max(y_unique) - min(y_unique)) > 0 + + if not x_range_ok or not y_range_ok: + # Fall back to scatter plot when bin_size is too large for data range + # This typically happens with 3D world coordinates (small values like -1 to 1) + # when using a bin_size designed for pixel coordinates (like 10.0) + logger.warning( + f"Not enough bins for heatmap (x_bins={len(x_unique)}, y_bins={len(y_unique)}). " + f"Consider using a smaller bin_size for this data range. Falling back to scatter plot." + ) + viz = hv.Scatter( + df, kdims=["x_center", "y_center"], vdims="density" + ).opts( + color="density", + cmap=self.color_scale, + size=10, + colorbar=True, + title=f"Spatial Density (bin={bin_size}) - Scatter fallback", + xlim=self.x_range, + ylim=self.y_range, + ) + else: + # Create a 2D array for density values + density_grid = np.zeros((len(y_unique), len(x_unique))) + for _, row in df.iterrows(): + x_idx = x_unique.index(row["x_center"]) + y_idx = y_unique.index(row["y_center"]) + density_grid[y_idx, x_idx] = row["density"] + + # Create Image with proper bounds + # Flip y axis for heatmap (so y goes from max to min, as in image coordinates) + viz = hv.Image( + np.flipud(density_grid), + bounds=( + min(x_unique), + max(y_unique), + max(x_unique), + min(y_unique), + ), # flip y axis + ).opts( + cmap=self.color_scale, + # width=450, + # height=450, + colorbar=True, + title=f"Spatial Density (bin={bin_size})", + xlim=self.x_range, + ylim=self.y_range, + ) + + # Update pane content (efficient - just updates object, doesn't recreate widget) + self.heatmap_viz_pane.object = viz + + def _toggle_playback(self, event): + """Open modal dialog for client-side animation.""" + if self.tracks_df is None: + logger.warning("No track data available for animation") + return + + # Generate animation data from in-memory tracks + animation_data = self.get_animation_data_json() + + # Create and show modal + self._show_animation_modal(animation_data) + + def _show_animation_modal(self, animation_data): + """Create and display full-screen animation modal with client-side playback. + + The modal is injected directly into document.body via JavaScript, creating a + true overlay that works outside of Panel's component tree. All track data is + embedded as JSON in the HTML, enabling smooth 60fps client-side animation + with no server round-trips during playback. + + Features: + - Canvas 2D rendering with requestAnimationFrame for smooth animation + - Playback controls: play/pause, stop, speed (0.1x-10x) + - Keyboard shortcuts: Space (play/pause), Escape (close) + - Dynamic frame indicator and speed slider + - Close button to remove modal from DOM + """ + # Validate data + if not animation_data or not animation_data.get("tracks"): + logger.warning("No track data available for animation") + return + + # Check data size and warn if large + num_points = len(animation_data["tracks"]) + if num_points > 10000: + logger.warning( + f"Large dataset: {num_points} track points - animation may be slow" + ) + + # Serialize data to JSON string for embedding + try: + animation_json = json.dumps(animation_data) + except Exception as e: + logger.error(f"Failed to serialize animation data: {e}") + return + + # Load template from file using project root for robust path resolution + template_path = ( + get_project_root() + / "collab_env" + / "dashboard" + / "templates" + / "animation_modal.html" + ) + try: + template_content = template_path.read_text() + except Exception as e: + logger.error(f"Failed to load animation modal template: {e}") + return + + # Render template with variables + html_content = template_content.format( + animation_json=animation_json, + playback_speed=animation_data["settings"]["playback_speed"], + max_frame=animation_data["time_range"][1], + ) + + # Create HTML pane - let it size naturally + viewer_pane = pn.pane.HTML(html_content, sizing_mode="stretch_both") + + # Add to modal pane (which is part of the widget layout) + self.animation_modal_pane.clear() + self.animation_modal_pane.append(viewer_pane) + + logger.info("Animation modal displayed") + + @param.depends("current_time", watch=True) + def _on_time_change(self): + """Handle current time changes (from slider or playback).""" + if self.tracks_df is not None: + self._update_animation_panel() + + @param.depends("trail_length", watch=True) + def _on_trail_length_change(self): + """Handle trail length changes.""" + if self.tracks_df is not None: + self._update_animation_panel() + + @param.depends("color_scale", watch=True) + def _on_color_scale_change(self): + """Handle color scale changes.""" + if self.tracks_df is not None: + # Force re-render by clearing the object first + self.heatmap_viz_pane.object = None + self._update_heatmap_panel() + + def get_tab_content(self) -> pn.Column: + """ + Override to add modal pane to component tree. + + Modal overlay will be injected here when Play is clicked. + """ + # Get base components from parent class + base_content = super().get_tab_content() + + # Add modal pane to the column (empty by default, filled when Play is clicked) + base_content.append(self.animation_modal_pane) + + return base_content diff --git a/collab_env/dashboard/widgets/correlation_widget.py b/collab_env/dashboard/widgets/correlation_widget.py new file mode 100644 index 00000000..b3c444a6 --- /dev/null +++ b/collab_env/dashboard/widgets/correlation_widget.py @@ -0,0 +1,150 @@ +""" +Velocity correlation widget. + +Displays agent velocity correlations as 3D scatter plot. +""" + +import logging +from typing import Optional + +import param +import panel as pn +import holoviews as hv + +from .base_analysis_widget import BaseAnalysisWidget +from .query_scope import ScopeType + +logger = logging.getLogger(__name__) + + +class CorrelationWidget(BaseAnalysisWidget): + """ + Velocity correlation visualization. + + Displays pairwise agent velocity correlations as 3D scatter: + - X axis: Agent i index + - Y axis: Agent j index + - Z axis: Average correlation magnitude + - Color: Correlation strength + """ + + widget_name = "Correlations" + widget_description = "Agent velocity correlations" + widget_category = "behavioral" + + # Widget-specific parameters + correlation_method = param.Selector( + default="pearson", + objects=["pearson", "spearman", "kendall"], + doc="Correlation method (future use)", + ) + + min_correlation = param.Number( + default=0.0, bounds=(0.0, 1.0), doc="Minimum correlation magnitude to display" + ) + + marker_size = param.Integer( + default=8, bounds=(1, 20), doc="Marker size for scatter points" + ) + + color_map = param.Selector( + default="Viridis", + objects=["Viridis", "Plasma", "Inferno", "Magma", "RdYlBu"], + doc="Color map for correlation values", + ) + + def create_custom_controls(self) -> Optional[pn.Column]: + """Create widget-specific controls for correlation parameters.""" + return pn.Column( + "### Correlation Parameters", + pn.widgets.Select.from_param( + self.param.correlation_method, name="Method", width=200 + ), + pn.widgets.FloatSlider.from_param( + self.param.min_correlation, name="Min Correlation", width=200 + ), + pn.layout.Divider(), + "### Visualization", + pn.widgets.IntSlider.from_param( + self.param.marker_size, name="Marker Size", width=200 + ), + pn.widgets.Select.from_param( + self.param.color_map, name="Color Map", width=200 + ), + ) + + def create_display_pane(self) -> pn.pane.PaneBase: + """Create empty 3D plot pane.""" + return pn.pane.HoloViews( + hv.Curve([]).opts(width=700, height=500), sizing_mode="stretch_both" + ) + + def load_data(self) -> None: + """Load and visualize velocity correlations.""" + assert self.context is not None + # Check if scope is SESSION - correlations only support episode-level + if self.context.scope.scope_type == ScopeType.SESSION: + raise ValueError( + "Session-level correlation is not supported. " + "Correlation analysis is only available for single episodes. " + "Please select an episode scope instead." + ) + + # Query velocity correlations + # min_samples comes from context, but we can override if needed + df = self.query_with_context("get_velocity_correlations") + + logger.info(f"Query returned {len(df)} correlation pairs") + + if len(df) == 0: + raise ValueError( + "No correlation data found. Try adjusting time range or agent type." + ) + + # Calculate average correlation magnitude across available dimensions + corr_cols = [] + for col in ["v_x_correlation", "v_y_correlation", "v_z_correlation"]: + if col in df.columns and df[col].notna().any(): + corr_cols.append(col) + + if not corr_cols: + raise ValueError("No valid velocity correlation data found") + + df["avg_correlation"] = df[corr_cols].abs().mean(axis=1) + + # Filter by minimum correlation threshold + df_filtered = df[df["avg_correlation"] >= self.min_correlation] + + if len(df_filtered) == 0: + raise ValueError( + f"No correlations above threshold {self.min_correlation}. " + f"Total pairs: {len(df)}, max correlation: {df['avg_correlation'].max():.3f}" + ) + + logger.info( + f"Correlation range: {df_filtered['avg_correlation'].min():.3f} to " + f"{df_filtered['avg_correlation'].max():.3f}" + ) + + # Create 3D scatter plot where each point represents an agent pair + # Use agent_i and agent_j as spatial coordinates, correlation as z-axis and color + vdims = [c for c in corr_cols] + ["n_samples"] + scatter = hv.Scatter3D( + df_filtered, + kdims=["agent_i", "agent_j", "avg_correlation"], + vdims=vdims, + ).opts( + color="avg_correlation", + cmap=self.color_map, # Widget-specific parameter + size=self.marker_size, # Widget-specific parameter + width=800, + height=600, + colorbar=True, + title=f"Velocity Correlations (3D: agent_i × agent_j × avg_corr) - {len(df_filtered)} pairs", + zlabel="Average Correlation", + xlim=(df_filtered["agent_i"].min() - 1, df_filtered["agent_i"].max() + 1), + ylim=(df_filtered["agent_j"].min() - 1, df_filtered["agent_j"].max() + 1), + ) + + self.display_pane.object = scatter + logger.info(f"Loaded correlations for {len(df_filtered)} agent pairs") diff --git a/collab_env/dashboard/widgets/distance_widget.py b/collab_env/dashboard/widgets/distance_widget.py new file mode 100644 index 00000000..86831b64 --- /dev/null +++ b/collab_env/dashboard/widgets/distance_widget.py @@ -0,0 +1,219 @@ +""" +Distance statistics widget. + +Displays relative locations (pairwise distances) between agents: +- Histogram of ||x_i - x_j|| for all pairs i Optional[pn.Column]: + """Create widget-specific controls.""" + return pn.Column( + "### Visualization Options", + pn.widgets.IntSlider.from_param( + self.param.bin_count, name="Histogram Bins", width=200 + ), + ) + + def create_display_pane(self) -> pn.pane.PaneBase: + """Create empty plot pane.""" + # Create a placeholder curve (empty data) + placeholder = hv.Curve([]).opts( + width=800, + height=300, + title='Click "Load Data" to display distance statistics', + ) + return pn.pane.HoloViews(placeholder, sizing_mode="stretch_both") + + def load_data(self) -> None: + """Load and visualize relative location statistics.""" + assert self.context is not None + # Validate this is episode scope only + if self.context.scope.scope_type != ScopeType.EPISODE: + raise ValueError( + "Spatial Analysis widget only supports episode-level analysis. " + "Please select an episode scope instead of session scope." + ) + + # Get raw episode tracks (positions for all agents at all times) + df_tracks = self.query_with_context("get_episode_tracks") + + if len(df_tracks) == 0: + raise ValueError("No data found for selected parameters") + + # Compute pairwise distances + rel_dist_data = self._compute_relative_distances(df_tracks) + + if len(rel_dist_data) == 0: + raise ValueError("No pairwise distance data computed") + + # Create histogram + hist = self._create_histogram(rel_dist_data["relative_distance"].values) + + # Create time series with mean ± std + ts = self._create_time_series(rel_dist_data) + + # Arrange plots side by side + layout = (hist + ts).opts(title="Relative Locations (||x_i - x_j||)") + + self.display_pane.object = layout + logger.info( + f"Loaded distance stats with {len(rel_dist_data)} pairwise distances" + ) + + def _to_numeric_array(self, series: pd.Series) -> np.ndarray: + """Convert pandas series to clean numeric array, replacing None/NaN with 0.0.""" + # Convert to numeric (handles None, converts to NaN) + numeric = pd.to_numeric(series, errors="coerce") + # Replace NaN with 0.0 + return numeric.fillna(0.0).values + + def _create_histogram(self, data: np.ndarray) -> hv.Histogram: + """Create histogram of relative distances.""" + frequencies, edges = np.histogram(data, bins=self.bin_count) + hist = hv.Histogram((edges, frequencies)) + hist.opts( + opts.Histogram( + color="darkviolet", + width=400, + height=300, + xlabel="Distance ||x_i - x_j||", + ylabel="Count", + title="Distribution of Pairwise Distances", + ) + ) + return hist + + def _create_time_series(self, df: pd.DataFrame) -> hv.Overlay: + """Create time series with median and IQR (25th-75th percentile) for relative distances.""" + logger.info( + "⭐ USING NEW VERSION: Creating distance time series with Spread element" + ) + assert self.context is not None + window_size = self.context.temporal_window_size + + # Compute windowed statistics (median and quartiles) + df["time_window"] = (df["time_index"] // window_size) * window_size + stats = ( + df.groupby("time_window")["relative_distance"] + .agg( + [ + ("median", "median"), + ("q25", lambda x: x.quantile(0.25)), + ("q75", lambda x: x.quantile(0.75)), + ] + ) + .reset_index() + ) + + # Compute errors for Spread element + stats["neg_err"] = stats["median"] - stats["q25"] + stats["pos_err"] = stats["q75"] - stats["median"] + + # Create median line + curve = hv.Curve( + (stats["time_window"], stats["median"]), + kdims="Time", + vdims="Distance", + label="Median", + ).opts(color="darkviolet", line_width=2) + + # Create IQR spread + spread = hv.Spread( + (stats["time_window"], stats["median"], stats["neg_err"], stats["pos_err"]), + kdims="Time", + vdims=["Distance", "neg_err", "pos_err"], + label="IQR (25th-75th)", + ).opts(color="plum") + + def legend_hook(plot, element): + """Position legend inside plot for plotly backend.""" + fig = plot.state + fig["layout"]["legend"] = dict( + yanchor="top", y=0.98, xanchor="right", x=0.98 + ) + + return (spread * curve).opts( + width=400, + height=300, + title="Pairwise Distance Over Time", + show_legend=True, + hooks=[legend_hook], + ) + + def _compute_relative_distances(self, df_tracks: pd.DataFrame) -> pd.DataFrame: + """ + Compute pairwise distance magnitudes ||x_i - x_j|| for all i color + + # UI components (will be created in _create_ui) + self.timeseries_pane = None + self.histogram_pane = None + + # Two-stage loading UI components + self.load_names_btn = None + self.load_data_btn = None + self.property_selector = None + self.property_status = None + + super().__init__(**params) + + def _create_ui(self): + """Override to hide the base class load button.""" + super()._create_ui() + # Hide the base load button to avoid confusion (we have our own 2-button workflow) + self.load_btn.visible = False + + def create_custom_controls(self) -> Optional[pn.Column]: + """Create property selection controls with two-stage loading.""" + + # === Stage 1: Load Property Names === + self.load_names_btn = pn.widgets.Button( + name="1. Load Property Names", button_type="primary", width=200 + ) + self.load_names_btn.on_click(self._on_load_names_click) + + self.property_status = pn.pane.Markdown( + "_Click 'Load Property Names' to see available properties_", + styles={"color": "#666", "font-style": "italic"}, + ) + + load_names_section = pn.Column( + "### Step 1: Load Property Names", + pn.Row(self.load_names_btn), + self.property_status, + ) + + # === Stage 2: Select and Load Properties === + # Property selection (disabled until names are loaded) + self.property_selector = pn.widgets.CheckBoxGroup.from_param( + self.param.selected_properties, + name="Select Properties to Load", + inline=True, + width=800, + disabled=True, + ) + + self.load_data_btn = pn.widgets.Button( + name="2. Load Selected Properties", + button_type="success", + width=200, + disabled=True, + ) + self.load_data_btn.on_click(self._on_load_data_click) + + property_selection_section = pn.Column( + "### Step 2: Select Properties", + self.property_selector, + pn.Row( + self.load_data_btn, + pn.pane.Markdown( + "_Load only selected properties_", + styles={"color": "#666", "font-style": "italic"}, + ), + ), + pn.pane.Markdown( + "**Note:** Time range filtering is controlled by the Start/End Time fields in the main panel (not widget-specific).", + styles={ + "color": "#666", + "font-size": "0.85em", + "font-style": "italic", + "margin-top": "10px", + }, + ), + ) + + # === Visualization Options === + # Quantile controls + lower_quantile_slider = pn.widgets.FloatSlider.from_param( + self.param.lower_quantile, name="Lower Quantile", width=150, step=0.05 + ) + + upper_quantile_slider = pn.widgets.FloatSlider.from_param( + self.param.upper_quantile, name="Upper Quantile", width=150, step=0.05 + ) + + # Normalize checkbox + normalize_checkbox = pn.widgets.Checkbox.from_param( + self.param.normalize, name="Z-Score Normalize" + ) + + # Raw datapoints controls + show_raw_checkbox = pn.widgets.Checkbox.from_param( + self.param.show_raw_lines, name="Show Agent Lines" + ) + + opacity_slider = pn.widgets.FloatSlider.from_param( + self.param.raw_line_opacity, name="Opacity", width=120 + ) + + marker_size_slider = pn.widgets.IntSlider.from_param( + self.param.raw_marker_size, name="Marker Size", width=120 + ) + + max_agents_slider = pn.widgets.IntSlider.from_param( + self.param.max_agents_to_plot, name="Max Agents", width=120 + ) + + # Distribution plot controls + bin_count_slider = pn.widgets.IntSlider.from_param( + self.param.bin_count, name="Histogram Bins", width=150 + ) + + plot_type_selector = pn.widgets.Select.from_param( + self.param.plot_type, name="Plot Type", width=150 + ) + + viz_options = pn.Column( + "### Visualization Options", + pn.Row( + lower_quantile_slider, + upper_quantile_slider, + normalize_checkbox, + sizing_mode="stretch_width", + ), + pn.Row( + show_raw_checkbox, + opacity_slider, + marker_size_slider, + max_agents_slider, + sizing_mode="stretch_width", + ), + pn.Row(bin_count_slider, plot_type_selector, sizing_mode="stretch_width"), + ) + + # === Complete Layout === + return pn.Column( + load_names_section, + pn.layout.Divider(), + property_selection_section, + pn.layout.Divider(), + viz_options, + sizing_mode="stretch_width", + ) + + def create_display_pane(self) -> pn.pane.PaneBase: + """Create 2-panel layout for time series and histograms.""" + + # Return a Column that we'll update with content after data loads + # This matches the pattern used by velocity_widget + return pn.Column( + pn.pane.Markdown( + '**Extended Properties Viewer**\n\nClick "1. Load Property Names" to begin.' + ), + sizing_mode="stretch_both", + ) + + def _on_load_names_click(self, event): + """Handle Stage 1: Load property names only (no data).""" + if not self._validate_context(): + return + + try: + self.context.report_loading("Loading property names...") + + # Determine scope label + scope_label = ( + "episode" + if self.context.scope.scope_type == ScopeType.EPISODE + else "session" + ) + logger.info(f"Loading available properties for {scope_label}...") + + # Query for available property names + self.available_props_df = self.query_with_context( + "get_available_properties" + ) + + if len(self.available_props_df) == 0: + raise ValueError(f"No extended properties found for this {scope_label}") + + # Update property selector options + prop_list = self.available_props_df["property_id"].tolist() + self.param.selected_properties.objects = prop_list + + # Preserve previous selection if possible + previous_selection = ( + list(self.selected_properties) if self.selected_properties else [] + ) + preserved_selection = [ + prop for prop in previous_selection if prop in prop_list + ] + self.selected_properties = preserved_selection + + # Enable UI controls + self.property_selector.disabled = False + self.load_data_btn.disabled = False + + # Update status + status_msg = f"✓ Found **{len(prop_list)}** properties" + if preserved_selection: + status_msg += f" ({len(preserved_selection)} previously selected)" + status_msg += ". Select properties and click 'Load Selected Properties'." + self.property_status.object = status_msg + + self.context.report_success(f"Loaded {len(prop_list)} property names") + logger.info(f"Property names loaded: {prop_list}") + + except Exception as e: + logger.error(f"Failed to load property names: {e}", exc_info=True) + self.context.report_error(f"Failed to load property names: {e}") + + def _on_load_data_click(self, event): + """Handle Stage 2: Load selected property data.""" + if not self._validate_context(): + return + + # Validate that property names are loaded + if self.available_props_df is None or len(self.available_props_df) == 0: + self.context.report_error("Please load property names first (Step 1)") + return + + # Validate that at least one property is selected + if not self.selected_properties or len(self.selected_properties) == 0: + self.context.report_error("Please select at least one property to load") + return + + try: + self.context.report_loading( + f"Loading {len(self.selected_properties)} selected properties..." + ) + + # Call load_data with selected properties + self.load_data(property_ids=list(self.selected_properties)) + + # Update scope display after successful load + self._update_scope_display() + + self.context.report_success( + f"Loaded {len(self.selected_properties)} properties successfully" + ) + + except Exception as e: + logger.error(f"Failed to load properties: {e}", exc_info=True) + self.context.report_error(f"Failed to load properties: {e}") + + def _reset_loading_state(self): + """Reset UI to initial state (used when scope changes).""" + self.available_props_df = None + self.properties_ts_df = None + self.properties_dist_df = None + self.properties_raw_df = None + self.param.selected_properties.objects = [] + self.selected_properties = [] + + if self.property_selector: + self.property_selector.disabled = True + if self.load_data_btn: + self.load_data_btn.disabled = True + if self.property_status: + self.property_status.object = ( + "_Click 'Load Property Names' to see available properties_" + ) + + # Reset display pane + self.display_pane.objects = [ + pn.pane.Markdown( + '**Extended Properties Viewer**\n\nClick "1. Load Property Names" to begin.' + ) + ] + + def _validate_context(self) -> bool: + """ + Validate that context has required data scope. + + Returns + ------- + bool + True if context is valid, False otherwise + """ + if not self.context: + logger.error("No context set") + return False + + scope = self.context.scope + + if scope.scope_type == ScopeType.EPISODE and not scope.episode_id: + self.context.report_error("Please select an episode first") + return False + + if scope.scope_type == ScopeType.SESSION and not scope.session_id: + self.context.report_error("Please select a session first") + return False + + return True + + def load_data(self, property_ids: Optional[List[str]] = None) -> None: + """ + Load extended properties data for time series and histograms. + + Parameters + ---------- + property_ids : list of str, optional + Specific properties to load. If None, uses selected_properties. + If no properties selected and None, raises error. + """ + assert self.context is not None + # Validate scope type (support both episode and session) + if self.context.scope.scope_type not in [ScopeType.EPISODE, ScopeType.SESSION]: + raise ValueError( + "Extended Properties Viewer only supports episode and session scopes" + ) + + # Use selected properties if not specified + if property_ids is None: + if not self.selected_properties: + raise ValueError( + "No properties selected. Please select properties first, " + "or use 'Load Property Names' to see available options." + ) + property_ids = list(self.selected_properties) + + scope_label = ( + "episode" + if self.context.scope.scope_type == ScopeType.EPISODE + else "session" + ) + logger.info( + f"Loading {len(property_ids)} properties for {scope_label}: {property_ids}" + ) + + # Conditional data loading based on scope + if self.context.scope.scope_type == ScopeType.EPISODE: + # Episode scope: Load time series, distributions, and optionally raw data + logger.info( + f"Loading property time series (quantiles: {self.lower_quantile:.0%} - {self.upper_quantile:.0%})..." + ) + self.properties_ts_df = self.query_with_context( + "get_extended_properties_timeseries", + property_ids=property_ids, # Load ONLY selected properties + lower_quantile=self.lower_quantile, + upper_quantile=self.upper_quantile, + ) + + logger.info("Loading property distributions...") + self.properties_dist_df = self.query_with_context( + "get_property_distributions", + property_ids=property_ids, # Load ONLY selected properties + ) + + # Load raw property data if show_raw_lines is enabled + if self.show_raw_lines: + logger.info("Loading raw property data for agent lines...") + self.properties_raw_df = self.query_with_context( + "get_extended_properties_raw", + property_ids=property_ids, # Load ONLY selected properties + ) + logger.info(f"Loaded {len(self.properties_raw_df)} raw observations") + else: + self.properties_raw_df = None + + # Create both time series and distribution visualizations + timeseries_plot = self._create_timeseries_plot() + histogram_layout = self._create_histogram_layout() + + # Update display pane with both panels + histogram_pane = self._wrap_distribution_pane(histogram_layout) + + self.display_pane.objects = [ + pn.pane.Markdown("## Time Series Panel"), + pn.pane.HoloViews( + timeseries_plot, sizing_mode="stretch_width", height=400 + ), + pn.pane.Markdown("## Distribution Panel"), + histogram_pane, + ] + + else: # SESSION scope + # Session scope: Load only distributions (aggregated across all episodes in session) + # Use time range from context.scope (shared with main UI) + start_time = self.context.scope.start_time + end_time = self.context.scope.end_time + + time_filter_msg = "" + if start_time is not None or end_time is not None: + time_filter_msg = f" (time range: {start_time or 0}-{end_time or '∞'})" + logger.info( + f"Loading property distributions (session-level aggregation{time_filter_msg})..." + ) + + self.properties_ts_df = None + self.properties_raw_df = None + self.properties_dist_df = self.query_with_context( + "get_property_distributions", + property_ids=property_ids, # Load ONLY selected properties + # start_time and end_time automatically passed via query_with_context from scope + ) + + # Create only distribution visualization + histogram_layout = self._create_histogram_layout() + + # Update display pane with single panel + histogram_pane = self._wrap_distribution_pane(histogram_layout) + + session_header = "## Distribution Panel (Session-Level Aggregation)" + if time_filter_msg: + session_header += f"\n_Filtered{time_filter_msg}_" + + self.display_pane.objects = [ + pn.pane.Markdown(session_header), + pn.pane.Markdown( + "_Time series plots are not available for session-level analysis_" + ), + histogram_pane, + ] + + logger.info( + f"Extended Properties Viewer loaded successfully ({scope_label} scope, {len(property_ids)} properties)" + ) + + def _get_normalization_stats(self, prop_id: str): + """ + Compute mean and std for a property from distribution data. + + Parameters + ---------- + prop_id : str + Property ID to compute stats for + + Returns + ------- + tuple + (mean, std) for z-score normalization + """ + if self.properties_dist_df is None: + return 0.0, 1.0 + + # Get all values for this property + prop_values = self.properties_dist_df[ + self.properties_dist_df["property_id"] == prop_id + ]["value_float"].values + + # Filter out NaN/inf + prop_values = prop_values[np.isfinite(prop_values)] + + if len(prop_values) == 0: + return 0.0, 1.0 + + mean = np.mean(prop_values) + std = np.std(prop_values) + + # Avoid division by zero + if std == 0 or not np.isfinite(std): + std = 1.0 + + return mean, std + + def _normalize_values( + self, values: np.ndarray, mean: float, std: float + ) -> np.ndarray: + """ + Apply z-score normalization to values. + + Parameters + ---------- + values : np.ndarray + Values to normalize + mean : float + Mean for normalization + std : float + Standard deviation for normalization + + Returns + ------- + np.ndarray + Normalized values + """ + return (values - mean) / std + + def _create_timeseries_plot(self): + """Create time series plot with selected properties.""" + if self.properties_ts_df is None or len(self.properties_ts_df) == 0: + # Create empty placeholder + return hv.Curve([]).opts( + width=800, height=400, title="Time Series (no properties available)" + ) + + # Filter to selected properties + if len(self.selected_properties) == 0: + return hv.Curve([]).opts( + width=800, + height=400, + title="Time Series (select properties to display)", + ) + + df = self.properties_ts_df[ + self.properties_ts_df["property_id"].isin(self.selected_properties) + ] + + if len(df) == 0: + return hv.Curve([]).opts( + width=800, + height=400, + title="Time Series (no data for selected properties)", + ) + + # Build color map for selected properties (used by both time series and histograms) + self.property_color_map = { + prop_id: self.colors[i % len(self.colors)] + for i, prop_id in enumerate(self.selected_properties) + } + + # Build overlay of curves and spreads + overlay_elements = [] + has_data = False + + for i, prop_id in enumerate(self.selected_properties): + prop_df = df[df["property_id"] == prop_id].sort_values("time_window") + + if len(prop_df) == 0: + continue + + # Filter out rows with NaN/inf in avg_value + prop_df = prop_df[np.isfinite(prop_df["avg_value"])].copy() + + if len(prop_df) == 0: + logger.warning(f"No valid time series data for property {prop_id}") + continue + + has_data = True + color = self.property_color_map[prop_id] + + # Get normalization stats if needed + if self.normalize: + mean, std = self._get_normalization_stats(prop_id) + else: + mean, std = 0.0, 1.0 + + # Add individual agent lines FIRST (so they render behind aggregated lines) + if self.show_raw_lines and self.properties_raw_df is not None: + agent_lines = self._create_agent_lines(prop_id, color) + overlay_elements.extend(agent_lines) + + # Add shaded band for quantile range if available + if "q_lower" in prop_df.columns and "q_upper" in prop_df.columns: + # Filter to rows where quantiles are finite + quantile_df = prop_df[ + np.isfinite(prop_df["median_value"]) + & np.isfinite(prop_df["q_lower"]) + & np.isfinite(prop_df["q_upper"]) + ].copy() + if len(quantile_df) > 0: + # Apply normalization if needed + if self.normalize: + quantile_df["median_value"] = self._normalize_values( + quantile_df["median_value"].values, mean, std + ) + quantile_df["q_lower"] = self._normalize_values( + quantile_df["q_lower"].values, mean, std + ) + quantile_df["q_upper"] = self._normalize_values( + quantile_df["q_upper"].values, mean, std + ) + + # Compute error bands for Spread element (distance from median to quantiles) + neg_err = quantile_df["median_value"] - quantile_df["q_lower"] + pos_err = quantile_df["q_upper"] - quantile_df["median_value"] + + # Add quantile spread without showing in legend + spread = hv.Spread( + ( + quantile_df["time_window"], + quantile_df["median_value"], + neg_err, + pos_err, + ), + kdims="Time Window", + vdims=["Value", "neg_err", "pos_err"], + ).opts( + color=color, + show_legend=False, # Explicitly hide from legend + ) + + overlay_elements.append(spread) + + # Prepare median values for curve + median_values = prop_df["median_value"].values + if self.normalize: + median_values = self._normalize_values(median_values, mean, std) + + # Create median line curve (on top of agent lines and IQR spread) + curve = hv.Curve( + (prop_df["time_window"], median_values), + kdims="Time Window", + vdims="Value", + label=prop_id, + ).opts(color=color, line_width=2) + + overlay_elements.append(curve) + + if not has_data: + logger.warning("No valid data for any selected properties in time series") + return hv.Curve([]).opts( + width=800, height=400, title="Time Series (no valid data)" + ) + + def layout_hook(plot, element): + """Position legend and style title for plotly backend.""" + fig = plot.state + # Position legend inside plot + fig["layout"]["legend"] = dict( + yanchor="top", y=0.98, xanchor="right", x=0.98 + ) + # Reduce title font size for long scope strings + # Title might be a string or dict, so we need to handle both + current_title = fig["layout"].get("title", "") + if isinstance(current_title, str): + title_text = current_title + else: + title_text = current_title.get("text", "") + + fig["layout"]["title"] = dict(text=title_text, font=dict(size=9)) + + # Create overlay and apply options + scope_str = ( + str(self.context.scope) + if self.context and self.context.scope + else "Unknown Scope" + ) + # Wrap title text for long scope strings using
for Plotly + full_title = f"Property Time Series - {scope_str}" + if len(full_title) > 80: + # Split at a reasonable point (prefer after " - ") + parts = textwrap.wrap(full_title, width=80) + wrapped_title = "
".join(parts) + else: + wrapped_title = full_title + + return hv.Overlay(overlay_elements).opts( + width=800, + height=400, + title=wrapped_title, + show_legend=True, + hooks=[layout_hook], + ) + + def _create_histogram_layout(self): + """Create histogram layout with selected properties.""" + if self.properties_dist_df is None or len(self.properties_dist_df) == 0: + return hv.Curve([]).opts( + width=800, + height=300, + title="Distribution plots (no properties available)", + ) + + if len(self.selected_properties) == 0: + return hv.Curve([]).opts( + width=800, + height=300, + title="Distribution plots (select properties to display)", + ) + + # Filter to selected properties + df = self.properties_dist_df[ + self.properties_dist_df["property_id"].isin(self.selected_properties) + ] + + if len(df) == 0: + return hv.Curve([]).opts( + width=800, + height=300, + title="Distribution plots (no data for selected properties)", + ) + + # Ensure color map is built (same as in time series) + if not hasattr(self, "property_color_map") or set( + self.property_color_map.keys() + ) != set(self.selected_properties): + self.property_color_map = { + prop_id: self.colors[i % len(self.colors)] + for i, prop_id in enumerate(self.selected_properties) + } + + # Dispatch to appropriate helper method based on plot_type + if self.plot_type == "Histogram": + return self._create_histograms(df) + elif self.plot_type == "Violin Plot (separate)": + return self._create_separate_violins(df) + else: # "Violin Plot (merged)" + return self._create_merged_violin(df) + + def _create_histograms(self, df: pd.DataFrame): + """Create separate histogram for each property.""" + histogram_plots = [] + for prop_id in self.selected_properties: + prop_df = df[df["property_id"] == prop_id] + + if len(prop_df) == 0: + continue + + # Get values and clean them (remove NaN/inf) + values = prop_df["value_float"].values + values = values[np.isfinite(values)] + + if len(values) == 0: + logger.warning(f"No valid values for property {prop_id}") + continue + + # Apply normalization if needed + if self.normalize: + mean, std = self._get_normalization_stats(prop_id) + values = self._normalize_values(values, mean, std) + + # Use the same color as the time series for this property + color = self.property_color_map.get(prop_id, "navy") + + try: + # Create histogram with configurable bin count + frequencies, edges = np.histogram(values, bins=self.bin_count) + plot = hv.Histogram((edges, frequencies)).opts( + opts.Histogram( + color=color, + width=400, + height=300, + xlabel="Value", + ylabel="Count", + title=prop_id, + ) + ) + histogram_plots.append(plot) + except Exception as e: + logger.error(f"Failed to create histogram for {prop_id}: {e}") + continue + + # Return layout + if histogram_plots: + # Use Panel GridBox for independent axes, arranged in rows of 3 columns + return pn.GridBox(*[pn.pane.HoloViews(h) for h in histogram_plots], ncols=3) + else: + return hv.Curve([]).opts( + width=800, height=300, title="Histograms (no valid data)" + ) + + def _create_separate_violins(self, df: pd.DataFrame): + """Create separate violin plot for each property.""" + violin_plots = [] + for prop_id in self.selected_properties: + prop_df = df[df["property_id"] == prop_id] + + if len(prop_df) == 0: + continue + + # Get values and clean them (remove NaN/inf) + values = prop_df["value_float"].values + values = values[np.isfinite(values)] + + if len(values) == 0: + logger.warning(f"No valid values for property {prop_id}") + continue + + # Apply normalization if needed + if self.normalize: + mean, std = self._get_normalization_stats(prop_id) + values = self._normalize_values(values, mean, std) + + # Use the same color as the time series for this property + color = self.property_color_map.get(prop_id, "navy") + + try: + # Create violin plot using HoloViews Violin element + violin_df = pd.DataFrame( + {"Property": [prop_id] * len(values), "Value": values} + ) + plot = hv.Violin(violin_df, kdims=["Property"], vdims=["Value"]).opts( + color=color, + width=400, + height=300, + xlabel="Property", + ylabel="Value", + title=prop_id, + backend="plotly", + ) + violin_plots.append(plot) + except Exception as e: + logger.error(f"Failed to create violin plot for {prop_id}: {e}") + continue + + # Return layout + if violin_plots: + # Use Panel GridBox for independent axes, arranged in rows of 3 columns + return pn.GridBox(*[pn.pane.HoloViews(h) for h in violin_plots], ncols=3) + else: + return hv.Curve([]).opts( + width=800, height=300, title="Violin plots (no valid data)" + ) + + def _create_merged_violin(self, df: pd.DataFrame): + """Create a single merged violin plot with all selected properties.""" + # Collect all property values into a single DataFrame + all_values = [] + for prop_id in self.selected_properties: + prop_df = df[df["property_id"] == prop_id] + + if len(prop_df) == 0: + continue + + # Get values and clean them (remove NaN/inf) + values = prop_df["value_float"].values + values = values[np.isfinite(values)] + + if len(values) == 0: + logger.warning(f"No valid values for property {prop_id}") + continue + + # Apply normalization if needed + if self.normalize: + mean, std = self._get_normalization_stats(prop_id) + values = self._normalize_values(values, mean, std) + + # Add rows with property label + for val in values: + all_values.append({"Property": prop_id, "Value": val}) + + if not all_values: + return hv.Curve([]).opts( + width=800, height=300, title="Merged violin plot (no valid data)" + ) + + # Create merged DataFrame + merged_df = pd.DataFrame(all_values) + + # Create single violin plot with all properties + # Use matplotlib backend for simpler, less cluttered visualization + try: + plot = hv.Violin(merged_df, kdims=["Property"], vdims=["Value"]).opts( + width=800, + height=400, + xlabel="Property", + ylabel="Value", + title="Property Distributions (Merged View)", + backend="matplotlib", + show_legend=False, + ) + + # Apply color mapping via hooks + def color_hook(plot, element): + """Apply per-property colors to violin plot.""" + try: + # Try to get axis from handles (different keys may be used) + ax = None + if hasattr(plot, "handles"): + # Try common handle keys + for key in ["axis", "axes", "ax"]: + if key in plot.handles: + ax = plot.handles[key] + break + + # Fallback: get current axis from plot state + if ax is None and hasattr(plot, "state"): + # plot.state might be the figure, get current axes + import matplotlib.pyplot as plt + + ax = plt.gca() + + if ax is None: + logger.warning( + "Could not access matplotlib axis for color customization" + ) + return + + # Get violin parts (PolyCollection objects) + if hasattr(ax, "collections") and len(ax.collections) > 0: + for i, (collection, prop_id) in enumerate( + zip(ax.collections, self.selected_properties) + ): + if prop_id in self.property_color_map: + color = self.property_color_map[prop_id] + collection.set_facecolor(color) + collection.set_edgecolor(color) + collection.set_alpha(0.6) + except Exception as e: + logger.warning(f"Failed to apply colors to merged violin plot: {e}") + + plot = plot.opts(hooks=[color_hook]) + + return plot + except Exception as e: + logger.error(f"Failed to create merged violin plot: {e}") + return hv.Curve([]).opts( + width=800, + height=300, + title="Merged violin plot (error during creation)", + ) + + def _hex_to_rgba(self, hex_color: str, opacity: float) -> str: + """ + Convert hex color to rgba string for Plotly. + + Parameters + ---------- + hex_color : str + Hex color like '#1f77b4' + opacity : float + Opacity value 0.0-1.0 + + Returns + ------- + str + RGBA color string like 'rgba(31, 119, 180, 0.3)' + """ + # Remove '#' if present + hex_color = hex_color.lstrip("#") + + # Convert to RGB + r = int(hex_color[0:2], 16) + g = int(hex_color[2:4], 16) + b = int(hex_color[4:6], 16) + + return f"rgba({r}, {g}, {b}, {opacity})" + + def _create_agent_lines(self, prop_id: str, base_color: str) -> List[hv.Curve]: + """ + Create individual agent trajectory lines for a property. + + Parameters + ---------- + prop_id : str + Property ID to plot + base_color : str + Base color for this property (will be used with opacity) + + Returns + ------- + List[hv.Curve] + List of curve elements, one per agent (up to max_agents_to_plot) + """ + if self.properties_raw_df is None: + return [] + + # Filter to this property + prop_raw = self.properties_raw_df[ + self.properties_raw_df["property_id"] == prop_id + ].copy() + + if len(prop_raw) == 0: + return [] + + # Filter out NaN/inf values + prop_raw = prop_raw[np.isfinite(prop_raw["value_float"])].copy() + + if len(prop_raw) == 0: + return [] + + # Apply normalization if needed + if self.normalize: + mean, std = self._get_normalization_stats(prop_id) + prop_raw["value_float"] = self._normalize_values( + prop_raw["value_float"].values, mean, std + ) + + # Get unique agents + agents = prop_raw["agent_id"].unique() + + # Limit number of agents to plot for performance + if len(agents) > self.max_agents_to_plot: + logger.info( + f"Limiting agent lines from {len(agents)} to {self.max_agents_to_plot} agents" + ) + # Sample agents deterministically (same agents each time) + agents = np.sort(agents)[: self.max_agents_to_plot] + + # Convert base color to rgba with opacity (Plotly doesn't support alpha parameter) + rgba_color = self._hex_to_rgba(base_color, self.raw_line_opacity) + + # Create a curve for each agent + agent_curves = [] + for agent_id in agents: + agent_data = prop_raw[prop_raw["agent_id"] == agent_id].sort_values( + "time_index" + ) + + if len(agent_data) < 2: + # Need at least 2 points for a line + continue + + # Create curve with markers (Plotly-compatible) + curve = hv.Curve( + (agent_data["time_index"], agent_data["value_float"]), + kdims="Time Window", + vdims="Value", + ).opts( + color=rgba_color, # Use rgba color with opacity + line_width=1, + show_legend=False, + ) + + # Add markers using Scatter overlay + scatter = hv.Scatter( + (agent_data["time_index"], agent_data["value_float"]), + kdims="Time Window", + vdims="Value", + ).opts(color=rgba_color, size=self.raw_marker_size, show_legend=False) + + # Combine line and markers + agent_curves.append(curve * scatter) + + logger.info(f"Created {len(agent_curves)} agent lines for property {prop_id}") + return agent_curves + + @param.depends("selected_properties", watch=True) + def _on_properties_change(self): + """Handle property selection changes.""" + # Update plots if any data is loaded (time series OR distributions) + if ( + self.properties_ts_df is not None or self.properties_dist_df is not None + ) and len(self.display_pane.objects) > 1: + self._update_plots() + + @param.depends("show_raw_lines", watch=True) + def _on_show_raw_lines_change(self): + """Handle show_raw_lines toggle - reload data if needed.""" + if self.properties_ts_df is None: + return # No data loaded yet + + # If enabling raw lines and we don't have the data, query it + if self.show_raw_lines and self.properties_raw_df is None: + logger.info("Loading raw property data for agent lines...") + # Use selected properties (not all properties) + property_ids = ( + list(self.selected_properties) if self.selected_properties else None + ) + self.properties_raw_df = self.query_with_context( + "get_extended_properties_raw", property_ids=property_ids + ) + logger.info(f"Loaded {len(self.properties_raw_df)} raw observations") + + # Update plots + if len(self.display_pane.objects) > 1: + self._update_plots() + + @param.depends( + "raw_line_opacity", "raw_marker_size", "max_agents_to_plot", watch=True + ) + def _on_raw_params_change(self): + """Handle changes to raw line parameters.""" + if ( + self.show_raw_lines + and self.properties_raw_df is not None + and len(self.display_pane.objects) > 1 + ): + self._update_plots() + + @param.depends("lower_quantile", "upper_quantile", watch=True) + def _on_quantile_change(self): + """Handle quantile parameter changes - reload aggregated data.""" + if self.properties_ts_df is None: + return # No data loaded yet + + logger.info( + f"Reloading time series with new quantiles: {self.lower_quantile:.0%} - {self.upper_quantile:.0%}" + ) + + # Reload aggregated data with new quantiles + # Use selected properties (not all properties) + property_ids = ( + list(self.selected_properties) if self.selected_properties else None + ) + self.properties_ts_df = self.query_with_context( + "get_extended_properties_timeseries", + property_ids=property_ids, + lower_quantile=self.lower_quantile, + upper_quantile=self.upper_quantile, + ) + + # Update plots + if len(self.display_pane.objects) > 1: + self._update_plots() + + @param.depends("normalize", watch=True) + def _on_normalize_change(self): + """Handle normalization toggle - update plots with z-scored values.""" + if self.properties_ts_df is None and self.properties_dist_df is None: + return # No data loaded yet + + logger.info(f"Normalization {'enabled' if self.normalize else 'disabled'}") + + # Update plots (normalization is applied client-side) + if len(self.display_pane.objects) > 1: + self._update_plots() + + @param.depends("bin_count", watch=True) + def _on_bin_count_change(self): + """Handle bin count changes - update histogram plots.""" + if self.properties_dist_df is None: + return # No data loaded yet + + logger.info(f"Histogram bin count changed to {self.bin_count}") + + # Update plots (only affects histograms) + if len(self.display_pane.objects) > 1: + self._update_plots() + + @param.depends("plot_type", watch=True) + def _on_plot_type_change(self): + """Handle plot type changes - switch between histogram and violin.""" + if self.properties_dist_df is None: + return # No data loaded yet + + logger.info(f"Plot type changed to {self.plot_type}") + + # Update plots (only affects distribution panel) + if len(self.display_pane.objects) > 1: + self._update_plots() + + def _wrap_distribution_pane(self, histogram_layout): + """Wrap distribution plot layout in appropriate Panel pane.""" + if isinstance(histogram_layout, pn.GridBox): + # GridBox is already a Panel component + return histogram_layout + else: + # For merged violin (matplotlib) or empty plots, wrap in HoloViews pane + # Use fixed height for matplotlib backend to prevent rendering issues + if self.plot_type == "Violin Plot (merged)": + return pn.pane.HoloViews( + histogram_layout, sizing_mode="stretch_width", height=500 + ) + else: + return pn.pane.HoloViews( + histogram_layout, sizing_mode="stretch_width", min_height=300 + ) + + def _update_plots(self): + """Helper to update plots based on current scope.""" + assert self.context is not None + # Determine scope type + if self.context.scope.scope_type == ScopeType.EPISODE: + # Episode scope: Update both time series and distribution panels + timeseries_plot = self._create_timeseries_plot() + histogram_layout = self._create_histogram_layout() + + # Prepare histogram pane + histogram_pane = self._wrap_distribution_pane(histogram_layout) + + # Rebuild the entire objects list to trigger Panel update + self.display_pane.objects = [ + pn.pane.Markdown("## Time Series Panel"), + pn.pane.HoloViews( + timeseries_plot, sizing_mode="stretch_width", height=400 + ), + pn.pane.Markdown("## Distribution Panel"), + histogram_pane, + ] + + else: # SESSION scope + # Session scope: Update only distribution panel + histogram_layout = self._create_histogram_layout() + + # Prepare histogram pane + histogram_pane = self._wrap_distribution_pane(histogram_layout) + + # Rebuild the objects list for session scope + self.display_pane.objects = [ + pn.pane.Markdown("## Distribution Panel (Session-Level Aggregation)"), + pn.pane.Markdown( + "_Time series plots are not available for session-level analysis_" + ), + histogram_pane, + ] diff --git a/collab_env/dashboard/widgets/query_scope.py b/collab_env/dashboard/widgets/query_scope.py new file mode 100644 index 00000000..951075f7 --- /dev/null +++ b/collab_env/dashboard/widgets/query_scope.py @@ -0,0 +1,202 @@ +""" +Query scope abstraction for flexible data selection. + +Defines what subset of data to analyze (episode, session, or custom filters). +""" + +from dataclasses import dataclass, field +from typing import Optional, Dict, Any, List +from enum import Enum + + +class ScopeType(Enum): + """Type of data scope for analysis.""" + + EPISODE = "episode" + SESSION = "session" + CUSTOM = "custom" + + +@dataclass +class QueryScope: + """ + Defines what data subset to analyze. + + Supports three types of scopes: + - EPISODE: Single episode with optional time filtering + - SESSION: All episodes in a session + - CUSTOM: Arbitrary filters for advanced queries + + Examples + -------- + >>> # Analyze specific time range in episode + >>> scope = QueryScope.from_episode("ep_123", start_time=0, end_time=500) + + >>> # Analyze entire session + >>> scope = QueryScope.from_session("sess_456", agent_type="agent") + + >>> # Custom filtered analysis + >>> scope = QueryScope.from_custom( + ... session_id="sess_456", + ... agent_ids=["agent_1", "agent_2"], + ... min_speed=5.0 + ... ) + """ + + scope_type: ScopeType + + # Identifiers (at least one required) + episode_id: Optional[str] = None + session_id: Optional[str] = None + + # Time filtering + start_time: Optional[int] = None + end_time: Optional[int] = None + + # Agent filtering + agent_type: Optional[str] = None # "agent", "target", "all", or custom + agent_ids: Optional[List[str]] = None # Specific agent IDs + + # Arbitrary filters (for custom scope) + custom_filters: Optional[Dict[str, Any]] = field(default_factory=dict) + + @classmethod + def from_episode( + cls, + episode_id: str, + start_time: Optional[int] = None, + end_time: Optional[int] = None, + agent_type: str = "agent", + ) -> "QueryScope": + """ + Create scope for single episode. + + Parameters + ---------- + episode_id : str + Episode identifier + start_time : int, optional + Start time (frame number) + end_time : int, optional + End time (frame number) + agent_type : str, default="agent" + Agent type filter + + Returns + ------- + QueryScope + Episode scope + """ + return cls( + scope_type=ScopeType.EPISODE, + episode_id=episode_id, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + ) + + @classmethod + def from_session( + cls, + session_id: str, + start_time: Optional[int] = None, + end_time: Optional[int] = None, + agent_type: str = "agent", + ) -> "QueryScope": + """ + Create scope for full session (all episodes). + + Parameters + ---------- + session_id : str + Session identifier + start_time : int, optional + Start time (frame number) + end_time : int, optional + End time (frame number) + agent_type : str, default="agent" + Agent type filter + + Returns + ------- + QueryScope + Session scope + """ + return cls( + scope_type=ScopeType.SESSION, + session_id=session_id, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + ) + + @classmethod + def from_custom(cls, **filters) -> "QueryScope": + """ + Create custom scope with arbitrary filters. + + Parameters + ---------- + **filters + Arbitrary filter key-value pairs + + Returns + ------- + QueryScope + Custom scope + + Examples + -------- + >>> scope = QueryScope.from_custom( + ... session_id="sess_123", + ... agent_ids=["a1", "a2"], + ... min_speed=5.0 + ... ) + """ + return cls(scope_type=ScopeType.CUSTOM, custom_filters=filters) + + def to_query_params(self) -> Dict[str, Any]: + """ + Convert scope to dictionary of query parameters. + + Returns + ------- + dict + Query parameters suitable for QueryBackend methods + """ + params: Dict[str, Any] = {} + + if self.episode_id: + params["episode_id"] = self.episode_id + if self.session_id: + params["session_id"] = self.session_id + if self.start_time is not None: + params["start_time"] = self.start_time + if self.end_time is not None: + params["end_time"] = self.end_time + if self.agent_type: + params["agent_type"] = self.agent_type + if self.agent_ids: + params["agent_ids"] = self.agent_ids + if self.custom_filters: + params.update(self.custom_filters) + + return params + + def __str__(self) -> str: + """String representation for debugging.""" + if self.scope_type == ScopeType.EPISODE: + time_range = "" + if self.start_time is not None or self.end_time is not None: + time_range = f" [{self.start_time or 0}:{self.end_time or '∞'}]" + return f"Episode({self.episode_id}{time_range}, {self.agent_type})" + elif self.scope_type == ScopeType.SESSION: + time_range = "" + if self.start_time is not None or self.end_time is not None: + time_range = f" [{self.start_time or 0}:{self.end_time or '∞'}]" + return f"Session({self.session_id}{time_range}, {self.agent_type})" + else: + filters = ", ".join( + f"{k}={v}" for k, v in (self.custom_filters or {}).items() + ) + return f"Custom({filters})" diff --git a/collab_env/dashboard/widgets/velocity_widget.py b/collab_env/dashboard/widgets/velocity_widget.py new file mode 100644 index 00000000..2c056b03 --- /dev/null +++ b/collab_env/dashboard/widgets/velocity_widget.py @@ -0,0 +1,490 @@ +""" +Velocity statistics widget. + +Displays three groups of velocity statistics: +1. Individual agent speed (histogram + time series with median and IQR) +2. Mean velocity magnitude at each timestamp (histogram + time series) +3. Relative velocity magnitude between pairs (histogram + time series with median and IQR) +""" + +import logging +from typing import Optional + +import numpy as np +import pandas as pd +import param +import panel as pn +import holoviews as hv +from holoviews import opts + +from .base_analysis_widget import BaseAnalysisWidget +from .query_scope import ScopeType + +logger = logging.getLogger(__name__) + + +class VelocityStatsWidget(BaseAnalysisWidget): + """ + Comprehensive velocity statistics visualization. + + Displays three groups of velocity metrics: + - Individual agent speeds (from observations) - median + IQR bands + - Mean velocity magnitude (normalized velocity vectors, then magnitude of mean) + - Relative velocity magnitudes (pairwise ||v_i - v_j||) - median + IQR bands + """ + + widget_name = "Velocity Stats" + widget_description = "Comprehensive velocity statistics" + widget_category = "temporal" + + # Widget-specific parameters (minimal, since layout is fixed) + bin_count = param.Integer( + default=30, bounds=(10, 100), doc="Number of bins for histograms" + ) + + def create_custom_controls(self) -> Optional[pn.Column]: + """Create widget-specific controls.""" + return pn.Column( + "### Visualization Options", + pn.widgets.IntSlider.from_param( + self.param.bin_count, name="Histogram Bins", width=200 + ), + ) + + def create_display_pane(self) -> pn.pane.PaneBase: + """Create empty plot pane.""" + # Return a Column that we can update with content + return pn.Column( + pn.pane.Markdown('Click "Load Data" to display velocity statistics'), + sizing_mode="stretch_both", + ) + + def load_data(self) -> None: + """Load and visualize velocity statistics.""" + assert self.context is not None + # Validate this is episode scope only + if self.context.scope.scope_type != ScopeType.EPISODE: + raise ValueError( + "Velocity Stats widget only supports episode-level analysis. " + "Please select an episode scope instead of session scope." + ) + + # Get raw episode tracks (positions + velocities for all agents at all times) + df_tracks = self.query_with_context("get_episode_tracks") + + if len(df_tracks) == 0: + raise ValueError("No data found for selected parameters") + + # Container for display elements + display_objects = [] + successful_groups = 0 + + # Group 1a: Individual agent speed (should always work) + try: + speed_data = self._to_numeric_array(df_tracks["speed"]) + speed_hist = self._create_histogram( + speed_data, + "1a. Individual Agent Speed - Distribution", + "Speed", + "darkblue", + ) + speed_ts = self._create_speed_time_series( + df_tracks, "1a. Individual Agent Speed - Time Series" + ) + display_objects.extend( + [ + pn.pane.Markdown("## 1a. Individual Agent Speed"), + pn.pane.HoloViews((speed_hist + speed_ts).opts(axiswise=True)), + ] + ) + successful_groups += 1 + logger.info("✓ Individual agent speed statistics computed successfully") + except Exception as e: + logger.warning(f"Failed to compute individual agent speed: {e}") + display_objects.extend( + [ + pn.pane.Markdown("## 1a. Individual Agent Speed"), + pn.pane.Markdown( + f"_Could not compute individual agent speed statistics: {e}_" + ), + ] + ) + + # Group 1b: Mean velocity magnitude (may fail if all agents stationary) + try: + mean_vel_mag_data = self._compute_mean_velocity_magnitude(df_tracks) + if ( + len(mean_vel_mag_data) == 0 + or mean_vel_mag_data["mean_velocity_magnitude"].isna().all() + ): + raise ValueError("All agents have zero or near-zero velocity") + + mean_vel_mag_hist = self._create_histogram( + mean_vel_mag_data["mean_velocity_magnitude"].values, + "1b. Mean Velocity Magnitude - Distribution", + "Magnitude", + "darkgreen", + ) + mean_vel_mag_ts = self._create_simple_time_series( + mean_vel_mag_data, + "mean_velocity_magnitude", + "1b. Mean Velocity Magnitude - Time Series", + "green", + ) + display_objects.extend( + [ + pn.pane.Markdown("## 1b. Mean Velocity Magnitude"), + pn.pane.HoloViews( + (mean_vel_mag_hist + mean_vel_mag_ts).opts(axiswise=True) + ), + ] + ) + successful_groups += 1 + logger.info("✓ Mean velocity magnitude statistics computed successfully") + except Exception as e: + logger.warning(f"Failed to compute mean velocity magnitude: {e}") + display_objects.extend( + [ + pn.pane.Markdown("## 1b. Mean Velocity Magnitude"), + pn.pane.Markdown( + f"_Could not compute mean velocity magnitude: {e}_" + ), + ] + ) + + # Group 1c: Relative velocity magnitude (may fail or be uninteresting if agents stationary) + try: + rel_vel_mag_data = self._compute_relative_velocity_magnitude(df_tracks) + if len(rel_vel_mag_data) == 0: + raise ValueError("No pairwise velocity data available") + + # Check if all relative velocities are near-zero (stationary agents) + if rel_vel_mag_data["relative_velocity_magnitude"].max() < 1e-6: + raise ValueError("All agents appear stationary (no relative movement)") + + rel_vel_mag_hist = self._create_histogram( + rel_vel_mag_data["relative_velocity_magnitude"].values, + "1c. Relative Velocity Magnitude - Distribution", + "||v_i - v_j||", + "darkorange", + ) + rel_vel_mag_ts = self._create_relative_time_series( + rel_vel_mag_data, + "relative_velocity_magnitude", + "1c. Relative Velocity Magnitude - Time Series", + "orange", + ) + display_objects.extend( + [ + pn.pane.Markdown("## 1c. Relative Velocity Magnitude (pairwise)"), + pn.pane.HoloViews( + (rel_vel_mag_hist + rel_vel_mag_ts).opts(axiswise=True) + ), + ] + ) + successful_groups += 1 + logger.info( + "✓ Relative velocity magnitude statistics computed successfully" + ) + except Exception as e: + logger.warning(f"Failed to compute relative velocity magnitude: {e}") + display_objects.extend( + [ + pn.pane.Markdown("## 1c. Relative Velocity Magnitude (pairwise)"), + pn.pane.Markdown( + f"_Could not compute relative velocity statistics: {e}_" + ), + ] + ) + + # Only fail if NO statistics could be computed + if successful_groups == 0: + raise ValueError( + "Could not compute any velocity statistics. Check data quality." + ) + + # Update display with whatever we successfully computed + self.display_pane.objects = display_objects + logger.info( + f"Loaded velocity stats with {len(df_tracks)} observations ({successful_groups}/3 groups successful)" + ) + + def _to_numeric_array(self, series: pd.Series) -> np.ndarray: + """Convert pandas series to clean numeric array, replacing None/NaN with 0.0.""" + # Convert to numeric (handles None, converts to NaN) + numeric = pd.to_numeric(series, errors="coerce") + # Replace NaN with 0.0 + return numeric.fillna(0.0).values + + def _create_histogram( + self, data: np.ndarray, title: str, xlabel: str, color: str + ) -> hv.Histogram: + """Create a histogram plot.""" + # Remove NaN and infinite values + clean_data = data[np.isfinite(data)] + if len(clean_data) == 0: + raise ValueError(f"No valid data for histogram: {title}") + + # Check for zero variance (all values are the same) + if np.std(clean_data) < 1e-10: + # Create a single-bin histogram centered on the constant value + value = clean_data[0] + edges = np.array([value - 0.5, value + 0.5]) + frequencies = np.array([len(clean_data)]) + else: + frequencies, edges = np.histogram(clean_data, bins=self.bin_count) + + hist = hv.Histogram((edges, frequencies)) + hist.opts( + opts.Histogram( + color=color, + width=500, + height=300, + xlabel=xlabel, + ylabel="Count", + title=title, + ) + ) + return hist + + def _create_speed_time_series( + self, df_tracks: pd.DataFrame, title: str = "Speed Over Time" + ) -> hv.Overlay: + """Create time series with median and IQR (25th-75th percentile) for individual agent speeds.""" + logger.info( + "⭐ USING NEW VERSION: Creating speed time series with Spread element" + ) + assert self.context is not None + window_size = self.context.temporal_window_size + + # Clean speed data first (handle None/NaN values) + df_tracks = df_tracks.copy() + df_tracks["speed"] = self._to_numeric_array(df_tracks["speed"]) + + # Compute windowed statistics (median and quartiles) + df_tracks["time_window"] = ( + df_tracks["time_index"] // window_size + ) * window_size + stats = ( + df_tracks.groupby("time_window")["speed"] + .agg( + [ + ("median", "median"), + ("q25", lambda x: x.quantile(0.25)), + ("q75", lambda x: x.quantile(0.75)), + ] + ) + .reset_index() + ) + + # Compute errors for Spread element (distance from median to quantiles) + stats["neg_err"] = stats["median"] - stats["q25"] + stats["pos_err"] = stats["q75"] - stats["median"] + + # Create median line + curve = hv.Curve( + (stats["time_window"], stats["median"]), + kdims="Time", + vdims="Speed", + label="Median", + ).opts(color="darkblue", line_width=2) + + # Create IQR spread + spread = hv.Spread( + (stats["time_window"], stats["median"], stats["neg_err"], stats["pos_err"]), + kdims="Time", + vdims=["Speed", "neg_err", "pos_err"], + label="IQR (25th-75th)", + ).opts(color="lightblue") + + def legend_hook(plot, element): + """Position legend inside plot for plotly backend.""" + fig = plot.state + fig["layout"]["legend"] = dict( + yanchor="top", y=0.98, xanchor="right", x=0.98 + ) + + return (spread * curve).opts( + width=500, height=300, title=title, show_legend=True, hooks=[legend_hook] + ) + + def _create_simple_time_series( + self, df: pd.DataFrame, value_col: str, title: str, color: str + ) -> hv.Curve: + """Create simple time series with windowing (no std bands).""" + assert self.context is not None + window_size = self.context.temporal_window_size + + # Filter out NaN values + df_clean = df.dropna(subset=[value_col]).copy() + if len(df_clean) == 0: + raise ValueError(f"No valid data for time series: {title}") + + # Apply windowing and compute mean per window + df_clean["time_window"] = (df_clean["time_index"] // window_size) * window_size + stats = df_clean.groupby("time_window")[value_col].mean().reset_index() + + return hv.Curve(stats, kdims="time_window", vdims=value_col).opts( + color=color, + line_width=2, + width=500, + height=300, + xlabel="Time", + ylabel="Magnitude", + title=title, + ) + + def _create_relative_time_series( + self, df: pd.DataFrame, value_col: str, title: str, color: str + ) -> hv.Overlay: + """Create time series with median and IQR (25th-75th percentile) for relative quantities.""" + logger.info( + f"⭐ USING NEW VERSION: Creating relative time series with Spread element (color={color})" + ) + assert self.context is not None + window_size = self.context.temporal_window_size + + # Compute windowed statistics (median and quartiles) + df["time_window"] = (df["time_index"] // window_size) * window_size + stats = ( + df.groupby("time_window")[value_col] + .agg( + [ + ("median", "median"), + ("q25", lambda x: x.quantile(0.25)), + ("q75", lambda x: x.quantile(0.75)), + ] + ) + .reset_index() + ) + + # Compute errors for Spread element + stats["neg_err"] = stats["median"] - stats["q25"] + stats["pos_err"] = stats["q75"] - stats["median"] + + # Create line plot (median) - use darker shade for line + dark_color = {"green": "darkgreen", "orange": "darkorange"}.get(color, color) + light_color = {"green": "lightgreen", "orange": "lightsalmon"}.get(color, color) + + curve = hv.Curve( + (stats["time_window"], stats["median"]), + kdims="Time", + vdims="Magnitude", + label="Median", + ).opts(color=dark_color, line_width=2) + + # Create IQR spread + spread = hv.Spread( + (stats["time_window"], stats["median"], stats["neg_err"], stats["pos_err"]), + kdims="Time", + vdims=["Magnitude", "neg_err", "pos_err"], + label="IQR (25th-75th)", + ).opts(color=light_color) + + def legend_hook(plot, element): + """Position legend inside plot for plotly backend.""" + fig = plot.state + fig["layout"]["legend"] = dict( + yanchor="top", y=0.98, xanchor="right", x=0.98 + ) + + return (spread * curve).opts( + width=500, height=300, title=title, show_legend=True, hooks=[legend_hook] + ) + + def _compute_mean_velocity_magnitude(self, df_tracks: pd.DataFrame) -> pd.DataFrame: + """ + Compute mean velocity magnitude at each timestamp. + + At each time: normalize velocities v_i/||v_i||, compute mean vector, take norm. + """ + results = [] + + for time_idx in df_tracks["time_index"].unique(): + df_t = df_tracks[df_tracks["time_index"] == time_idx].copy() + + # Compute velocity magnitudes (handle 2D data where v_z might be None/NaN or missing) + v_x = self._to_numeric_array(df_t["v_x"]) + v_y = ( + self._to_numeric_array(df_t["v_y"]) + if "v_y" in df_t.columns and not df_t["v_y"].isna().all() + else np.zeros(len(df_t)) + ) + v_z_vals = ( + self._to_numeric_array(df_t["v_z"]) + if "v_z" in df_t.columns + else np.zeros(len(df_t)) + ) + v_mag = np.sqrt(v_x**2 + v_y**2 + v_z_vals**2) + + # Normalize velocities (avoid division by zero) + mask = v_mag > 1e-10 + if mask.sum() == 0: + continue + + v_x_norm = np.zeros_like(v_x) + v_y_norm = np.zeros_like(v_y) + v_z_norm = np.zeros(len(df_t)) + + v_x_norm[mask] = v_x[mask] / v_mag[mask] + v_y_norm[mask] = v_y[mask] / v_mag[mask] + v_z_norm[mask] = v_z_vals[mask] / v_mag[mask] + + # Compute mean normalized vector + mean_v_x = v_x_norm[mask].mean() + mean_v_y = v_y_norm[mask].mean() + mean_v_z = v_z_norm[mask].mean() + + # Compute magnitude of mean vector + mean_vel_mag = np.sqrt(mean_v_x**2 + mean_v_y**2 + mean_v_z**2) + + results.append( + {"time_index": time_idx, "mean_velocity_magnitude": mean_vel_mag} + ) + + return pd.DataFrame(results) + + def _compute_relative_velocity_magnitude( + self, df_tracks: pd.DataFrame + ) -> pd.DataFrame: + """ + Compute pairwise relative velocity magnitudes ||v_i - v_j|| for all i>> registry = WidgetRegistry("analysis_widgets.yaml") + >>> widgets = registry.get_enabled_widgets() + >>> for widget in widgets: + ... print(f"Loaded: {widget.widget_name}") + """ + + def __init__(self, config_path: Optional[str] = None): + """ + Initialize registry. + + Parameters + ---------- + config_path : str, optional + Path to YAML config file. If None, uses default location. + """ + self.widgets: Dict[str, Type[BaseAnalysisWidget]] = {} + self.config: Dict[str, Any] = {} + + if config_path: + self.load_from_config(config_path) + + def register( + self, widget_class: Type[BaseAnalysisWidget], name: Optional[str] = None + ): + """ + Register widget programmatically. + + Parameters + ---------- + widget_class : Type[BaseAnalysisWidget] + Widget class to register + name : str, optional + Registration name (defaults to class name) + """ + widget_name = name or widget_class.__name__ + self.widgets[widget_name] = widget_class + logger.info(f"Registered widget: {widget_name}") + + def load_from_config(self, config_path: str): + """ + Load widgets from YAML configuration. + + Parameters + ---------- + config_path : str + Path to YAML config file + + Examples + -------- + Config file format: + + ```yaml + defaults: + spatial_bin_size: 10.0 + + widgets: + - class: collab_env.dashboard.widgets.velocity_widget.VelocityStatsWidget + enabled: true + order: 1 + category: temporal + ``` + """ + config_file = Path(config_path) + + if not config_file.exists(): + logger.warning(f"Config file not found: {config_path}") + return + + with open(config_file, "r") as f: + self.config = yaml.safe_load(f) + + if not self.config: + logger.warning(f"Empty config file: {config_path}") + return + + # Load widget classes + widget_configs = self.config.get("widgets", []) + for widget_config in widget_configs: + class_path = widget_config.get("class") + if not class_path: + logger.warning(f"Widget config missing 'class' field: {widget_config}") + continue + + try: + widget_class = self._import_class(class_path) + self.register(widget_class, name=class_path) + logger.info(f"Loaded widget from config: {class_path}") + + except Exception as e: + logger.error(f"Failed to load widget {class_path}: {e}") + + def _import_class(self, class_path: str) -> Type[BaseAnalysisWidget]: + """ + Import class from module path. + + Parameters + ---------- + class_path : str + Full module path (e.g., "package.module.ClassName") + + Returns + ------- + Type[BaseAnalysisWidget] + Imported widget class + + Raises + ------ + ImportError + If module or class cannot be imported + TypeError + If class is not a BaseAnalysisWidget subclass + """ + # Split module and class name + module_path, class_name = class_path.rsplit(".", 1) + + # Import module + module = importlib.import_module(module_path) + + # Get class + widget_class = getattr(module, class_name) + + # Validate it's a widget + if not issubclass(widget_class, BaseAnalysisWidget): + raise TypeError(f"{class_path} is not a BaseAnalysisWidget subclass") + + return widget_class + + def get_enabled_widgets(self) -> List[BaseAnalysisWidget]: + """ + Get instantiated widgets that are enabled in config. + + Returns widgets sorted by order field in config. + + Returns + ------- + list of BaseAnalysisWidget + Instantiated enabled widgets + + Examples + -------- + >>> registry = WidgetRegistry("widgets.yaml") + >>> widgets = registry.get_enabled_widgets() + >>> for w in widgets: + ... print(f"{w.widget_name}: {w.widget_description}") + """ + enabled_widgets = [] + widget_configs = self.config.get("widgets", []) + + for widget_config in widget_configs: + # Check if enabled + if not widget_config.get("enabled", True): + continue + + class_path = widget_config.get("class") + if class_path not in self.widgets: + logger.warning(f"Widget not registered: {class_path}") + continue + + # Instantiate widget + try: + widget_class = self.widgets[class_path] + widget = widget_class() + + # Store metadata + widget._config_order = widget_config.get("order", 999) + widget._config_category = widget_config.get( + "category", widget.widget_category + ) + + enabled_widgets.append(widget) + + except Exception as e: + logger.error(f"Failed to instantiate {class_path}: {e}") + + # Sort by order + enabled_widgets.sort(key=lambda w: w._config_order) + + logger.info(f"Enabled {len(enabled_widgets)} widgets") + return enabled_widgets + + def get_defaults(self) -> Dict[str, Any]: + """ + Get default parameter values from config. + + Returns + ------- + dict + Default parameter values + + Examples + -------- + >>> defaults = registry.get_defaults() + >>> spatial_bin_size = defaults.get('spatial_bin_size', 10.0) + """ + return self.config.get("defaults", {}) diff --git a/collab_env/data/boids/boid_single_species_basic.pt b/collab_env/data/boids/boid_single_species_basic.pt deleted file mode 100644 index fad7366e..00000000 Binary files a/collab_env/data/boids/boid_single_species_basic.pt and /dev/null differ diff --git a/collab_env/data/boids/boid_single_species_basic_config.pt b/collab_env/data/boids/boid_single_species_basic_config.pt deleted file mode 100644 index 3a99fb35..00000000 Binary files a/collab_env/data/boids/boid_single_species_basic_config.pt and /dev/null differ diff --git a/collab_env/data/db/__init__.py b/collab_env/data/db/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/collab_env/data/db/config.py b/collab_env/data/db/config.py new file mode 100644 index 00000000..b5ec79ee --- /dev/null +++ b/collab_env/data/db/config.py @@ -0,0 +1,246 @@ +""" +Database configuration from environment variables. +Supports PostgreSQL and DuckDB backends. +""" + +import os +from typing import Optional +from dataclasses import dataclass + +from collab_env.data.file_utils import get_project_root + + +@dataclass +class PostgresConfig: + """PostgreSQL connection configuration""" + + dbname: str + user: str + password: Optional[str] + host: str + port: int + + @classmethod + def from_env(cls) -> "PostgresConfig": + """Load PostgreSQL config from environment variables""" + return cls( + dbname=os.getenv("POSTGRES_DB", "tracking_analytics"), + user=os.getenv("POSTGRES_USER", os.getenv("USER", "postgres")), + password=os.getenv("POSTGRES_PASSWORD"), # None if not set + host=os.getenv("POSTGRES_HOST", "localhost"), + port=int(os.getenv("POSTGRES_PORT", "5432")), + ) + + def connection_string(self, include_password: bool = True) -> str: + """Generate PostgreSQL connection string for SQLAlchemy""" + # Check if host is a Unix socket path (starts with '/') + # For Cloud Run, POSTGRES_HOST=/cloudsql/PROJECT:REGION:INSTANCE + if self.host.startswith("/"): + # Unix socket connection - pass directory path, driver adds .s.PGSQL.5432 + # See: https://cloud.google.com/sql/docs/postgres/samples/cloud-sql-postgres-sqlalchemy-connect-unix + if self.password and include_password: + return f"postgresql://{self.user}:{self.password}@/{self.dbname}?host={self.host}" + else: + return f"postgresql://{self.user}@/{self.dbname}?host={self.host}" + else: + # Standard TCP connection + if self.password and include_password: + return f"postgresql://{self.user}:{self.password}@{self.host}:{self.port}/{self.dbname}" + else: + return f"postgresql://{self.user}@{self.host}:{self.port}/{self.dbname}" + + def psycopg2_params(self) -> dict: + """Get parameters for psycopg2.connect() (for direct connections)""" + params = { + "dbname": self.dbname, + "user": self.user, + "host": self.host, + "port": self.port, + } + if self.password: + params["password"] = self.password + return params + + def sqlalchemy_url(self) -> str: + """Get SQLAlchemy connection URL""" + return self.connection_string(include_password=True) + + +@dataclass +class DuckDBConfig: + """DuckDB connection configuration""" + + dbpath: str + read_only: bool + + @classmethod + def from_env(cls) -> "DuckDBConfig": + """Load DuckDB config from environment variables""" + # Default to tracking.duckdb in project root or specified path + default_path = os.getenv("DUCKDB_PATH", "tracking.duckdb") + + # If relative path, make it absolute from project root + if not os.path.isabs(default_path): + project_root = get_project_root() + default_path = str(project_root / default_path) + + return cls( + dbpath=default_path, + read_only=os.getenv("DUCKDB_READ_ONLY", "false").lower() == "true", + ) + + def connection_string(self) -> str: + """Generate DuckDB connection string for SQLAlchemy""" + return f"duckdb:///{self.dbpath}" + + def sqlalchemy_url(self) -> str: + """Get SQLAlchemy connection URL""" + return self.connection_string() + + +class DBConfig: + """ + Main database configuration. + Automatically detects backend from DB_BACKEND env var. + """ + + def __init__(self, backend: Optional[str] = None): + """ + Initialize database configuration. + + Parameters + ---------- + backend : str, optional + Database backend ('postgres' or 'duckdb'). + If None, reads from DB_BACKEND env var (defaults to 'duckdb') + """ + self.backend = backend or os.getenv("DB_BACKEND", "duckdb") + + if self.backend not in ("postgres", "duckdb"): + raise ValueError( + f"Invalid backend: {self.backend}. Must be 'postgres' or 'duckdb'" + ) + + self.postgres: Optional[PostgresConfig] = None + self.duckdb: Optional[DuckDBConfig] = None + + if self.backend == "postgres": + self.postgres = PostgresConfig.from_env() + else: + self.duckdb = DuckDBConfig.from_env() + + @property + def connection_string(self) -> str: + """Get connection string for current backend""" + if self.backend == "postgres": + assert self.postgres is not None + return self.postgres.connection_string() + else: + assert self.duckdb is not None + return self.duckdb.connection_string() + + def sqlalchemy_url(self) -> str: + """Get SQLAlchemy connection URL for current backend""" + if self.backend == "postgres": + assert self.postgres is not None + return self.postgres.sqlalchemy_url() + else: + assert self.duckdb is not None + return self.duckdb.sqlalchemy_url() + + def __repr__(self) -> str: + if self.backend == "postgres": + assert self.postgres is not None + return f"DBConfig(backend='postgres', dbname='{self.postgres.dbname}', host='{self.postgres.host}')" + else: + assert self.duckdb is not None + return f"DBConfig(backend='duckdb', dbpath='{self.duckdb.dbpath}')" + + +def load_dotenv_if_exists(): + """ + Load .env file if python-dotenv is available. + This is optional - falls back to OS environment variables. + """ + try: + from dotenv import load_dotenv + + project_root = get_project_root() + env_file = project_root / ".env" + if env_file.exists(): + load_dotenv(env_file) + return True + except ImportError: + pass + return False + + +# Convenience function +def get_db_config(backend: Optional[str] = None) -> DBConfig: + """ + Get database configuration with optional .env file loading. + + Parameters + ---------- + backend : str, optional + Override backend (otherwise uses DB_BACKEND env var) + + Returns + ------- + DBConfig + Database configuration + + Examples + -------- + >>> config = get_db_config() + >>> print(config.backend) + 'duckdb' + + >>> config = get_db_config('postgres') + >>> print(config.postgres.dbname) + 'tracking_analytics' + """ + load_dotenv_if_exists() + return DBConfig(backend) + + +if __name__ == "__main__": + # Test configuration loading + + print("=" * 60) + print("Database Configuration Test") + print("=" * 60) + + # Try loading .env + if load_dotenv_if_exists(): + print("✓ Loaded .env file") + else: + print("✗ No .env file found (using OS environment)") + + print() + + # Test both backends + for backend in ["duckdb", "postgres"]: + print(f"\n{backend.upper()} Configuration:") + print("-" * 60) + + try: + config = DBConfig(backend) + print(f"Backend: {config.backend}") + print(f"Connection string: {config.connection_string}") + + if backend == "postgres": + assert config.postgres is not None + print(f"Database: {config.postgres.dbname}") + print(f"User: {config.postgres.user}") + print(f"Host: {config.postgres.host}:{config.postgres.port}") + print(f"Password set: {config.postgres.password is not None}") + else: + assert config.duckdb is not None + print(f"DB Path: {config.duckdb.dbpath}") + print(f"Read-only: {config.duckdb.read_only}") + + except Exception as e: + print(f"Error: {e}") + + print("\n" + "=" * 60) diff --git a/collab_env/data/db/db_loader.py b/collab_env/data/db/db_loader.py new file mode 100644 index 00000000..7d4ca7d8 --- /dev/null +++ b/collab_env/data/db/db_loader.py @@ -0,0 +1,2669 @@ +""" +Data loader for tracking analytics database. + +Loads data from various sources into PostgreSQL or DuckDB: +- 3D Boids: Parquet files from collab_env.sim.boids +- 2D Boids: PyTorch .pt files from collab_env.sim.boids_gnn_temp +- Tracking CSV: Real-world tracking data from collab_env.tracking +- GNN Rollout: Model evaluation rollout pickle files with predictions +""" + +import argparse +import json +import os +import re +import sys +from dataclasses import dataclass +from enum import Enum +from pathlib import Path +from typing import Any, Dict, List, Optional, Tuple +import numpy as np +import pandas as pd +import torch +import yaml +from loguru import logger +from sqlalchemy import create_engine, text +from sqlalchemy.engine import Engine + +from collab_env.data.db.config import DBConfig, get_db_config + +# Configure loguru logging +logger.remove() # Remove default handler +logger.add( + sys.stderr, + format="{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {name}:{function}:{line} - {message}", + level="INFO", +) + +# Add file output to logs directory +log_dir = Path(__file__).parent.parent.parent.parent / "logs" +log_dir.mkdir(exist_ok=True) +logger.add( + log_dir / "db_loader_{time:YYYY-MM-DD}.log", + rotation="00:00", # Rotate at midnight + retention="30 days", # Keep logs for 30 days + format="{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {name}:{function}:{line} - {message}", + level="DEBUG", +) + + +def convert_to_json_serializable(obj: Any) -> Any: + """ + Recursively convert numpy/PyTorch types to native Python types for JSON serialization. + + Args: + obj: Object to convert (dict, list, numpy type, torch type, etc.) + + Returns: + Converted object with native Python types + """ + if isinstance(obj, dict): + return {k: convert_to_json_serializable(v) for k, v in obj.items()} + elif isinstance(obj, (list, tuple)): + return [convert_to_json_serializable(item) for item in obj] + elif isinstance(obj, (np.integer, np.int64, np.int32, np.int16, np.int8)): + return int(obj) + elif isinstance(obj, (np.floating, np.float64, np.float32, np.float16)): + return float(obj) + elif isinstance(obj, np.ndarray): + return obj.tolist() + elif isinstance(obj, torch.Tensor): + return obj.cpu().numpy().tolist() + elif isinstance(obj, (np.bool_, bool)): + return bool(obj) + else: + return obj + + +def get_food_location_from_config( + config: Dict[str, Any], scene_size: float +) -> Optional[Tuple[float, float]]: + """ + Extract food location from 2D boids species config. + + The config structure is: + { + 'A': {'width': 480, 'height': 480, ...}, + 'food0': {'x': 160.0, 'y': 0, 'counts': 1} + } + + Food coordinates in config are in pixel coordinates. We normalize them + and then scale by scene_size to match the coordinate system used for + agent positions. + + Args: + config: Species configuration dictionary + scene_size: Scene size for coordinate scaling (default 480.0) + + Returns: + (food_x, food_y) in scaled scene coordinates, or None if no food + """ + if not config or "food0" not in config: + return None + + food_config = config["food0"] + + # Get scene dimensions (default to scene_size if not in config) + if "A" in config: + width = config["A"].get("width", scene_size) + height = config["A"].get("height", scene_size) + else: + width = height = scene_size + + # Food config stores pixel coordinates, normalize first + food_x_normalized = food_config["x"] / width + food_y_normalized = food_config["y"] / height + + # Scale to scene coordinates (same as agent positions) + food_x = food_x_normalized * scene_size + food_y = food_y_normalized * scene_size + + logger.debug( + f"Food location: pixel=({food_config['x']}, {food_config['y']}), " + f"normalized=({food_x_normalized:.4f}, {food_y_normalized:.4f}), " + f"scaled=({food_x:.2f}, {food_y:.2f})" + ) + + return (food_x, food_y) + + +class TrackingCSVFormat(Enum): + """Supported tracking CSV formats.""" + + TRACKS_2D = "tracks_2d" # track_id, frame, x, y + TRACKS_3D = "tracks_3d" # track_id, frame, x, y, z (simple 3D tracks) + BBOX_2D = "bbox_2d" # track_id, frame, x1, y1, x2, y2, confidence, class + CENTROID_3D = "centroid_3d" # track_id, frame, x1, y1, x2, y2, confidence, class, u, v, x, y, z + UNKNOWN = "unknown" # Unsupported format (e.g., raw detections) + + +def detect_csv_format(df: pd.DataFrame) -> TrackingCSVFormat: + """ + Detect tracking CSV format based on column names. + + Args: + df: DataFrame with CSV data (can be just header row) + + Returns: + TrackingCSVFormat enum value + """ + cols = set(df.columns) + + # 3D centroids have world coordinates (x, y, z) and image coordinates (u, v) + if {"x", "y", "z", "u", "v"}.issubset(cols) and "track_id" in cols: + return TrackingCSVFormat.CENTROID_3D + + # 2D bboxes have corner coordinates + if {"x1", "y1", "x2", "y2", "track_id", "frame"}.issubset(cols): + return TrackingCSVFormat.BBOX_2D + + # Simple 3D tracks have centroid coordinates with z (check before 2D) + if {"x", "y", "z", "track_id", "frame"}.issubset(cols): + return TrackingCSVFormat.TRACKS_3D + + # Simple 2D tracks have centroid coordinates + if {"x", "y", "track_id", "frame"}.issubset(cols): + return TrackingCSVFormat.TRACKS_2D + + return TrackingCSVFormat.UNKNOWN + + +@dataclass +class SessionMetadata: + """Metadata for a simulation/tracking session.""" + + session_id: str + session_name: str + category_id: ( + str # 'boids_3d', 'boids_2d', 'tracking_csv' (references categories table) + ) + config: Dict[str, Any] + metadata: Optional[Dict[str, Any]] = None + + +@dataclass +class EpisodeMetadata: + """Metadata for a single episode.""" + + episode_id: str + session_id: str + episode_number: int + num_frames: int + num_agents: int + frame_rate: float + file_path: str + + +class DatabaseConnection: + """Unified database connection using SQLAlchemy.""" + + def __init__(self, config: DBConfig, native_bulk_insert: bool = False): + """Initialize database connection. + + Args: + config: Database configuration + native_bulk_insert: If True, use native bulk insert methods (COPY for + PostgreSQL, DataFrame registration for DuckDB) which are faster + but less portable. Default False for backward compatibility. + """ + self.config = config + self.engine: Optional[Engine] = None + self.native_bulk_insert = native_bulk_insert + + def connect(self): + """Establish database connection using SQLAlchemy.""" + url = self.config.sqlalchemy_url() + self.engine = create_engine(url, echo=False) + + # Test connection + with self.engine.connect() as conn: + conn.execute(text("SELECT 1")) + + if self.config.backend == "postgres": + logger.info(f"Connected to PostgreSQL: {self.config.postgres.dbname}") + else: + logger.info(f"Connected to DuckDB: {self.config.duckdb.dbpath}") + + def close(self): + """Close database connection.""" + if self.engine: + self.engine.dispose() + logger.info("Database connection closed") + + def transaction(self): + """ + Context manager for transaction handling. + + Usage: + with db.transaction() as conn: + # All operations here are in a single transaction + conn.execute(text("INSERT ...")) + conn.execute(text("INSERT ...")) + # Auto-commits on exit, rolls back on exception + + This is much faster for bulk operations as it commits only once. + """ + return self.engine.begin() + + def execute(self, query: str, params: Optional[Dict[str, Any]] = None, conn=None): + """Execute a query with named parameters. + + Args: + query: SQL query string + params: Named parameters for query + conn: Optional connection (for transactional usage) + """ + if conn is not None: + # Use provided connection (transactional mode - no auto-commit) + conn.execute(text(query), params or {}) + else: + # Create connection and auto-commit (non-transactional mode) + assert self.engine is not None + with self.engine.connect() as conn: + conn.execute(text(query), params or {}) + conn.commit() + + def fetch_one( + self, query: str, params: Optional[Dict[str, Any]] = None + ) -> Optional[tuple]: + """Fetch one result.""" + assert self.engine is not None + with self.engine.connect() as conn: + result = conn.execute(text(query), params or {}) + return result.fetchone() # type: ignore[return-value] + + def fetch_all( + self, query: str, params: Optional[Dict[str, Any]] = None + ) -> List[tuple]: + """Fetch all results.""" + assert self.engine is not None + with self.engine.connect() as conn: + result = conn.execute(text(query), params or {}) + return result.fetchall() # type: ignore[return-value] + + def insert_dataframe( + self, df: pd.DataFrame, table_name: str, if_exists: str = "append", conn=None + ): + """Insert DataFrame into database table. + + When native_bulk_insert=True (set in constructor), uses native bulk loading + for maximum performance: + - DuckDB: Native DataFrame registration + INSERT FROM SELECT + - PostgreSQL: COPY command via psycopg2 + + When native_bulk_insert=False (default), uses standard pandas to_sql with + multi-row INSERT for maximum compatibility. + + Args: + df: DataFrame to insert + table_name: Target table name + if_exists: What to do if table exists ('append', 'replace', 'fail') + conn: Optional connection (for transactional usage) + """ + from io import StringIO + + # Use standard pandas to_sql if native_bulk_insert is disabled + if not self.native_bulk_insert: + if conn is not None: + df.to_sql( + table_name, conn, if_exists=if_exists, index=False, method="multi" + ) + else: + df.to_sql( + table_name, + self.engine, + if_exists=if_exists, + index=False, + method="multi", + ) + return + + # Native bulk insert methods for maximum performance + assert self.engine is not None + engine_url = str(self.engine.url) + + if "duckdb" in engine_url: + # DuckDB: Use native DataFrame registration for ~10-50x speedup + if conn is not None: + raw_conn = conn.connection.dbapi_connection + else: + raw_conn = self.engine.raw_connection().dbapi_connection + + # Register DataFrame and insert directly + raw_conn.register("_temp_insert_df", df) + columns = ", ".join(f'"{c}"' for c in df.columns) + raw_conn.execute( + f"INSERT INTO {table_name} ({columns}) SELECT {columns} FROM _temp_insert_df" + ) + raw_conn.unregister("_temp_insert_df") + + elif "postgresql" in engine_url: + # PostgreSQL: Use COPY command for ~10-100x speedup + def _psql_copy_insert(table, conn_inner, keys, data_iter): + """Fast PostgreSQL insert using COPY command.""" + raw_conn = conn_inner.connection.dbapi_connection + buffer = StringIO() + for row in data_iter: + # Handle None values and convert to tab-separated + line = "\t".join("" if v is None else str(v) for v in row) + buffer.write(line + "\n") + buffer.seek(0) + + columns = ", ".join(f'"{k}"' for k in keys) + with raw_conn.cursor() as cursor: + cursor.copy_expert( + f"COPY {table.name} ({columns}) FROM STDIN WITH (FORMAT TEXT, NULL '')", + buffer, + ) + + if conn is not None: + df.to_sql( + table_name, + conn, + if_exists=if_exists, + index=False, + method=_psql_copy_insert, + ) + else: + df.to_sql( + table_name, + self.engine, + if_exists=if_exists, + index=False, + method=_psql_copy_insert, + ) + + else: + # Unknown backend: fallback to pandas to_sql + if conn is not None: + df.to_sql( + table_name, conn, if_exists=if_exists, index=False, method="multi" + ) + else: + df.to_sql( + table_name, + self.engine, + if_exists=if_exists, + index=False, + method="multi", + ) + + +class BaseDataLoader: + """Base class for data loaders.""" + + def __init__(self, db_conn: DatabaseConnection, max_episodes: float = np.inf): + self.db = db_conn + self.max_episodes = max_episodes + + def load_session(self, metadata: SessionMetadata, conn=None): + """Load session metadata into database. + + Args: + metadata: Session metadata + conn: Optional connection (for transactional usage) + """ + # Convert config and metadata to JSON strings (convert numpy/torch types first) + config_json = json.dumps(convert_to_json_serializable(metadata.config)) + metadata_json = ( + json.dumps(convert_to_json_serializable(metadata.metadata)) + if metadata.metadata + else None + ) + + query = """ + INSERT INTO sessions (session_id, session_name, category_id, config, metadata) + VALUES (:session_id, :session_name, :category_id, :config, :metadata) + """ + + self.db.execute( + query, + { + "session_id": metadata.session_id, + "session_name": metadata.session_name, + "category_id": metadata.category_id, + "config": config_json, + "metadata": metadata_json, + }, + conn=conn, + ) + logger.info(f"Loaded session: {metadata.session_id}") + + def load_episode(self, metadata: EpisodeMetadata, conn=None): + """Load episode metadata into database. + + Args: + metadata: Episode metadata + conn: Optional connection (for transactional usage) + """ + query = """ + INSERT INTO episodes (episode_id, session_id, episode_number, num_frames, num_agents, frame_rate, file_path) + VALUES (:episode_id, :session_id, :episode_number, :num_frames, :num_agents, :frame_rate, :file_path) + """ + + self.db.execute( + query, + { + "episode_id": metadata.episode_id, + "session_id": metadata.session_id, + "episode_number": metadata.episode_number, + "num_frames": metadata.num_frames, + "num_agents": metadata.num_agents, + "frame_rate": metadata.frame_rate, + "file_path": metadata.file_path, + }, + conn=conn, + ) + logger.info(f"Loaded episode: {metadata.episode_id}") + + def load_observations_batch( + self, observations: pd.DataFrame, episode_id: str, conn=None + ): + """Load observations in batch using pandas to_sql. + + Args: + observations: DataFrame with observation data + episode_id: Episode ID + conn: Optional connection (for transactional usage) + """ + # Ensure required columns exist + required_cols = ["time_index", "agent_id", "x", "y"] + for col in required_cols: + if col not in observations.columns: + raise ValueError(f"Missing required column: {col}") + + # Prepare DataFrame for insertion (optimized - work with copy to avoid side effects) + df = observations.copy() + + # Add episode_id column (use assign for efficiency) + df["episode_id"] = episode_id + + # Set default agent_type_id if missing + if "agent_type_id" not in df.columns: + df["agent_type_id"] = "agent" + + # Select only the columns we need in the correct order + # This avoids type conversions for columns that are already correct + col_order = [ + "episode_id", + "time_index", + "agent_id", + "agent_type_id", + "x", + "y", + "z", + "v_x", + "v_y", + "v_z", + ] + existing_cols = [c for c in col_order if c in df.columns] + df = df[existing_cols] + + # Use pandas to_sql for fast bulk insert + self.db.insert_dataframe(df, "observations", if_exists="append", conn=conn) + logger.info(f"Loaded {len(df)} observations for episode {episode_id}") + + def load_extended_properties_batch( + self, episode_id: str, property_data: Dict[str, pd.Series], conn=None + ): + """ + Load extended properties in batch. + + Args: + episode_id: Episode identifier + property_data: Dict mapping property_id to Series with values + Series index should match observations (time_index, agent_id) + conn: Optional connection (for transactional usage) + """ + # Get observation IDs for this episode + # Optimize: try simple 2-tuple mapping first (fastest path for 90% of episodes) + # IMPORTANT: Use the same connection to see uncommitted inserts in the transaction + query = """ + SELECT observation_id, time_index, agent_id + FROM observations + WHERE episode_id = :episode_id + ORDER BY time_index, agent_id + """ + + if conn is not None: + # Use transactional connection + result = conn.execute(text(query), {"episode_id": episode_id}) + obs_rows = result.fetchall() + else: + # Use non-transactional connection + obs_rows = self.db.fetch_all(query, {"episode_id": episode_id}) + + # Build simple 2-tuple mapping - works for most cases + obs_id_map: Dict[Any, Any] = {} + has_collision = False + for row in obs_rows: + key = (row[1], row[2]) # (time_index, agent_id) + if key in obs_id_map: + # Collision detected - need to use 3-tuple mapping + has_collision = True + break + obs_id_map[key] = row[0] + + # If collision detected, rebuild with 3-tuple mapping + if has_collision: + logger.info( + f"Multiple agent types detected for episode {episode_id}, using 3-tuple mapping" + ) + query_3tuple = """ + SELECT observation_id, time_index, agent_id, agent_type_id + FROM observations + WHERE episode_id = :episode_id + ORDER BY time_index, agent_id, agent_type_id + """ + if conn is not None: + result = conn.execute(text(query_3tuple), {"episode_id": episode_id}) + obs_rows = result.fetchall() + else: + obs_rows = self.db.fetch_all(query_3tuple, {"episode_id": episode_id}) + + obs_id_map = {(row[1], row[2], row[3]): row[0] for row in obs_rows} + # Also create 2-tuple fallback for 'agent' type (property data uses 2-tuples) + obs_id_map_2tuple = { + (row[1], row[2]): row[0] for row in obs_rows if row[3] == "agent" + } + else: + obs_id_map_2tuple = None + + # Prepare data for batch insert + records = [] + total_property_values = sum(len(v) for v in property_data.values()) + logger.info( + f"Processing {len(property_data)} properties with {total_property_values} total values" + ) + + for property_id, values in property_data.items(): + property_records = 0 + for idx, value in values.items(): + # Determine observation_id based on index structure + if isinstance(idx, tuple): + if len(idx) == 2: + # Try 2-tuple mapping (most common) + obs_id = ( + obs_id_map_2tuple.get(idx) + if obs_id_map_2tuple is not None + else obs_id_map.get(idx) + ) + elif len(idx) == 3 and has_collision: + # Try 3-tuple mapping + obs_id = obs_id_map.get(idx) + else: + obs_id = None + else: + obs_id = None + + if obs_id is None: + logger.warning(f"No observation found for index {idx}") + continue + + if pd.notna(value): + records.append( + { + "observation_id": obs_id, + "property_id": property_id, + "value_float": float(value) + if isinstance(value, (int, float)) + else None, + "value_text": str(value) + if not isinstance(value, (int, float)) + else None, + } + ) + property_records += 1 + + logger.info( + f"Property '{property_id}': created {property_records} records from {len(values)} values" + ) + + if not records: + logger.info(f"No extended properties to load for episode {episode_id}") + return + + # Use pandas to_sql for fast bulk insert + df = pd.DataFrame(records) + self.db.insert_dataframe( + df, "extended_properties", if_exists="append", conn=conn + ) + logger.info( + f"Loaded {len(records)} extended property values for episode {episode_id}" + ) + + +class Boids3DLoader(BaseDataLoader): + """Loader for 3D boids simulation data from parquet files.""" + + def load_simulations_bulk(self, parent_dir: Path): + """ + Load multiple simulations from a parent directory. + + Args: + parent_dir: Directory containing multiple simulation subdirectories + """ + # Discover all simulation directories (those with config.yaml) + simulation_dirs = [] + for subdir in sorted(parent_dir.iterdir()): + if subdir.is_dir() and (subdir / "config.yaml").exists(): + simulation_dirs.append(subdir) + + if not simulation_dirs: + raise ValueError(f"No simulation directories found in {parent_dir}") + + logger.info( + f"Found {len(simulation_dirs)} simulation directories in {parent_dir}" + ) + logger.info("Loading all simulations in single transaction...") + + # Load all simulations in one transaction for maximum performance + with self.db.transaction() as conn: + for idx, sim_dir in enumerate(simulation_dirs, 1): + logger.info(f"[{idx}/{len(simulation_dirs)}] Loading {sim_dir.name}...") + self._load_simulation_no_transaction(sim_dir, conn=conn) + + logger.info(f"Completed loading {len(simulation_dirs)} simulations") + + def _load_simulation_no_transaction(self, simulation_dir: Path, conn=None): + """Internal method to load a simulation without starting a transaction. + + Args: + simulation_dir: Path to simulation directory + conn: Optional connection (for transactional usage) + """ + logger.info(f"Loading 3D boids simulation from: {simulation_dir}") + + # Load config + config_path = simulation_dir / "config.yaml" + if not config_path.exists(): + raise FileNotFoundError(f"Config file not found: {config_path}") + + with open(config_path, "r") as f: + config = yaml.safe_load(f) + + # Create session metadata + session_id = f"session-{simulation_dir.name}" + session_metadata = SessionMetadata( + session_id=session_id, + session_name=simulation_dir.name, + category_id="boids_3d", + config=config, + metadata={"simulation_dir": str(simulation_dir), "loader": "Boids3DLoader"}, + ) + + self.load_session(session_metadata, conn=conn) + + # Load each episode + episode_files = sorted(simulation_dir.glob("episode-*.parquet")) + logger.info( + f"Loading up to {min(len(episode_files), self.max_episodes)} episodes..." + ) + + episodes_loaded = 0 + for episode_num, episode_file in enumerate(episode_files): + if episode_num >= self.max_episodes: + logger.info( + f"Reached maximum number of episodes ({self.max_episodes}) for session {session_id}, stopping..." + ) + break + logger.info( + f"[{episode_num + 1}/{len(episode_files)}] Loading episode {episode_num} from: {episode_file}" + ) + self.load_episode_file( + session_id, episode_num, episode_file, config, conn=conn + ) + episodes_loaded += 1 + + logger.info( + f"Completed loading simulation: {session_id} ({episodes_loaded} out of {len(episode_files)} episodes)" + ) + + def load_simulation(self, simulation_dir: Path): + """ + Load a complete 3D boids simulation. + + Args: + simulation_dir: Directory containing config.yaml and episode-*.parquet files + """ + logger.info(f"Loading 3D boids simulation from: {simulation_dir}") + + # Load config + config_path = simulation_dir / "config.yaml" + if not config_path.exists(): + raise FileNotFoundError(f"Config file not found: {config_path}") + + with open(config_path, "r") as f: + config = yaml.safe_load(f) + + # Create session metadata + session_id = f"session-{simulation_dir.name}" + session_metadata = SessionMetadata( + session_id=session_id, + session_name=simulation_dir.name, + category_id="boids_3d", + config=config, + metadata={"simulation_dir": str(simulation_dir), "loader": "Boids3DLoader"}, + ) + + # Load all data in a single transaction for performance + episode_files = sorted(simulation_dir.glob("episode-*.parquet")) + logger.info( + f"Loading up to {min(len(episode_files), self.max_episodes)} episodes in single transaction..." + ) + + with self.db.transaction() as conn: + self.load_session(session_metadata, conn=conn) + + # Load each episode + episodes_loaded = 0 + for episode_num, episode_file in enumerate(episode_files): + if episode_num >= self.max_episodes: + logger.info( + f"Reached maximum number of episodes ({self.max_episodes}) for session {session_id}, stopping..." + ) + break + logger.info( + f"[{episode_num + 1}/{len(episode_files)}] Loading episode {episode_num} from: {episode_file}" + ) + self.load_episode_file( + session_id, episode_num, episode_file, config, conn=conn + ) + episodes_loaded += 1 + + logger.info( + f"Completed loading simulation: {session_id} ({episodes_loaded} out of {len(episode_files)} episodes)" + ) + + def load_episode_file( + self, + session_id: str, + episode_number: int, + file_path: Path, + config: Dict[str, Any], + conn=None, + ): + """Load a single episode parquet file. + + Args: + session_id: Session ID + episode_number: Episode number + file_path: Path to parquet file + config: Configuration dictionary + conn: Optional connection (for transactional usage) + """ + logger.info(f"Loading episode {episode_number} from: {file_path}") + + # Read parquet file + df = pd.read_parquet(file_path) + + # Log entity types (includes both agents and environment entities) + if "type" in df.columns: + logger.info( + f"Row count: {len(df)}, Types: {df['type'].value_counts().to_dict()}" + ) + + # Extract metadata (convert numpy types to native Python types) + num_frames = int(df["time"].max() + 1) + num_agents = int(df["id"].nunique()) + frame_rate = float(config.get("frame_rate", 30.0)) + + episode_id = f"episode-{episode_number}-{file_path.stem}" + + episode_metadata = EpisodeMetadata( + episode_id=episode_id, + session_id=session_id, + episode_number=episode_number, + num_frames=num_frames, + num_agents=num_agents, + frame_rate=frame_rate, + file_path=str(file_path), + ) + + self.load_episode(episode_metadata, conn=conn) + + # Prepare observations DataFrame + observations = pd.DataFrame( + { + "time_index": df["time"], + "agent_id": df["id"], + "agent_type_id": df["type"], + "x": df["x"], + "y": df["y"], + "z": df["z"], + "v_x": df["v_x"], + "v_y": df["v_y"], + "v_z": df["v_z"], + } + ) + + self.load_observations_batch(observations, episode_id, conn=conn) + + # Load extended properties if they exist + # IMPORTANT: Only load extended properties for 'agent' type observations + # Environment entities ('env' type) don't have extended properties and create + # index collisions when they share agent_ids with actual agents + import numpy as np + + extended_props = {} + + # Filter DataFrame to only include 'agent' type rows for extended properties + agent_df = df[df["type"] == "agent"].copy() + + # Map actual parquet column names to property IDs + # Distance to target center (may have suffix like _1, and may or may not have '_to_') + target_center_cols = [ + c + for c in agent_df.columns + if c.startswith("distance_target_center") + or c.startswith("distance_to_target_center") + ] + if target_center_cols: + extended_props["distance_to_target_center"] = agent_df.set_index( + ["time", "id"] + )[target_center_cols[0]] + + # Distance to target mesh (may have suffix like _1) + target_mesh_cols = [ + c for c in agent_df.columns if "distance_to_target_mesh" in c + ] + if target_mesh_cols: + extended_props["distance_to_target_mesh"] = agent_df.set_index( + ["time", "id"] + )[target_mesh_cols[0]] + + # Distance to scene mesh + if "mesh_scene_distance" in agent_df.columns: + extended_props["distance_to_scene_mesh"] = agent_df.set_index( + ["time", "id"] + )["mesh_scene_distance"] + + # Handle array-type closest point columns + # Target mesh closest point (stored as array [x, y, z]) + # Match columns like 'target_mesh_closest_point_1' but NOT 'distance_to_target_mesh_closest_point_1' + target_closest_cols = [ + c + for c in agent_df.columns + if "target_mesh_closest_point" in c and not c.startswith("distance") + ] + if target_closest_cols: + # Extract array column and filter out None values + arr_col = agent_df[target_closest_cols[0]] + # Create mask for non-None values + mask = arr_col.notna() + filtered_df = agent_df[mask] + filtered_arr_col = arr_col[mask] + + if len(filtered_arr_col) > 0: + # Stack arrays into 2D numpy array + logger.info( + f"Before stack: filtered_arr_col length={len(filtered_arr_col)}, first element type={type(filtered_arr_col.iloc[0])}" + ) + coords_array = np.stack(filtered_arr_col.to_numpy()) + logger.info( + f"After stack: coords_array shape={coords_array.shape}, dtype={coords_array.dtype}" + ) + + # Create Series for each coordinate with (time, id) multi-index (only for non-None values) + idx = pd.MultiIndex.from_arrays( + [filtered_df["time"], filtered_df["id"]] + ) + for i, suffix in enumerate(["x", "y", "z"]): + prop_id = f"target_mesh_closest_{suffix}" + extended_props[prop_id] = pd.Series(coords_array[:, i], index=idx) + + # Scene mesh closest point (stored as array [x, y, z]) + if "mesh_scene_closest_point" in agent_df.columns: + # Extract array column and filter out None values + arr_col = agent_df["mesh_scene_closest_point"] + # Create mask for non-None values + mask = arr_col.notna() + filtered_df = agent_df[mask] + filtered_arr_col = arr_col[mask] + + if len(filtered_arr_col) > 0: + # Stack arrays into 2D numpy array + coords_array = np.stack(filtered_arr_col.to_numpy()) + + # Create Series for each coordinate with (time, id) multi-index (only for non-None values) + idx = pd.MultiIndex.from_arrays( + [filtered_df["time"], filtered_df["id"]] + ) + for i, suffix in enumerate(["x", "y", "z"]): + prop_id = f"scene_mesh_closest_{suffix}" + extended_props[prop_id] = pd.Series(coords_array[:, i], index=idx) + + if extended_props: + logger.info( + f"Loading {len(extended_props)} extended properties for episode {episode_id}" + ) + self.load_extended_properties_batch(episode_id, extended_props, conn=conn) + + +class Boids2DLoader(BaseDataLoader): + """Loader for 2D boids simulation data from PyTorch .pt files.""" + + def load_datasets_bulk(self, parent_dir: Path): + """ + Load multiple 2D boids datasets from a parent directory. + + Args: + parent_dir: Directory containing multiple .pt dataset files + """ + # Discover all .pt files (excluding *_config.pt) + dataset_files = [] + for pt_file in sorted(parent_dir.glob("*.pt")): + if not pt_file.name.endswith("_config.pt"): + dataset_files.append(pt_file) + + if not dataset_files: + raise ValueError(f"No .pt dataset files found in {parent_dir}") + + logger.info(f"Found {len(dataset_files)} dataset files in {parent_dir}") + logger.info("Loading all datasets in single transaction...") + + # Load all datasets in one transaction for maximum performance + with self.db.transaction() as conn: + for idx, data_file in enumerate(dataset_files, 1): + logger.info(f"[{idx}/{len(dataset_files)}] Loading {data_file.name}...") + self._load_dataset_no_transaction(data_file, conn=conn) + + logger.info(f"Completed loading {len(dataset_files)} datasets") + + def _load_dataset_no_transaction(self, data_path: Path, conn=None): + """Internal method to load a dataset without starting a transaction. + + Args: + data_path: Path to .pt file + conn: Optional connection (for transactional usage) + """ + logger.info(f"Loading 2D boids dataset from: {data_path}") + + # Validate file exists + if not data_path.exists(): + raise FileNotFoundError(f"Data file not found: {data_path}") + + # Construct config file path + basename = data_path.stem + config_path = data_path.parent / f"{basename}_config.pt" + + # Load config (may not exist for all datasets) + config = {} + if config_path.exists(): + logger.info(f"Loading config from: {config_path}") + config = torch.load(config_path, weights_only=False) + else: + logger.warning(f"Config file not found: {config_path}, using defaults") + + # Load dataset + logger.info(f"Loading PyTorch dataset from: {data_path}") + dataset = torch.load(data_path, weights_only=False) + + logger.info(f"Dataset loaded: {len(dataset)} samples") + + # Extract scene size from config + scene_size = config.get("scene_size", 480.0) + if not isinstance(scene_size, (int, float)): + scene_size = 480.0 + + num_samples = np.minimum(len(dataset), self.max_episodes) + # Create session metadata + session_id = f"session-2d-{basename}" + session_metadata = SessionMetadata( + session_id=session_id, + session_name=basename, + category_id="boids_2d", + config=config, + metadata={ + "data_file": str(data_path), + "config_file": str(config_path) if config_path.exists() else None, + "num_samples": num_samples, + "scene_size": scene_size, + "loader": "Boids2DLoader", + }, + ) + + self.load_session(session_metadata, conn=conn) + + # Load each sample as an episode + logger.info(f"Loading up to {min(len(dataset), self.max_episodes)} episodes...") + episodes_loaded = 0 + for sample_idx in range(len(dataset)): + if sample_idx >= self.max_episodes: + logger.info( + f"Reached maximum number of episodes ({self.max_episodes}) for session {session_id}, stopping..." + ) + break + logger.info( + f"[{sample_idx + 1}/{len(dataset)}] Loading sample {sample_idx}" + ) + self.load_sample( + session_id, + sample_idx, + dataset[sample_idx], + config, + scene_size, + conn=conn, + ) + episodes_loaded += 1 + + logger.info( + f"Completed loading dataset: {session_id} ({episodes_loaded} out of {len(dataset)} episodes)" + ) + + def load_dataset(self, data_path: Path): + """ + Load a complete 2D boids dataset. + + Args: + data_path: Path to .pt file (e.g., boid_single_species_basic.pt) + """ + logger.info(f"Loading 2D boids dataset from: {data_path}") + + # Validate file exists + if not data_path.exists(): + raise FileNotFoundError(f"Data file not found: {data_path}") + + # Construct config file path + # Config files follow pattern: {basename}_config.pt + basename = data_path.stem # e.g., "boid_single_species_basic" + config_path = data_path.parent / f"{basename}_config.pt" + + # Load config (may not exist for all datasets) + config = {} + if config_path.exists(): + logger.info(f"Loading config from: {config_path}") + config = torch.load(config_path, weights_only=False) + else: + logger.warning(f"Config file not found: {config_path}, using defaults") + + # Load dataset + logger.info(f"Loading PyTorch dataset from: {data_path}") + dataset = torch.load(data_path, weights_only=False) + + logger.info(f"Dataset loaded: {len(dataset)} samples") + + # Extract scene size from config + scene_size = config.get("scene_size", 480.0) + if not isinstance(scene_size, (int, float)): + # If scene_size is not in top level, try to infer from species config + scene_size = 480.0 # Default value + + num_samples = np.minimum(len(dataset), self.max_episodes) + + # Create session metadata + session_id = f"session-2d-{basename}" + session_metadata = SessionMetadata( + session_id=session_id, + session_name=basename, + category_id="boids_2d", + config=config, + metadata={ + "data_file": str(data_path), + "config_file": str(config_path) if config_path.exists() else None, + "num_samples": num_samples, + "scene_size": scene_size, + "loader": "Boids2DLoader", + }, + ) + + # Load all data in a single transaction for performance + logger.info( + f"Loading up to {num_samples} out of {len(dataset)} episodes in single transaction..." + ) + + with self.db.transaction() as conn: + self.load_session(session_metadata, conn=conn) + + # Load each sample as an episode + episodes_loaded = 0 + for sample_idx in range(len(dataset)): + if sample_idx >= self.max_episodes: + logger.info( + f"Reached maximum number of episodes ({self.max_episodes}) for session {session_id}, stopping..." + ) + break + logger.info( + f"[{sample_idx + 1}/{len(dataset)}] Loading sample {sample_idx}" + ) + self.load_sample( + session_id, + sample_idx, + dataset[sample_idx], + config, + scene_size, + conn=conn, + ) + episodes_loaded += 1 + + logger.info( + f"Completed loading dataset: {session_id} ({episodes_loaded} out of {len(dataset)} episodes)" + ) + + def load_sample( + self, + session_id: str, + sample_idx: int, + sample: tuple, + config: Dict[str, Any], + scene_size: float, + conn=None, + ): + """ + Load a single sample (trajectory) from the dataset. + + Args: + session_id: Session identifier + sample_idx: Sample index in dataset + sample: Tuple of (positions, species) + config: Configuration dictionary + scene_size: Scene size in pixels + conn: Optional connection (for transactional usage) + """ + logger.info(f"Loading sample {sample_idx}") + + positions, species = sample + + # positions: [timesteps, num_agents, 2] + # species: [num_agents] + + # Convert to numpy for easier manipulation + import numpy as np + + positions_np = positions.numpy() + + num_timesteps, num_agents, num_dims = positions_np.shape + assert num_dims == 2, f"Expected 2D positions, got {num_dims}D" + + # Compute velocities: v[t] = p[t+1] - p[t] + # Shape: [timesteps-1, num_agents, 2] + velocities_np = np.diff(positions_np, axis=0) + + # For last timestep, use velocity from previous timestep + # This maintains consistent timestep count + last_velocity = velocities_np[-1:, :, :] + velocities_np = np.vstack([velocities_np, last_velocity]) + + assert velocities_np.shape[0] == num_timesteps, ( + f"Velocity timesteps mismatch: {velocities_np.shape[0]} != {num_timesteps}" + ) + + # Assume frame rate of 1.0 for 2D boids (discrete timesteps) + # This can be overridden if specified in config + frame_rate = config.get("frame_rate", 1.0) + + # Create episode ID + episode_id = f"episode-{sample_idx:04d}-{session_id}" + + episode_metadata = EpisodeMetadata( + episode_id=episode_id, + session_id=session_id, + episode_number=sample_idx, + num_frames=num_timesteps, + num_agents=num_agents, + frame_rate=frame_rate, + file_path=f"sample-{sample_idx}", + ) + + self.load_episode(episode_metadata, conn=conn) + + # Prepare observations DataFrame using vectorized numpy operations (MUCH faster) + # Total rows = num_timesteps * num_agents + total_rows = num_timesteps * num_agents + + logger.info(f"Total rows: {total_rows}") + + # Create index arrays using numpy broadcasting + # time_index: [0,0,0,...,1,1,1,...,2,2,2,...] (repeat each timestep num_agents times) + time_indices = np.repeat(np.arange(num_timesteps), num_agents) + + # agent_id: [0,1,2,...,0,1,2,...,0,1,2,...] (tile agent IDs num_timesteps times) + agent_ids = np.tile(np.arange(num_agents), num_timesteps) + + # Scale and flatten position/velocity arrays + # positions_np: [timesteps, agents, 2] -> reshape to [timesteps*agents, 2] + positions_flat = positions_np.reshape(-1, 2) * scene_size + velocities_flat = velocities_np.reshape(-1, 2) * scene_size + + # Create DataFrame directly from numpy arrays (100x faster than list of dicts) + observations = pd.DataFrame( + { + "time_index": time_indices, + "agent_id": agent_ids, + "agent_type_id": "agent", # Same for all rows + "x": positions_flat[:, 0], + "y": positions_flat[:, 1], + "z": None, # No z-coordinate for 2D boids + "v_x": velocities_flat[:, 0], + "v_y": velocities_flat[:, 1], + "v_z": None, # No z-velocity for 2D boids + } + ) + + self.load_observations_batch(observations, episode_id, conn=conn) + + # Compute extended properties: distance to food (if food is present) + extended_props = {} + food_location = get_food_location_from_config(config, scene_size) + + if food_location is not None: + food_x, food_y = food_location + + # Compute distance to food for each boid at each timestep + # Distance = sqrt((boid_x - food_x)^2 + (boid_y - food_y)^2) + # + # Note: Food agent itself (last agent if species[-1] == 1) gets distance 0 + # but we compute for all agents for simplicity + + dx = positions_flat[:, 0] - food_x + dy = positions_flat[:, 1] - food_y + distances = np.sqrt(dx**2 + dy**2) + + # Create multi-index for extended properties + idx = pd.MultiIndex.from_arrays([time_indices, agent_ids]) + extended_props["distance_to_food"] = pd.Series(distances, index=idx) + + logger.info(f"Computed distance_to_food for {len(distances)} observations") + + if extended_props: + self.load_extended_properties_batch(episode_id, extended_props, conn=conn) + + logger.info( + f"Loaded sample {sample_idx}: {num_timesteps} frames, {num_agents} agents" + ) + + +class TrackingCSVLoader(BaseDataLoader): + """Loader for real-world tracking CSV data from processed_tracks. + + Supports multiple CSV formats: + - 2D tracks: track_id, frame, x, y + - 2D bounding boxes: track_id, frame, x1, y1, x2, y2, confidence, class + - 3D centroids: track_id, frame, x1, y1, x2, y2, confidence, class, u, v, x, y, z + (creates two episodes: one with 3D world coords, one with 2D image coords) + """ + + def _discover_tracking_csvs( + self, camera_dir: Path + ) -> List[Tuple[Path, TrackingCSVFormat]]: + """ + Find all tracking CSVs in camera_dir with their formats. + + Args: + camera_dir: Directory to search for CSV files + + Returns: + List of (csv_path, format) tuples, sorted by filename + """ + results = [] + for csv_path in camera_dir.glob("*.csv"): + try: + # Read just the header to detect format + df_header = pd.read_csv(csv_path, nrows=0) + fmt = detect_csv_format(df_header) + if fmt != TrackingCSVFormat.UNKNOWN: + results.append((csv_path, fmt)) + else: + logger.debug(f"Skipping unsupported CSV format: {csv_path.name}") + except Exception as e: + logger.warning(f"Error reading CSV header {csv_path}: {e}") + return sorted(results, key=lambda x: x[0].name) + + def _normalize_bbox_to_centroid(self, df: pd.DataFrame) -> pd.DataFrame: + """ + Convert bounding box format to centroid format. + + Args: + df: DataFrame with x1, y1, x2, y2 columns + + Returns: + DataFrame with track_id, frame, x, y columns + """ + return pd.DataFrame( + { + "track_id": df["track_id"], + "frame": df["frame"], + "x": (df["x1"] + df["x2"]) / 2, + "y": (df["y1"] + df["y2"]) / 2, + } + ) + + def _compute_velocities( + self, df: pd.DataFrame, frame_rate: float = 30.0, has_z: bool = False + ) -> pd.DataFrame: + """ + Compute velocities from position data. + + Args: + df: DataFrame with track_id, frame, x, y (and optionally z) columns + frame_rate: Frame rate for velocity computation + has_z: Whether to compute z velocity + + Returns: + DataFrame with v_x, v_y (and optionally v_z) columns added + """ + # Sort by track_id and frame for proper diff() calculation + df = df.sort_values(["track_id", "frame"]).reset_index(drop=True) + + # Compute position and frame differences using groupby (vectorized) + df["dx"] = df.groupby("track_id")["x"].diff() + df["dy"] = df.groupby("track_id")["y"].diff() + df["frame_diff"] = df.groupby("track_id")["frame"].diff() + + if has_z and "z" in df.columns: + df["dz"] = df.groupby("track_id")["z"].diff() + + # Compute time delta: dt = frame_diff / frame_rate (seconds) + df["dt"] = df["frame_diff"] / frame_rate + + # Compute velocities: v = dx / dt + df["v_x"] = df["dx"] / df["dt"] + df["v_y"] = df["dy"] / df["dt"] + if has_z and "z" in df.columns: + df["v_z"] = df["dz"] / df["dt"] + + # Set velocity to NaN when there are frame gaps + gap_mask = df["frame_diff"] > 1 + velocity_cols = ["v_x", "v_y"] + ( + ["v_z"] if has_z and "z" in df.columns else [] + ) + df.loc[gap_mask, velocity_cols] = np.nan + + # For first frame of each track, set velocity to 0.0 + first_frame_mask = df["frame_diff"].isna() + df.loc[first_frame_mask, velocity_cols] = 0.0 + + # Drop temporary columns + temp_cols = ["dx", "dy", "frame_diff", "dt"] + if has_z and "dz" in df.columns: + temp_cols.append("dz") + df = df.drop(columns=temp_cols) + + return df + + def _load_episode_from_df( + self, + session_id: str, + episode_number: int, + episode_name: str, + df: pd.DataFrame, + csv_path: Path, + has_z: bool = False, + frame_rate: float = 30.0, + conn=None, + ): + """ + Load episode from a normalized DataFrame. + + Args: + session_id: Session identifier + episode_number: Episode number within session + episode_name: Episode name + df: DataFrame with track_id, frame, x, y (and optionally z) columns + csv_path: Original CSV path (for metadata) + has_z: Whether data has z coordinate + frame_rate: Frame rate for velocity computation + conn: Optional connection + """ + logger.info(f"Loading episode {episode_name} from: {csv_path}") + + # Compute velocities + df = self._compute_velocities(df, frame_rate=frame_rate, has_z=has_z) + + # Extract metadata + num_frames = int(df["frame"].max() + 1) + num_agents = int(df["track_id"].nunique()) + + episode_id = f"episode-{episode_name}-{session_id}" + + episode_metadata = EpisodeMetadata( + episode_id=episode_id, + session_id=session_id, + episode_number=episode_number, + num_frames=num_frames, + num_agents=num_agents, + frame_rate=frame_rate, + file_path=str(csv_path), + ) + + self.load_episode(episode_metadata, conn=conn) + + # Prepare observations DataFrame + observations = pd.DataFrame( + { + "time_index": df["frame"], + "agent_id": df["track_id"], + "agent_type_id": "agent", + "x": df["x"], + "y": df["y"], + "z": df["z"] if has_z and "z" in df.columns else None, + "v_x": df["v_x"], + "v_y": df["v_y"], + "v_z": df["v_z"] if has_z and "v_z" in df.columns else None, + } + ) + + self.load_observations_batch(observations, episode_id, conn=conn) + + logger.info( + f"Loaded episode {episode_name}: {num_frames} frames, {num_agents} tracks, {len(df)} observations" + ) + + def _load_3d_centroid_episodes( + self, + session_id: str, + episode_number: int, + camera_name: str, + csv_path: Path, + conn=None, + ) -> int: + """ + Load 3D centroid CSV as two episodes: 3D world coords and 2D image coords. + + Args: + session_id: Session identifier + episode_number: Starting episode number + camera_name: Camera directory name + csv_path: Path to CSV file + conn: Optional connection + + Returns: + Number of episodes created (2) + """ + logger.info(f"Loading 3D centroid CSV: {csv_path}") + + df = pd.read_csv(csv_path) + csv_stem = csv_path.stem + + # Episode 1: 3D world coordinates (x, y, z) + # Filter out rows where 3D triangulation failed (x, y, z are NaN) + df_3d_raw = df[df["x"].notna() & df["y"].notna() & df["z"].notna()] + if len(df_3d_raw) < len(df): + logger.info( + f"Filtered {len(df) - len(df_3d_raw)} rows with null 3D coordinates" + ) + + df_3d = pd.DataFrame( + { + "track_id": df_3d_raw["track_id"], + "frame": df_3d_raw["frame"], + "x": df_3d_raw["x"], + "y": df_3d_raw["y"], + "z": df_3d_raw["z"], + } + ) + episode_name_3d = f"{camera_name}_{csv_stem}_3d" + self._load_episode_from_df( + session_id, + episode_number, + episode_name_3d, + df_3d, + csv_path, + has_z=True, + conn=conn, + ) + + # Episode 2: 2D image coordinates (u, v as x, y) + # u, v should always be present (2D detection succeeded) + df_2d = pd.DataFrame( + { + "track_id": df["track_id"], + "frame": df["frame"], + "x": df["u"], + "y": df["v"], + } + ) + episode_name_2d = f"{camera_name}_{csv_stem}_2d" + self._load_episode_from_df( + session_id, + episode_number + 1, + episode_name_2d, + df_2d, + csv_path, + has_z=False, + conn=conn, + ) + + return 2 # Number of episodes created + + def load_sessions_bulk(self, parent_dir: Path): + """ + Load multiple tracking sessions from a parent directory. + + Args: + parent_dir: Directory containing multiple session subdirectories + (e.g., data/processed_tracks/) + """ + # Discover all session directories (those with aligned_frames/) + session_dirs = [] + for subdir in sorted(parent_dir.iterdir()): + if subdir.is_dir() and (subdir / "aligned_frames").exists(): + session_dirs.append(subdir) + + if not session_dirs: + raise ValueError(f"No session directories found in {parent_dir}") + + logger.info(f"Found {len(session_dirs)} session directories in {parent_dir}") + logger.info("Loading all sessions in single transaction...") + + # Load all sessions in one transaction for maximum performance + with self.db.transaction() as conn: + for idx, session_dir in enumerate(session_dirs, 1): + logger.info( + f"[{idx}/{len(session_dirs)}] Loading {session_dir.name}..." + ) + self._load_session_no_transaction(session_dir, conn) + + logger.info(f"Completed loading {len(session_dirs)} sessions") + + def _load_session_no_transaction(self, session_dir: Path, conn=None): + """Internal method to load a session without starting a transaction. + + Args: + session_dir: Directory containing aligned_frames/ subdirectory + conn: Optional connection (for transactional usage) + """ + logger.info(f"Loading tracking session from: {session_dir}") + + # Load optional Metadata.yaml if exists + metadata_path = session_dir / "Metadata.yaml" + config = {} + if metadata_path.exists(): + logger.info(f"Loading metadata from: {metadata_path}") + with open(metadata_path, "r") as f: + config = yaml.safe_load(f) + + # Create session metadata + session_id = session_dir.name # e.g., "2024_06_01-session_0003" + session_metadata = SessionMetadata( + session_id=session_id, + session_name=session_dir.name, + category_id="tracking_csv", + config=config, + metadata={"session_dir": str(session_dir), "loader": "TrackingCSVLoader"}, + ) + + self.load_session(session_metadata, conn=conn) + + # Discover all camera directories in aligned_frames/ + aligned_frames = session_dir / "aligned_frames" + camera_dirs = sorted( + [ + d + for d in aligned_frames.iterdir() + if d.is_dir() and not d.name.startswith(".") + ] + ) + + # Discover all CSVs across all camera directories + all_csvs: List[ + Tuple[Path, Path, TrackingCSVFormat] + ] = [] # (camera_dir, csv_path, format) + for camera_dir in camera_dirs: + csv_files = self._discover_tracking_csvs(camera_dir) + for csv_path, csv_format in csv_files: + all_csvs.append((camera_dir, csv_path, csv_format)) + + if not all_csvs: + logger.warning(f"No tracking CSV files found in {aligned_frames}") + return + + # Count potential episodes (CENTROID_3D creates 2 episodes per CSV) + total_potential = sum( + 2 if fmt == TrackingCSVFormat.CENTROID_3D else 1 for _, _, fmt in all_csvs + ) + logger.info( + f"Found {len(all_csvs)} CSV files, {total_potential} potential episodes" + ) + logger.info( + f"Loading up to {min(total_potential, self.max_episodes)} episodes..." + ) + + episodes_loaded = 0 + episode_number = 0 + + for camera_dir, csv_path, csv_format in all_csvs: + if episodes_loaded >= self.max_episodes: + logger.info( + f"Reached maximum number of episodes ({self.max_episodes}) for session {session_id}, stopping..." + ) + break + + camera_name = camera_dir.name + + if csv_format == TrackingCSVFormat.CENTROID_3D: + # Check if we have room for 2 episodes + if episodes_loaded + 2 > self.max_episodes: + logger.info( + f"Skipping 3D centroid CSV (would exceed max_episodes): {csv_path.name}" + ) + continue + # Creates 2 episodes: 3D and 2D + num_created = self._load_3d_centroid_episodes( + session_id, episode_number, camera_name, csv_path, conn=conn + ) + episodes_loaded += num_created + episode_number += num_created + else: + # TRACKS_2D or BBOX_2D: creates 1 episode + episode_name = f"{camera_name}_{csv_path.stem}" + self.load_episode_csv( + session_id, + episode_number, + episode_name, + csv_path, + csv_format=csv_format, + conn=conn, + ) + episodes_loaded += 1 + episode_number += 1 + + logger.info( + f"Completed loading session: {session_id} ({episodes_loaded} episodes from {len(all_csvs)} CSV files)" + ) + + def load_tracking_session(self, session_dir: Path): + """ + Load a single tracking session. + + Args: + session_dir: Directory containing aligned_frames/ subdirectory + """ + logger.info(f"Loading tracking session from: {session_dir}") + + # Validate structure + aligned_frames = session_dir / "aligned_frames" + if not aligned_frames.exists(): + raise FileNotFoundError(f"aligned_frames not found in {session_dir}") + + # Load in single transaction + with self.db.transaction() as conn: + self._load_session_no_transaction(session_dir, conn) + + logger.info(f"Completed loading session: {session_dir.name}") + + def load_episode_csv( + self, + session_id: str, + episode_number: int, + episode_name: str, + csv_path: Path, + csv_format: Optional[TrackingCSVFormat] = None, + conn=None, + ): + """Load a single camera's tracking CSV file (2D/3D tracks or bounding boxes). + + Args: + session_id: Session identifier + episode_number: Episode number within session + episode_name: Episode name (camera name) + csv_path: Path to CSV file + csv_format: CSV format (auto-detected if None) + conn: Optional connection (for transactional usage) + + Note: + For 3D centroid CSVs with u,v image coords, use _load_3d_centroid_episodes() instead. + """ + # Read CSV + df = pd.read_csv(csv_path) + + # Auto-detect format if not provided + if csv_format is None: + csv_format = detect_csv_format(df) + + if csv_format == TrackingCSVFormat.UNKNOWN: + raise ValueError(f"Unsupported CSV format in {csv_path}") + + if csv_format == TrackingCSVFormat.CENTROID_3D: + raise ValueError( + f"3D centroid CSV should be loaded via _load_3d_centroid_episodes(): {csv_path}" + ) + + # Normalize to standard format + if csv_format == TrackingCSVFormat.BBOX_2D: + df = self._normalize_bbox_to_centroid(df) + # TRACKS_2D and TRACKS_3D already have the right format + + # Determine if data has z coordinate + has_z = csv_format == TrackingCSVFormat.TRACKS_3D + + # Load using the common helper + self._load_episode_from_df( + session_id, + episode_number, + episode_name, + df, + csv_path, + has_z=has_z, + conn=conn, + ) + + +class GNNRolloutLoader(BaseDataLoader): + """Loader for GNN model evaluation rollout data from pickle files.""" + + def _detect_food_agent(self, dataset_name: str, num_agents: int) -> int: + """ + Detect food agent by filename heuristic. + + Args: + dataset_name: Dataset name from rollout filename + num_agents: Number of agents in trajectory + + Returns: + Agent index of food agent, or -1 if none found + """ + # If 'food' is in the dataset name, food agent is the last agent + if "food" in dataset_name.lower(): + return num_agents - 1 + + return -1 # No food agent + + def _create_agent_type_map( + self, food_agent_idx: int, num_frames: int, num_agents: int + ) -> Dict[Tuple[int, int], str]: + """ + Create mapping from (time_index, agent_id) to agent_type. + + Args: + food_agent_idx: Index of food agent (-1 if none) + num_frames: Number of frames + num_agents: Number of agents + + Returns: + Dict mapping (time_index, agent_id) -> agent_type_id + """ + agent_type_map = {} + + for time_idx in range(num_frames): + for agent_id in range(num_agents): + if food_agent_idx >= 0 and agent_id == food_agent_idx: + agent_type_map[(time_idx, agent_id)] = "food" + else: + agent_type_map[(time_idx, agent_id)] = "agent" + + return agent_type_map + + def _prepare_acceleration_properties( + self, + accelerations: np.ndarray, + num_frames: int, + num_agents: int, + scene_size: float, + ) -> Dict[str, pd.Series]: + """ + Prepare acceleration extended properties. + + Args: + accelerations: [frames, agents, 2] + num_frames: Number of frames + num_agents: Number of agents + scene_size: Scene size for scaling + + Returns: + Dict of property_id -> Series with multi-index (time_index, agent_id) + """ + # Scale accelerations + accelerations_scaled = accelerations * scene_size + accelerations_flat = accelerations_scaled.reshape(-1, 2) + + # Create multi-index + time_indices = np.repeat(np.arange(num_frames), num_agents) + agent_ids = np.tile(np.arange(num_agents), num_frames) + idx = pd.MultiIndex.from_arrays([time_indices, agent_ids]) + + return { + "acceleration_x": pd.Series(accelerations_flat[:, 0], index=idx), + "acceleration_y": pd.Series(accelerations_flat[:, 1], index=idx), + } + + def _prepare_attention_properties( + self, + W_frames: List, # List of (edge_index, edge_weight) tuples + traj_idx: int, # Trajectory index within batch + num_frames: int, + num_agents: int, + food_agent_idx: int, + ) -> Dict[str, pd.Series]: + """ + Prepare attention weight extended properties. + + Args: + W_frames: List of (edge_index, edge_weight) tuples, one per frame + traj_idx: Trajectory index within batch + num_frames: Number of frames + num_agents: Number of agents + food_agent_idx: Index of food agent (-1 if none) + + Returns: + Dict of property_id -> Series with multi-index (time_index, agent_id) + Properties: attn_weight_self, attn_weight_boid, attn_weight_food + """ + from collab_env.gnn.gnn import debatch_edge_index_weight + + # Initialize storage for attention decomposition + attn_self_all = [] # [num_frames, num_agents] + attn_boid_all = [] # [num_frames, num_agents] + attn_food_all = [] # [num_frames, num_agents] + + for frame_idx in range(num_frames): + edge_index, edge_weight = W_frames[frame_idx] + + # Handle empty edge_index (no edges in this frame) + if edge_index.numel() == 0: + # No edges, set all attention weights to zero + attn_self_all.append(np.zeros(num_agents)) + attn_boid_all.append(np.zeros(num_agents)) + attn_food_all.append(np.zeros(num_agents)) + continue + + # Average across heads if multi-head + if len(edge_weight.shape) > 1 and edge_weight.shape[1] > 1: + edge_weight_avg = edge_weight.mean( + dim=1, keepdim=True + ) # [num_edges, 1] + else: + edge_weight_avg = edge_weight + + # Debatch to get NxN adjacency matrix for this trajectory + # Note: debatch expects batch_size trajectories, we only want one + batch_size = int(edge_index.max() // num_agents) + 1 + W_by_file, file_IDs = debatch_edge_index_weight( + edge_index, edge_weight_avg, num_agents, np.arange(batch_size) + ) + + # Get adjacency matrix for our trajectory + A = W_by_file[traj_idx] # [num_agents, num_agents] + + # Decompose attention for each agent + attn_self_frame = np.zeros(num_agents) + attn_boid_frame = np.zeros(num_agents) + attn_food_frame = np.zeros(num_agents) + + for agent_id in range(num_agents): + # Self-attention + attn_self_frame[agent_id] = A[agent_id, agent_id] + + boid_mask = np.ones(num_agents, dtype=bool) + boid_mask[agent_id] = False # Exclude self + # Attention to other boids + if food_agent_idx >= 0: + # Sum attention to all boids (excluding self and food) + boid_mask[food_agent_idx] = False # Exclude food + # Attention to food + attn_food_frame[agent_id] = A[food_agent_idx, agent_id] + else: + # No food, all non-self are boids + attn_food_frame[agent_id] = 0.0 + + attn_boid_frame[agent_id] = np.sum(A[boid_mask, agent_id]) + + attn_self_all.append(attn_self_frame) + attn_boid_all.append(attn_boid_frame) + attn_food_all.append(attn_food_frame) + + # Convert to [num_frames, num_agents] arrays + attn_self_arr = np.array(attn_self_all) # [frames, agents] + attn_boid_arr = np.array(attn_boid_all) + attn_food_arr = np.array(attn_food_all) + + # Flatten and create multi-index + time_indices = np.repeat(np.arange(num_frames), num_agents) + agent_ids = np.tile(np.arange(num_agents), num_frames) + idx = pd.MultiIndex.from_arrays([time_indices, agent_ids]) + + return { + "attn_weight_self": pd.Series(attn_self_arr.flatten(), index=idx), + "attn_weight_boid": pd.Series(attn_boid_arr.flatten(), index=idx), + "attn_weight_food": pd.Series(attn_food_arr.flatten(), index=idx), + } + + def _prepare_loss_observations( + self, + loss_values: List[float], # List of scalars, one per frame + num_frames: int, + scene_size: float, + ) -> Tuple[pd.DataFrame, Dict[str, pd.Series]]: + """ + Prepare per-frame loss as 'env' agent observations. + + Args: + loss_values: List of scalar loss values (one per frame) + num_frames: Number of frames + scene_size: Scene size for positioning env node at center + + Returns: + observations: DataFrame with env agent observations at scene center + extended_props: Dict with 'loss' property + """ + # Verify we have the right number of loss values + loss_array = np.array(loss_values) + if len(loss_array) != num_frames: + logger.warning( + f"Loss array length ({len(loss_array)}) != num_frames ({num_frames}). " + f"Truncating or padding with NaN." + ) + # Pad with NaN or truncate as needed + if len(loss_array) < num_frames: + loss_array = np.pad( + loss_array, + (0, num_frames - len(loss_array)), + constant_values=np.nan, + ) + else: + loss_array = loss_array[:num_frames] + + # Position env node at scene center + scene_center = scene_size / 2.0 # 240.0 for default scene_size=480.0 + + # Create observations with agent_type_id='env', agent_id=-1 (arbitrary, but distinct) + observations = pd.DataFrame( + { + "time_index": np.arange(num_frames), + "agent_id": -1, # Use -1 to distinguish from regular agent IDs (0, 1, 2, ...) + "agent_type_id": "env", + "x": scene_center, + "y": scene_center, + "z": None, + "v_x": None, # NULL velocity for env node + "v_y": None, + "v_z": None, + } + ) + + # Create extended property for loss + idx = pd.MultiIndex.from_arrays( + [ + np.arange(num_frames), # time_index + np.full(num_frames, -1, dtype=int), # agent_id=-1 + ] + ) + extended_props = {"loss": pd.Series(loss_array, index=idx)} + + return observations, extended_props + + def _load_trajectory_episode( + self, + session_id: str, + episode_id: str, + episode_number: int, + positions: np.ndarray, # [frames, agents, 2] + accelerations: np.ndarray, # [frames, agents, 2] + W_frames: Optional[List] = None, # List of (edge_index, edge_weight) tuples + loss_frames: Optional[ + List + ] = None, # List of scalar loss values (one per frame) + traj_idx: int = 0, # Trajectory index within batch + num_frames: Optional[int] = None, + num_agents: Optional[int] = None, + episode_type: str = "actual", # 'actual' or 'predicted' + food_agent_idx: int = -1, + actual_food_positions: Optional[ + np.ndarray + ] = None, # [frames, 2] - TRUE food positions from actual episode + actual_positions: Optional[ + np.ndarray + ] = None, # [frames, agents, 2] - Actual positions for prediction error + metadata: Optional[Dict] = None, + scene_size: float = 480.0, + conn=None, + ): + """Load a single trajectory as an episode with accelerations, attention weights, loss, and prediction error.""" + + # Infer dimensions if not provided + if num_frames is None: + num_frames = positions.shape[0] + if num_agents is None: + num_agents = positions.shape[1] + + # 1. Create agent type map + agent_type_map = self._create_agent_type_map( + food_agent_idx, num_frames, num_agents + ) + + # 2. Insert episode + metadata_dict = metadata or {} + query = """ + INSERT INTO episodes (episode_id, session_id, episode_number, num_frames, + num_agents, frame_rate, file_path) + VALUES (:episode_id, :session_id, :episode_number, :num_frames, + :num_agents, :frame_rate, :file_path) + """ + self.db.execute( + query, + { + "episode_id": episode_id, + "session_id": session_id, + "episode_number": episode_number, + "num_frames": num_frames, + "num_agents": num_agents, + "frame_rate": 1.0, + "file_path": metadata_dict.get("rollout_file", ""), + }, + conn=conn, + ) + + # 3. Prepare observations with agent types + positions_scaled = positions * scene_size + positions_flat = positions_scaled.reshape(-1, 2) + + # Compute velocities + velocities = np.diff(positions_scaled, axis=0) + last_velocity = velocities[-1:, :, :] + velocities = np.vstack([velocities, last_velocity]) + velocities_flat = velocities.reshape(-1, 2) + + # Create index arrays + time_indices = np.repeat(np.arange(num_frames), num_agents) + agent_ids = np.tile(np.arange(num_agents), num_frames) + + # Map agent types + agent_type_ids = [ + agent_type_map.get((t, a), "agent") for t, a in zip(time_indices, agent_ids) + ] + + # Create observations DataFrame + observations = pd.DataFrame( + { + "time_index": time_indices, + "agent_id": agent_ids, + "agent_type_id": agent_type_ids, + "x": positions_flat[:, 0], + "y": positions_flat[:, 1], + "z": None, + "v_x": velocities_flat[:, 0], + "v_y": velocities_flat[:, 1], + "v_z": None, + } + ) + + self.load_observations_batch(observations, episode_id, conn=conn) + + # 3b. Load env observations for loss (predicted episodes only) + if episode_type == "predicted" and loss_frames is not None: + env_observations, loss_props = self._prepare_loss_observations( + loss_frames, num_frames, scene_size + ) + self.load_observations_batch(env_observations, episode_id, conn=conn) + logger.debug( + f"Added {len(loss_props['loss'])} loss observations for env agent" + ) + + # 4. Load accelerations as extended properties + extended_props = self._prepare_acceleration_properties( + accelerations, num_frames, num_agents, scene_size + ) + + # 4b. Merge loss properties if we loaded env observations + if episode_type == "predicted" and loss_frames is not None: + extended_props.update(loss_props) + + # 5. Load attention weights as extended properties (if available) + if W_frames is not None: + attention_props = self._prepare_attention_properties( + W_frames, traj_idx, num_frames, num_agents, food_agent_idx + ) + extended_props.update(attention_props) + + # 6. Compute distance to food (if food agent exists) + if food_agent_idx >= 0: + # positions_scaled: [frames, agents, 2] + time_indices_all = np.repeat(np.arange(num_frames), num_agents) + agent_ids_all = np.tile(np.arange(num_agents), num_frames) + idx = pd.MultiIndex.from_arrays([time_indices_all, agent_ids_all]) + + if episode_type == "actual": + # ACTUAL EPISODE: Compute distance to actual food position + food_positions = positions_scaled[:, food_agent_idx, :] # [frames, 2] + + distances = [] + for time_idx in range(num_frames): + for agent_id in range(num_agents): + if agent_id == food_agent_idx: + distances.append(0.0) + else: + boid_x, boid_y = positions_scaled[time_idx, agent_id, :] + food_x, food_y = food_positions[time_idx, :] + distance = np.sqrt( + (boid_x - food_x) ** 2 + (boid_y - food_y) ** 2 + ) + distances.append(distance) + + extended_props["distance_to_food"] = pd.Series(distances, index=idx) + logger.debug( + f"Computed distance_to_food for actual episode ({len(distances)} observations)" + ) + + else: # episode_type == 'predicted' + # PREDICTED EPISODE: Compute TWO distance metrics + # 1. distance_to_food_actual: Distance to TRUE food position (from actual episode) + # 2. distance_to_food_predicted: Distance to PREDICTED food position + + predicted_food_positions = positions_scaled[ + :, food_agent_idx, : + ] # [frames, 2] + + distances_to_actual_food = [] + distances_to_predicted_food = [] + + for time_idx in range(num_frames): + for agent_id in range(num_agents): + if agent_id == food_agent_idx: + # Food agent itself + distances_to_actual_food.append(0.0) + distances_to_predicted_food.append(0.0) + else: + # Boid positions + boid_x, boid_y = positions_scaled[time_idx, agent_id, :] + + # Distance to TRUE food (from actual episode) + if actual_food_positions is not None: + actual_food_x, actual_food_y = actual_food_positions[ + time_idx, : + ] + dist_to_actual = np.sqrt( + (boid_x - actual_food_x) ** 2 + + (boid_y - actual_food_y) ** 2 + ) + distances_to_actual_food.append(dist_to_actual) + else: + distances_to_actual_food.append(np.nan) + + # Distance to PREDICTED food + pred_food_x, pred_food_y = predicted_food_positions[ + time_idx, : + ] + dist_to_predicted = np.sqrt( + (boid_x - pred_food_x) ** 2 + + (boid_y - pred_food_y) ** 2 + ) + distances_to_predicted_food.append(dist_to_predicted) + + extended_props["distance_to_food_actual"] = pd.Series( + distances_to_actual_food, index=idx + ) + extended_props["distance_to_food_predicted"] = pd.Series( + distances_to_predicted_food, index=idx + ) + + logger.debug( + f"Computed distance_to_food_actual and distance_to_food_predicted " + f"for predicted episode ({len(distances_to_actual_food)} observations)" + ) + + # 7. Compute prediction error (predicted episodes only) + if episode_type == "predicted" and actual_positions is not None: + # actual_positions: [frames, agents, 2] (normalized coordinates) + # positions: [frames, agents, 2] (predicted, normalized coordinates) + + time_indices_all = np.repeat(np.arange(num_frames), num_agents) + agent_ids_all = np.tile(np.arange(num_agents), num_frames) + idx = pd.MultiIndex.from_arrays([time_indices_all, agent_ids_all]) + + # Compute L2 distance in scene units + actual_scaled = actual_positions * scene_size # [frames, agents, 2] + predicted_scaled = positions * scene_size # [frames, agents, 2] + + prediction_errors = [] + for time_idx in range(num_frames): + for agent_id in range(num_agents): + actual_pos = actual_scaled[time_idx, agent_id, :] + predicted_pos = predicted_scaled[time_idx, agent_id, :] + error = np.sqrt(np.sum((actual_pos - predicted_pos) ** 2)) + prediction_errors.append(error) + + extended_props["prediction_error"] = pd.Series(prediction_errors, index=idx) + logger.debug( + f"Computed prediction_error for predicted episode ({len(prediction_errors)} observations)" + ) + + if extended_props: + self.load_extended_properties_batch(episode_id, extended_props, conn=conn) + + def _parse_rollout_filename(self, rollout_path: Path) -> Dict[str, Any]: + """ + Parse rollout filename to extract metadata. + + Example: boid_food_strong_vpluspplus_a_n0_h1_vr0.5_s0_rollout_5.pkl + """ + filename = rollout_path.stem + + # Extract dataset name (everything before the model parameters) + # Pattern: {dataset}_{model}_n{noise}_h{heads}_vr{visual_range}_s{seed}_rollout_{frame} + match = re.match( + r"(.+?)_n(\d+(?:\.\d+)?)_h(\d+)_vr(\d+(?:\.\d+)?)_s(\d+)_rollout_(\d+)", + filename, + ) + + if not match: + logger.warning( + f"Could not parse rollout filename: {filename}, using defaults" + ) + return { + "dataset": filename, + "model_spec": "unknown", + "noise": 0, + "heads": 1, + "visual_range": 0.1, + "seed": 0, + "rollout_frame": 5, + } + + dataset_and_model = match.group(1) + noise = float(match.group(2)) + heads = int(match.group(3)) + visual_range = float(match.group(4)) + seed = int(match.group(5)) + rollout_frame = int(match.group(6)) + + # Try to separate dataset from model name (heuristic: look for common model names) + # Common patterns: dataset_modelname or just dataset + parts = dataset_and_model.rsplit("_", 1) + if len(parts) == 2 and parts[1] in [ + "vpluspplus", + "vplus", + "basic", + "a", + "b", + "c", + ]: + dataset = parts[0] + model_name = parts[1] + else: + dataset = dataset_and_model + model_name = "base" + + model_spec = f"{model_name}_n{noise}_h{heads}_vr{visual_range}_s{seed}" + + return { + "dataset": dataset, + "model_name": model_name, + "model_spec": model_spec, + "noise": noise, + "heads": heads, + "visual_range": visual_range, + "seed": seed, + "rollout_frame": rollout_frame, + } + + def _load_pickle(self, rollout_path: Path) -> Dict: + """Load pickle file with CPU device mapping.""" + from collab_env.gnn.plotting_utility import DeviceUnpickler + + with open(rollout_path, "rb") as f: + # Use DeviceUnpickler to safely load CUDA tensors on CPU-only machines + rollout_data = DeviceUnpickler(f, device="cpu").load() + + return rollout_data + + def load_rollout_file( + self, rollout_path: Path, scene_size: float = 480.0, conn=None + ): + """ + Load a single rollout pickle file. + + Args: + rollout_path: Path to rollout .pkl file + scene_size: Scene size for coordinate scaling + conn: Optional database connection (for bulk loading in single transaction) + """ + + logger.info(f"Loading GNN rollout from: {rollout_path}") + logger.info(f"Loader max_episodes setting: {self.max_episodes}") + + # 1. Parse filename + metadata = self._parse_rollout_filename(rollout_path) + + # 2. Load pickle + rollout_data = self._load_pickle(rollout_path) + + # 3. Create session + session_id = f"rollout-{metadata['dataset']}-{metadata['model_spec']}" + session_metadata = SessionMetadata( + session_id=session_id, + session_name=f"GNN Rollout: {metadata['dataset']}", + category_id="boids_2d_rollout", + config={**metadata, "scene_size": scene_size}, + metadata={"rollout_file": str(rollout_path)}, + ) + + # 4. Load in single transaction (or use provided connection) + def _load_data(conn): + """Internal function to load data with given connection.""" + self.load_session(session_metadata, conn=conn) + + trajectories_loaded = 0 + episode_counter = 0 + # Iterate epochs → batches → trajectories + for epoch_id, epoch_data in rollout_data.items(): + for batch_id, batch_data in epoch_data.items(): + # Extract numpy arrays + actual = np.array( + batch_data["actual"] + ) # [frames, batch, agents, 2] + predicted = np.array( + batch_data["predicted"] + ) # [frames, batch, agents, 2] + actual_acc = np.array( + batch_data["actual_acc"] + ) # [frames, batch, agents, 2] + predicted_acc = np.array( + batch_data["predicted_acc"] + ) # [frames, batch, agents, 2] + + # Extract attention weights if available + W_frames = batch_data.get( + "W", None + ) # List of (edge_index, edge_weight) tuples + + # Extract loss values if available + loss_frames = batch_data.get( + "loss", None + ) # List of scalar loss values (one per frame) + + num_frames = actual.shape[0] + batch_size = actual.shape[1] + num_agents = actual.shape[2] + + # 6. Process each trajectory in batch + for traj_idx in range(batch_size): + # Check if we've reached max episodes before loading this trajectory + # Each trajectory creates 2 episodes (actual + predicted) + if trajectories_loaded >= self.max_episodes: + logger.info( + f"Reached max_episodes limit: {trajectories_loaded} >= {self.max_episodes}, stopping..." + ) + break + + # Extract data for this trajectory + actual_traj = actual[:, traj_idx, :, :] # [frames, agents, 2] + predicted_traj = predicted[ + :, traj_idx, :, : + ] # [frames, agents, 2] + actual_acc_traj = actual_acc[ + :, traj_idx, :, : + ] # [frames, agents, 2] + predicted_acc_traj = predicted_acc[ + :, traj_idx, :, : + ] # [frames, agents, 2] + + # Detect food agent (same for actual and predicted) + food_agent_idx = self._detect_food_agent( + metadata["dataset"], num_agents + ) + + # Extract actual food positions for use in predicted episode + # This is the TRUE food location that should remain stationary + actual_food_positions = None + if food_agent_idx >= 0: + # Scale actual food positions to scene coordinates + actual_food_positions = ( + actual_traj[:, food_agent_idx, :] * scene_size + ) # [frames, 2] + + # Load ACTUAL episode (no attention weights for ground truth) + episode_id_actual = ( + f"{session_id}-{trajectories_loaded:04d}-actual" + ) + self._load_trajectory_episode( + session_id=session_id, + episode_id=episode_id_actual, + episode_number=episode_counter, + positions=actual_traj, + accelerations=actual_acc_traj, + W_frames=None, # No attention weights for ground truth + traj_idx=traj_idx, + num_frames=num_frames, + num_agents=num_agents, + episode_type="actual", + food_agent_idx=food_agent_idx, + actual_food_positions=None, # Not needed for actual episode + metadata={ + "source_epoch": int(epoch_id), + "source_batch": int(batch_id), + "trajectory_index": int(traj_idx), + "rollout_file": str(rollout_path), + }, + scene_size=scene_size, + conn=conn, + ) + + # Load PREDICTED episode (with attention weights from model) + episode_id_predicted = ( + f"{session_id}-{trajectories_loaded:04d}-predicted" + ) + + episode_counter += 1 + + self._load_trajectory_episode( + session_id=session_id, + episode_id=episode_id_predicted, + episode_number=episode_counter, + positions=predicted_traj, + accelerations=predicted_acc_traj, + W_frames=W_frames, # Include attention weights for predictions + loss_frames=loss_frames, # Include loss values per frame + traj_idx=traj_idx, + num_frames=num_frames, + num_agents=num_agents, + episode_type="predicted", + food_agent_idx=food_agent_idx, + actual_food_positions=actual_food_positions, # Pass TRUE food positions + actual_positions=actual_traj, # Pass actual positions for prediction error + metadata={ + "source_epoch": int(epoch_id), + "source_batch": int(batch_id), + "trajectory_index": int(traj_idx), + "model_name": metadata.get("model_name"), + "model_params": { + "noise": metadata.get("noise"), + "heads": metadata.get("heads"), + "visual_range": metadata.get("visual_range"), + "seed": metadata.get("seed"), + }, + "rollout_file": str(rollout_path), + }, + scene_size=scene_size, + conn=conn, + ) + + trajectories_loaded += 1 + episode_counter += 1 + + logger.info( + f"Completed loading rollout: {session_id} ({trajectories_loaded} trajectories, {episode_counter} episodes)" + ) + + # Use provided connection or create new transaction + if conn is not None: + _load_data(conn) + else: + with self.db.transaction() as new_conn: + _load_data(new_conn) + + def load_rollouts_bulk(self, rollouts_dir: Path, scene_size: float = 480.0): + """ + Load multiple rollout files from a directory in a single transaction. + + Each rollout file becomes a separate session. The max_episodes limit applies + independently to each file/session. + + Args: + rollouts_dir: Directory containing rollout .pkl files + scene_size: Scene size for coordinate scaling + """ + # Find all .pkl files + rollout_files = sorted(rollouts_dir.glob("*.pkl")) + + if not rollout_files: + raise ValueError(f"No .pkl files found in {rollouts_dir}") + + logger.info(f"Found {len(rollout_files)} rollout files in {rollouts_dir}") + + # Load all files in a single transaction + with self.db.transaction() as conn: + for idx, rollout_file in enumerate(rollout_files, 1): + logger.info( + f"[{idx}/{len(rollout_files)}] Loading {rollout_file.name}..." + ) + self.load_rollout_file(rollout_file, scene_size=scene_size, conn=conn) + + logger.info(f"Completed loading {len(rollout_files)} rollout files") + + +def main(): + """Command-line interface for data loader.""" + parser = argparse.ArgumentParser( + description="Load tracking data into database", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +Examples: + # Load 3D boids simulation (uses environment variables for DB) + python -m collab_env.data.db.db_loader --source boids3d --path simulated_data/hackathon + + # Load 2D boids dataset + python -m collab_env.data.db.db_loader --source boids2d --path simulated_data/boid_dataset.pt + + # Load GNN rollout predictions + python -m collab_env.data.db.db_loader --source boids2d_rollout --path trained_models/boid_food_strong/rollouts/rollout.pkl --scene-size 480.0 + + # Load with specific backend + python -m collab_env.data.db.db_loader --source boids3d --path simulated_data/hackathon --backend duckdb + """, + ) + + parser.add_argument( + "--source", + required=True, + choices=["boids3d", "boids2d", "tracking", "boids2d_rollout"], + help="Data source type", + ) + + parser.add_argument( + "--max-episodes-per-session", + type=int, + default=None, + help="Maximum number of episodes to load per session (default: unlimited)", + ) + + parser.add_argument( + "--path", required=True, type=Path, help="Path to data directory or file" + ) + + parser.add_argument( + "--backend", + choices=["postgres", "duckdb"], + help="Database backend (overrides DB_BACKEND env var)", + ) + + parser.add_argument( + "--dbpath", help="DuckDB database path (overrides DUCKDB_PATH env var)" + ) + + parser.add_argument( + "--scene-size", + type=float, + default=480.0, + help="Scene size for coordinate scaling (default: 480.0, for boids2d_rollout source only)", + ) + + args = parser.parse_args() + + # Handle dbpath via environment variable if specified + if args.dbpath: + os.environ["DUCKDB_PATH"] = str(args.dbpath) + + # Load configuration + config = get_db_config(backend=args.backend) + + # Create database connection + db_conn = DatabaseConnection(config) + db_conn.connect() + + try: + # Convert None to np.inf for unlimited episodes + max_eps = ( + args.max_episodes_per_session + if args.max_episodes_per_session is not None + else np.inf + ) + logger.info( + f"max_episodes_per_session argument: {args.max_episodes_per_session}" + ) + logger.info(f"Effective max_episodes: {max_eps}") + + # Load data based on source type + if args.source == "boids3d": + loader = Boids3DLoader(db_conn, max_episodes=max_eps) + + # Check if path is a directory with multiple simulations or a single simulation + if args.path.is_dir(): + # Check if this is a single simulation (has config.yaml) or parent directory + if (args.path / "config.yaml").exists(): + # Single simulation + logger.info("Loading single simulation...") + loader.load_simulation(args.path) + else: + # Parent directory with multiple simulations + logger.info("Loading multiple simulations from parent directory...") + loader.load_simulations_bulk(args.path) + else: + raise ValueError(f"Path must be a directory: {args.path}") + + elif args.source == "boids2d": + loader = Boids2DLoader(db_conn, max_episodes=max_eps) + + # Check if path is a file or directory + if args.path.is_file() and args.path.suffix == ".pt": + # Single dataset file + logger.info("Loading single dataset...") + loader.load_dataset(args.path) + elif args.path.is_dir(): + # Directory with multiple datasets + logger.info("Loading multiple datasets from directory...") + loader.load_datasets_bulk(args.path) + else: + raise ValueError(f"Path must be a .pt file or directory: {args.path}") + + elif args.source == "tracking": + loader = TrackingCSVLoader(db_conn, max_episodes=max_eps) + + # Check if path is a single session or parent directory + if args.path.is_dir(): + # Check if this is a single session (has aligned_frames/) + if (args.path / "aligned_frames").exists(): + # Single session + logger.info("Loading single session...") + loader.load_tracking_session(args.path) + else: + # Parent directory with multiple sessions + logger.info("Loading multiple sessions from parent directory...") + loader.load_sessions_bulk(args.path) + else: + raise ValueError(f"Path must be a directory: {args.path}") + + elif args.source == "boids2d_rollout": + loader = GNNRolloutLoader(db_conn, max_episodes=max_eps) + + if args.path.is_file() and args.path.suffix == ".pkl": + # Single rollout file + logger.info("Loading single rollout file...") + loader.load_rollout_file(args.path, scene_size=args.scene_size) + elif args.path.is_dir(): + # Directory with multiple rollout files + logger.info("Loading multiple rollout files from directory...") + loader.load_rollouts_bulk(args.path, scene_size=args.scene_size) + else: + raise ValueError(f"Path must be a .pkl file or directory: {args.path}") + + logger.info("Data loading completed successfully") + + except Exception as e: + logger.exception(f"Error loading data: {e}") + raise + finally: + db_conn.close() + + +if __name__ == "__main__": + main() diff --git a/collab_env/data/db/init_database.py b/collab_env/data/db/init_database.py new file mode 100644 index 00000000..f07409ad --- /dev/null +++ b/collab_env/data/db/init_database.py @@ -0,0 +1,465 @@ +#!/usr/bin/env python +""" +init_database.py +Initialize tracking_analytics database (PostgreSQL or DuckDB) +Reads configuration from environment variables or command-line args +""" + +import argparse +import re +import sys +from pathlib import Path +from typing import Optional + +from loguru import logger +from sqlalchemy import create_engine, text +from sqlalchemy.engine import Engine + +from collab_env.data.db.config import get_db_config, DBConfig +from collab_env.data.file_utils import get_project_root + +# Configure loguru logging +logger.remove() # Remove default handler + +# Add colorized console output +logger.add( + sys.stderr, + format="{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {message}", + level="INFO", + colorize=True, +) + +# Add file output to logs directory +log_dir = Path(__file__).parent.parent.parent.parent / "logs" +log_dir.mkdir(exist_ok=True) +logger.add( + log_dir / "init_database_{time:YYYY-MM-DD}.log", + rotation="00:00", # Rotate at midnight + retention="30 days", # Keep logs for 30 days + format="{time:YYYY-MM-DD HH:mm:ss} | {level: <8} | {name}:{function}:{line} - {message}", + level="DEBUG", +) + + +def log_header(msg: str): + """Log a header message with separator.""" + logger.info("=" * 60) + logger.info(msg) + logger.info("=" * 60) + + +class DatabaseBackend: + """Unified database backend using SQLAlchemy""" + + def __init__(self, config: DBConfig): + self.config = config + self.engine: Optional[Engine] = None + + def connect(self): + """Connect to database using SQLAlchemy""" + try: + url = self.config.sqlalchemy_url() + self.engine = create_engine(url, echo=False) + + # Test connection + with self.engine.connect() as conn: + conn.execute(text("SELECT 1")) + conn.commit() + + if self.config.backend == "postgres": + logger.success( + f"Connected to PostgreSQL: {self.config.postgres.dbname}" + ) + else: + logger.success(f"Connected to DuckDB: {self.config.duckdb.dbpath}") + except Exception as e: + logger.error(f"Failed to connect to database: {e}") + raise + + def execute_file(self, filepath: Path): + """Execute SQL file (with automatic dialect adaptation)""" + try: + with open(filepath, "r") as f: + sql_content = f.read() + + # DuckDB-specific adaptations + if self.config.backend == "duckdb": + # For BIGSERIAL, we need to use a sequence + sql_content = sql_content.replace( + "observation_id BIGSERIAL UNIQUE NOT NULL", + "observation_id BIGINT UNIQUE DEFAULT nextval('obs_id_seq')", + ) + sql_content = sql_content.replace("BIGSERIAL", "BIGINT") + sql_content = sql_content.replace("JSONB", "JSON") + sql_content = sql_content.replace("DOUBLE PRECISION", "DOUBLE") + # DuckDB doesn't support CASCADE in FK constraints + sql_content = sql_content.replace(" ON DELETE CASCADE", "") + # Remove ON CONFLICT clauses + sql_content = re.sub(r"\s+ON CONFLICT[^;]+DO NOTHING", "", sql_content) + # DuckDB doesn't support ALTER TABLE ADD CONSTRAINT for FK + sql_content = re.sub( + r"ALTER TABLE[^;]+ADD CONSTRAINT[^;]+FOREIGN KEY[^;]+;", + "", + sql_content, + ) + + # Create sequence if needed + if ( + "observations" in sql_content.lower() + and "obs_id_seq" in sql_content + ): + try: + assert self.engine is not None + with self.engine.connect() as conn: + conn.execute( + text("CREATE SEQUENCE IF NOT EXISTS obs_id_seq START 1") + ) + conn.commit() + except Exception: + pass # Sequence may already exist + + # Execute the SQL content + assert self.engine is not None + with self.engine.connect() as conn: + conn.execute(text(sql_content)) + conn.commit() + + logger.success(f"Executed {filepath.name}") + except Exception as e: + logger.error(f"Failed to execute {filepath.name}: {e}") + raise + + def execute_query(self, query: str): + """Execute single query and return results (if any)""" + assert self.engine is not None + with self.engine.connect() as conn: + result = conn.execute(text(query)) + # Fetch results before commit (commit closes the result object) + if result.returns_rows: + rows = result.fetchall() + conn.commit() + return rows + else: + conn.commit() + return None + + def close(self): + """Close database connection""" + if self.engine: + self.engine.dispose() + + +def get_schema_files(schema_dir: Path) -> list[Path]: + """Get schema files in order""" + files = [ + schema_dir / "01_core_tables.sql", + schema_dir / "02_extended_properties.sql", + schema_dir / "03_seed_data.sql", + ] + + for f in files: + if not f.exists(): + logger.error(f"Schema file not found: {f}") + sys.exit(1) + + return files + + +def verify_setup(backend: DatabaseBackend): + """Verify database setup""" + log_header("Verifying Setup") + + # Check table count + if backend.config.backend == "postgres": + query = """ + SELECT count(*) + FROM information_schema.tables + WHERE table_schema = 'public' AND table_type = 'BASE TABLE'; + """ + else: # DuckDB + query = "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'main';" + + result = backend.execute_query(query) + table_count = result[0][0] + + if table_count == 7: + logger.success("All 7 tables created") + else: + logger.error(f"Expected 7 tables, found {table_count}") + return False + + # Check seed data + result = backend.execute_query("SELECT count(*) FROM agent_types;") + agent_count = result[0][0] + if agent_count >= 5: + logger.success(f"Agent types loaded ({agent_count} rows)") + else: + logger.error(f"Expected at least 5 agent types, found {agent_count}") + return False + + result = backend.execute_query("SELECT count(*) FROM property_definitions;") + prop_count = result[0][0] + if prop_count >= 10: + logger.success(f"Property definitions loaded ({prop_count} rows)") + else: + logger.error(f"Expected at least 10 property definitions, found {prop_count}") + return False + + result = backend.execute_query("SELECT count(*) FROM categories;") + cat_count = result[0][0] + if cat_count == 4: + logger.success(f"Categories loaded ({cat_count} rows)") + else: + logger.error(f"Expected 4 categories, found {cat_count}") + return False + + return True + + +def print_summary(backend: DatabaseBackend): + """Print summary""" + log_header("Summary") + + if backend.config.backend == "postgres": + assert backend.config.postgres is not None + logger.info(f"Database: {backend.config.postgres.dbname}") + logger.info( + f"Host: {backend.config.postgres.host}:{backend.config.postgres.port}" + ) + logger.info(f"User: {backend.config.postgres.user}") + else: + assert backend.config.duckdb is not None + logger.info(f"Database: {backend.config.duckdb.dbpath}") + + logger.info("Tables created:") + + if backend.config.backend == "postgres": + result = backend.execute_query(""" + SELECT tablename FROM pg_tables + WHERE schemaname = 'public' + ORDER BY tablename; + """) + else: + result = backend.execute_query(""" + SELECT table_name FROM information_schema.tables + WHERE table_schema = 'main' + ORDER BY table_name; + """) + + for row in result: + logger.info(f" - {row[0]}") + + logger.success("Database initialization complete!") + + +def recreate_database(config: DBConfig): + """Drop and recreate the database""" + import os + + if config.backend == "postgres": + # For PostgreSQL, connect to 'postgres' database to drop/create target database + assert config.postgres is not None + temp_dbname = config.postgres.dbname + + # Connect to 'postgres' database + config.postgres.dbname = "postgres" + temp_engine = create_engine( + config.sqlalchemy_url(), isolation_level="AUTOCOMMIT" + ) + + try: + with temp_engine.connect() as conn: + # Terminate existing connections to target database + logger.info(f"Terminating connections to {temp_dbname}...") + conn.execute( + text(f""" + SELECT pg_terminate_backend(pg_stat_activity.pid) + FROM pg_stat_activity + WHERE pg_stat_activity.datname = '{temp_dbname}' + AND pid <> pg_backend_pid() + """) + ) + + # Drop database if it exists + logger.info(f"Dropping database {temp_dbname}...") + conn.execute(text(f"DROP DATABASE IF EXISTS {temp_dbname}")) + + # Create database + logger.success(f"Creating database {temp_dbname}...") + conn.execute(text(f"CREATE DATABASE {temp_dbname}")) + + finally: + temp_engine.dispose() + # Restore original database name + config.postgres.dbname = temp_dbname + + else: # DuckDB + assert config.duckdb is not None + # For DuckDB, just delete the file + if os.path.exists(config.duckdb.dbpath): + logger.info(f"Removing existing DuckDB file: {config.duckdb.dbpath}") + os.remove(config.duckdb.dbpath) + # Also remove .wal file if it exists + wal_file = config.duckdb.dbpath + ".wal" + if os.path.exists(wal_file): + os.remove(wal_file) + logger.success(f"Creating new DuckDB file: {config.duckdb.dbpath}") + + +def main(): + parser = argparse.ArgumentParser( + description="Initialize tracking_analytics database (PostgreSQL or DuckDB)", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +Examples: + # PostgreSQL (recreates database) + python -m collab_env.data.init_database --backend postgres + + # DuckDB + python -m collab_env.data.init_database --backend duckdb --dbpath tracking.duckdb + + # Custom PostgreSQL connection + python -m collab_env.data.init_database --backend postgres --dbname mydb --user myuser --host localhost + """, + ) + + parser.add_argument( + "--backend", + choices=["postgres", "duckdb"], + default=None, + help="Database backend (default: from DB_BACKEND env var or duckdb)", + ) + parser.add_argument( + "--dbname", + default=None, + help="Database name (PostgreSQL, default: from POSTGRES_DB env or tracking_analytics)", + ) + parser.add_argument( + "--user", + default=None, + help="Database user (PostgreSQL, default: from POSTGRES_USER env or current user)", + ) + parser.add_argument( + "--host", + default=None, + help="Database host (PostgreSQL, default: from POSTGRES_HOST env or localhost)", + ) + parser.add_argument( + "--port", + type=int, + default=None, + help="Database port (PostgreSQL, default: from POSTGRES_PORT env or 5432)", + ) + parser.add_argument( + "--dbpath", + default=None, + help="Database file path (DuckDB, default: from DUCKDB_PATH env or tracking.duckdb)", + ) + parser.add_argument( + "--schema-dir", + type=Path, + default=None, + help="Schema directory (default: /schema)", + ) + parser.add_argument( + "--no-drop", + action="store_true", + help="Do not drop existing database (only create tables, fails if tables exist)", + ) + + args = parser.parse_args() + + # Load configuration from environment, override with command-line args + logger.info("Loading database configuration...") + config = get_db_config(backend=args.backend) + + # Override config with command-line args if provided + if args.backend: + config.backend = args.backend + + if config.backend == "postgres": + # Override PostgreSQL settings + if args.dbname: + config.postgres.dbname = args.dbname + if args.user: + config.postgres.user = args.user + if args.host: + config.postgres.host = args.host + if args.port: + config.postgres.port = args.port + else: + # Override DuckDB settings + if args.dbpath: + config.duckdb.dbpath = args.dbpath + + # Get project root and schema directory + project_root = get_project_root() + schema_dir = args.schema_dir or ( + project_root / "collab_env" / "data" / "db" / "schema" + ) + + if not schema_dir.exists(): + logger.error(f"Schema directory not found: {schema_dir}") + sys.exit(1) + + log_header("Tracking Analytics Database Initialization") + logger.info(f"Backend: {config.backend}") + logger.info(f"Configuration: {config}") + logger.info(f"Schema dir: {schema_dir}") + + # Get schema files + schema_files = get_schema_files(schema_dir) + logger.info(f"Found {len(schema_files)} schema files") + + # Drop and recreate database (unless --no-drop specified) + if not args.no_drop: + log_header("Recreating Database") + logger.warning("⚠️ This will drop the existing database and all data!") + recreate_database(config) + + # Create unified backend with SQLAlchemy + backend = DatabaseBackend(config) + + try: + # Connect + log_header("Connecting to Database") + backend.connect() + + # Execute schema files + log_header("Creating Schema") + for schema_file in schema_files: + logger.info(f"Executing {schema_file.name}...") + backend.execute_file(schema_file) + + # Verify + if not verify_setup(backend): + logger.error("Verification failed") + sys.exit(1) + + # Summary + print_summary(backend) + + logger.info("Next steps:") + logger.info(" 1. Load data: python -m collab_env.data.db_loader") + if config.backend == "postgres": + logger.info( + f" 2. Connect Grafana to: {config.postgres.connection_string(include_password=False)}" + ) + logger.info( + f" 3. Query: psql -h {config.postgres.host} -U {config.postgres.user} -d {config.postgres.dbname}" + ) + else: + logger.info(f" 2. Query: duckdb {config.duckdb.dbpath}") + logger.info( + f" 3. Or in Python: import duckdb; conn = duckdb.connect('{config.duckdb.dbpath}')" + ) + + except Exception as e: + logger.error(f"Initialization failed: {e}") + sys.exit(1) + finally: + backend.close() + + +if __name__ == "__main__": + main() diff --git a/collab_env/data/db/queries/__init__.py b/collab_env/data/db/queries/__init__.py new file mode 100644 index 00000000..50bfb4e4 --- /dev/null +++ b/collab_env/data/db/queries/__init__.py @@ -0,0 +1,5 @@ +"""SQL queries for spatial analysis database. + +Queries are managed using aiosql (https://nackjicholson.github.io/aiosql/). +Each .sql file contains multiple named queries that are loaded at runtime. +""" diff --git a/collab_env/data/db/queries/basic_data_viewer.sql b/collab_env/data/db/queries/basic_data_viewer.sql new file mode 100644 index 00000000..d511139d --- /dev/null +++ b/collab_env/data/db/queries/basic_data_viewer.sql @@ -0,0 +1,151 @@ +-- Basic Data Viewer queries for comprehensive episode visualization +-- Provides general-purpose queries that work with any extended property + +-- name: get_episode_tracks +-- Get position and velocity data for all agents in an episode for animation +-- Returns raw trajectory data for time-based animation +SELECT + agent_id, + time_index, + x, + y, + z, + v_x, + v_y, + v_z, + sqrt(COALESCE(v_x*v_x, 0) + COALESCE(v_y*v_y, 0) + COALESCE(v_z*v_z, 0)) as speed +FROM observations +WHERE episode_id = :episode_id + AND (:start_time IS NULL OR time_index >= :start_time) + AND (:end_time IS NULL OR time_index <= :end_time) + AND (:agent_type = 'all' OR agent_type_id = :agent_type) +ORDER BY time_index, agent_id; + + +-- name: get_extended_properties_timeseries +-- Get aggregated time series for any extended properties +-- Property-agnostic query - gets all properties, filter in Python if needed +-- Returns windowed statistics for all properties (median + configurable quantile bands) +SELECT + floor(o.time_index / :window_size) * :window_size as time_window, + ep.property_id, + count(*) as n_observations, + avg(ep.value_float) as avg_value, + stddev_pop(ep.value_float) as std_value, + min(ep.value_float) as min_value, + max(ep.value_float) as max_value, + percentile_cont(0.5) WITHIN GROUP (ORDER BY ep.value_float) as median_value, + percentile_cont(:lower_quantile) WITHIN GROUP (ORDER BY ep.value_float) as q_lower, + percentile_cont(:upper_quantile) WITHIN GROUP (ORDER BY ep.value_float) as q_upper +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +WHERE o.episode_id = :episode_id + AND (:start_time IS NULL OR o.time_index >= :start_time) + AND (:end_time IS NULL OR o.time_index <= :end_time) + AND (:agent_type = 'all' OR o.agent_type_id = :agent_type) + AND ep.value_float IS NOT NULL +GROUP BY time_window, ep.property_id +ORDER BY time_window, ep.property_id; + + +-- name: get_property_distributions_episode +-- Get raw property values for histogram generation (episode scope) +-- Property-agnostic query - gets all properties, filter in Python if needed +-- Returns individual property values for distribution analysis +-- Optimized version without NULL checks (episode scope only) +SELECT + ep.property_id, + ep.value_float +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +WHERE o.episode_id = :episode_id + AND (:start_time IS NULL OR o.time_index >= :start_time) + AND (:end_time IS NULL OR o.time_index <= :end_time) + AND (:agent_type = 'all' OR o.agent_type_id = :agent_type) + AND ep.value_float IS NOT NULL +ORDER BY ep.property_id, ep.value_float; + + +-- name: get_property_distributions_session +-- Get raw property values for histogram generation (session scope) +-- Property-agnostic query - gets all properties, filter in Python if needed +-- Returns individual property values for distribution analysis +-- Optimized version without NULL checks (session scope only) +SELECT + ep.property_id, + ep.value_float +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +WHERE o.episode_id IN ( + SELECT episode_id FROM episodes WHERE session_id = :session_id + ) + AND (:start_time IS NULL OR o.time_index >= :start_time) + AND (:end_time IS NULL OR o.time_index <= :end_time) + AND (:agent_type = 'all' OR o.agent_type_id = :agent_type) + AND ep.value_float IS NOT NULL +ORDER BY ep.property_id, ep.value_float; + + +-- name: get_available_properties_episode +-- Get list of available extended properties for a single episode +-- Returns property metadata for UI selection +-- Optimized version without NULL checks (episode scope only) +SELECT + pd.property_id, + pd.property_name, + pd.description, + pd.unit, + pd.data_type +FROM property_definitions pd +WHERE pd.property_id IN ( + SELECT DISTINCT ep.property_id + FROM extended_properties ep + JOIN observations o ON ep.observation_id = o.observation_id + WHERE o.episode_id = :episode_id + AND (:agent_type = 'all' OR o.agent_type_id = :agent_type) +) +ORDER BY pd.property_name; + + +-- name: get_available_properties_session +-- Get list of available extended properties for all episodes in a session +-- Returns property metadata for UI selection +-- Supports time filtering to reduce scan size +SELECT + pd.property_id, + pd.property_name, + pd.description, + pd.unit, + pd.data_type +FROM property_definitions pd +WHERE pd.property_id IN ( + SELECT DISTINCT ep.property_id + FROM extended_properties ep + JOIN observations o ON ep.observation_id = o.observation_id + WHERE o.episode_id IN ( + SELECT episode_id FROM episodes WHERE session_id = :session_id + ) + AND (:start_time IS NULL OR o.time_index >= :start_time) + AND (:end_time IS NULL OR o.time_index <= :end_time) + AND (:agent_type = 'all' OR o.agent_type_id = :agent_type) +) +ORDER BY pd.property_name; + + +-- name: get_extended_properties_raw +-- Get raw (unaggregated) extended property values with time indices +-- For overlaying individual agent trajectories on time series plots +-- Returns all raw observations in long format for line plotting per agent +SELECT + o.time_index, + o.agent_id, + ep.property_id, + ep.value_float +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +WHERE o.episode_id = :episode_id + AND (:start_time IS NULL OR o.time_index >= :start_time) + AND (:end_time IS NULL OR o.time_index <= :end_time) + AND (:agent_type = 'all' OR o.agent_type_id = :agent_type) + AND ep.value_float IS NOT NULL +ORDER BY ep.property_id, o.agent_id, o.time_index; \ No newline at end of file diff --git a/collab_env/data/db/queries/correlations.sql b/collab_env/data/db/queries/correlations.sql new file mode 100644 index 00000000..7ff3cba0 --- /dev/null +++ b/collab_env/data/db/queries/correlations.sql @@ -0,0 +1,65 @@ +-- Correlation queries for agent interactions + +-- name: get_velocity_correlations +-- Compute pairwise velocity correlations between agents +-- Warning: O(n²) computation, can be slow for many agents +-- Only supports episode_id (single episode). Session-level correlation disabled. +WITH agent_velocities AS ( + SELECT + time_index, + agent_id, + v_x, + v_y, + v_z + FROM observations + WHERE episode_id = :episode_id + AND (:agent_type = 'all' OR agent_type_id = :agent_type) + AND (:start_time IS NULL OR time_index >= :start_time) + AND (:end_time IS NULL OR time_index <= :end_time) + AND v_x IS NOT NULL +) +SELECT + a.agent_id as agent_i, + b.agent_id as agent_j, + corr(a.v_x, b.v_x) as v_x_correlation, + corr(a.v_y, b.v_y) as v_y_correlation, + corr(a.v_z, b.v_z) as v_z_correlation, + count(*) as n_samples +FROM agent_velocities a +JOIN agent_velocities b + ON a.time_index = b.time_index + AND a.agent_id < b.agent_id +GROUP BY a.agent_id, b.agent_id +HAVING count(*) > :min_samples +ORDER BY v_x_correlation DESC; + + +-- name: get_distance_correlations +-- Compute pairwise distance-to-target correlations between agents +-- Warning: O(n²) computation, can be slow for many agents +-- Only supports episode_id (single episode). Session-level correlation disabled. +WITH agent_distances AS ( + SELECT + o.time_index, + o.agent_id, + ep.value_float as dist_to_target + FROM observations o + JOIN extended_properties ep ON o.observation_id = ep.observation_id + WHERE o.episode_id = :episode_id + AND ep.property_id = 'distance_to_target_center' + AND o.agent_type_id = 'agent' + AND (:start_time IS NULL OR o.time_index >= :start_time) + AND (:end_time IS NULL OR o.time_index <= :end_time) +) +SELECT + a.agent_id as agent_i, + b.agent_id as agent_j, + corr(a.dist_to_target, b.dist_to_target) as distance_correlation, + count(*) as n_samples +FROM agent_distances a +JOIN agent_distances b + ON a.time_index = b.time_index + AND a.agent_id < b.agent_id +GROUP BY a.agent_id, b.agent_id +HAVING count(*) > :min_samples +ORDER BY distance_correlation DESC; diff --git a/collab_env/data/db/queries/session_metadata.sql b/collab_env/data/db/queries/session_metadata.sql new file mode 100644 index 00000000..3ccc742b --- /dev/null +++ b/collab_env/data/db/queries/session_metadata.sql @@ -0,0 +1,73 @@ +-- Session and episode metadata queries + +-- name: get_categories +-- Get list of all categories +SELECT + category_id, + category_name, + description +FROM categories +ORDER BY category_name; + + +-- name: get_sessions +-- Get list of all sessions, optionally filtered by category +SELECT + s.session_id, + s.session_name, + s.category_id, + s.created_at, + s.config +FROM sessions s +WHERE (:category_id IS NULL OR s.category_id = :category_id) +ORDER BY s.created_at DESC; + + +-- name: get_episodes +-- Get all episodes for a given session +SELECT + e.episode_id, + e.episode_number, + e.num_frames, + e.num_agents, + e.frame_rate, + e.file_path +FROM episodes e +WHERE e.session_id = :session_id +ORDER BY e.episode_number; + + +-- name: get_episode_metadata +-- Get detailed metadata for a single episode +SELECT + e.episode_id, + e.session_id, + e.episode_number, + e.num_frames, + e.num_agents, + e.frame_rate, + e.file_path, + s.session_name, + s.category_id, + s.config +FROM episodes e +JOIN sessions s ON e.session_id = s.session_id +WHERE e.episode_id = :episode_id; + + +-- name: get_agent_types +-- Get distinct agent types for an episode +SELECT DISTINCT agent_type_id +FROM observations +WHERE episode_id = :episode_id +ORDER BY agent_type_id; + + +-- name: get_agent_types_for_session +-- Get distinct agent types across all episodes in a session +SELECT DISTINCT agent_type_id +FROM observations +WHERE episode_id IN ( + SELECT episode_id FROM episodes WHERE session_id = :session_id +) +ORDER BY agent_type_id; diff --git a/collab_env/data/db/queries/spatial_analysis.sql b/collab_env/data/db/queries/spatial_analysis.sql new file mode 100644 index 00000000..68a3cd20 --- /dev/null +++ b/collab_env/data/db/queries/spatial_analysis.sql @@ -0,0 +1,48 @@ +-- Spatial analysis queries for 3D boids data + +-- name: get_spatial_heatmap_episode +-- Get spatial density heatmap with configurable binning in 3D (episode scope) +-- Returns binned positions with density counts and average velocities +-- Optimized version without NULL checks (episode scope only) +SELECT + floor(x / :bin_size) * :bin_size as x_bin, + floor(y / :bin_size) * :bin_size as y_bin, + floor(z / :bin_size) * :bin_size as z_bin, + count(*) as density, + avg(v_x) as avg_vx, + avg(v_y) as avg_vy, + avg(v_z) as avg_vz +FROM observations +WHERE episode_id = :episode_id + AND (:start_time IS NULL OR time_index >= :start_time) + AND (:end_time IS NULL OR time_index <= :end_time) + AND (:agent_type = 'all' OR agent_type_id = :agent_type) +GROUP BY x_bin, y_bin, z_bin +HAVING count(*) > :min_count +ORDER BY x_bin, y_bin, z_bin; + + +-- name: get_spatial_heatmap_session +-- Get spatial density heatmap with configurable binning in 3D (session scope) +-- Returns binned positions with density counts and average velocities +-- Optimized version without NULL checks (session scope only) +SELECT + floor(x / :bin_size) * :bin_size as x_bin, + floor(y / :bin_size) * :bin_size as y_bin, + floor(z / :bin_size) * :bin_size as z_bin, + count(*) as density, + avg(v_x) as avg_vx, + avg(v_y) as avg_vy, + avg(v_z) as avg_vz +FROM observations +WHERE episode_id IN ( + SELECT episode_id FROM episodes WHERE session_id = :session_id + ) + AND (:start_time IS NULL OR time_index >= :start_time) + AND (:end_time IS NULL OR time_index <= :end_time) + AND (:agent_type = 'all' OR agent_type_id = :agent_type) +GROUP BY x_bin, y_bin, z_bin +HAVING count(*) > :min_count +ORDER BY x_bin, y_bin, z_bin; + + diff --git a/collab_env/data/db/query_backend.py b/collab_env/data/db/query_backend.py new file mode 100644 index 00000000..0b185615 --- /dev/null +++ b/collab_env/data/db/query_backend.py @@ -0,0 +1,818 @@ +""" +Query backend for spatial analysis of tracking data. + +Provides a high-level API for executing spatial analysis queries +on the tracking analytics database. Uses aiosql to manage SQL queries +in separate .sql files with driver-specific adapters. +""" + +import time +from pathlib import Path +from typing import Optional + +import aiosql +import pandas as pd +from loguru import logger + +from collab_env.data.db.config import DBConfig, get_db_config +from collab_env.data.db.db_loader import DatabaseConnection + + +class QueryBackend: + """ + Query interface for spatial analysis. + + Uses aiosql to load SQL queries from .sql files and execute them + against the database using driver-specific adapters (psycopg2 for + PostgreSQL, duckdb for DuckDB). All methods return pandas DataFrames. + + Examples + -------- + >>> from collab_env.data.db.query_backend import QueryBackend + >>> + >>> # Initialize with default config (reads from environment) + >>> query = QueryBackend() + >>> + >>> # Get sessions + >>> sessions = query.get_sessions(category_id='boids_3d') + >>> print(sessions) + >>> + >>> # Get episodes for first session + >>> session_id = sessions.iloc[0]['session_id'] + >>> episodes = query.get_episodes(session_id) + >>> + >>> # Get spatial heatmap for first episode + >>> episode_id = episodes.iloc[0]['episode_id'] + >>> heatmap = query.get_spatial_heatmap(episode_id, bin_size=10.0) + >>> + >>> # Close connection + >>> query.close() + """ + + def __init__( + self, config: Optional[DBConfig] = None, backend: Optional[str] = None + ): + """ + Initialize QueryBackend. + + Parameters + ---------- + config : DBConfig, optional + Database configuration. If None, uses get_db_config() + backend : str, optional + Database backend ('postgres' or 'duckdb'). + If provided, overrides config. + """ + if backend: + self.config = DBConfig(backend=backend) + else: + self.config = config or get_db_config() + + # Initialize database connection + self.db = DatabaseConnection(self.config) + self.db.connect() + + # Load SQL queries using aiosql with driver-specific adapter + queries_dir = Path(__file__).parent / "queries" + if not queries_dir.exists(): + raise FileNotFoundError(f"Queries directory not found: {queries_dir}") + + # Choose adapter based on backend + if self.config.backend == "postgres": + driver_adapter = "psycopg2" + else: + driver_adapter = "duckdb" + + self.queries = aiosql.from_path(str(queries_dir), driver_adapter) + logger.info(f"Loaded queries from {queries_dir} using {driver_adapter} adapter") + + def close(self): + """Close database connection.""" + logger.info("Closing database connection...") + self.db.close() + + def _execute_query(self, query_name: str, **params) -> pd.DataFrame: + """ + Execute a query and return results as pandas DataFrame. + + Parameters + ---------- + query_name : str + Name of the aiosql query to execute + **params + Query parameters + + Returns + ------- + pd.DataFrame + Query results + """ + # Log query execution start + start_time = time.time() + logger.info(f"Executing query '{query_name}' with params: {params}") + + try: + # Get the cursor variant of the query from aiosql + # aiosql provides both query_name() and query_name_cursor() variants + cursor_func = getattr(self.queries, f"{query_name}_cursor") + + # Get raw database connection + # aiosql works directly with psycopg2/duckdb connections + assert self.db.engine is not None + raw_conn = self.db.engine.raw_connection() + try: + # Execute query using aiosql cursor method + # The _cursor variant returns a context manager + with cursor_func(raw_conn, **params) as cursor: + # Fetch all rows + rows = cursor.fetchall() + + # Get column names from cursor description + if rows: + col_names = [desc[0] for desc in cursor.description] + result = pd.DataFrame(rows, columns=col_names) + else: + # Return empty DataFrame with column names + col_names = ( + [desc[0] for desc in cursor.description] + if cursor.description + else [] + ) + result = pd.DataFrame(columns=col_names) + + # Log successful query completion with execution time + elapsed_time = time.time() - start_time + logger.info( + f"Query '{query_name}' completed in {elapsed_time:.3f}s: " + f"{len(result)} rows returned" + ) + return result + finally: + raw_conn.close() + + except Exception as e: + elapsed_time = time.time() - start_time + logger.error( + f"Query '{query_name}' execution failed after {elapsed_time:.3f}s: {e}" + ) + raise + + # ==================== Session/Episode Metadata ==================== + + def get_categories(self) -> pd.DataFrame: + """ + Get list of all categories. + + Returns + ------- + pd.DataFrame + Categories with columns: category_id, category_name, description + """ + return self._execute_query("get_categories") + + def get_sessions(self, category_id: Optional[str] = None) -> pd.DataFrame: + """ + Get list of all sessions, optionally filtered by category. + + Parameters + ---------- + category_id : str, optional + Filter by category ('boids_3d', 'boids_2d', 'tracking_csv') + + Returns + ------- + pd.DataFrame + Sessions with columns: session_id, session_name, category_id, created_at, config + """ + return self._execute_query("get_sessions", category_id=category_id) + + def get_episodes(self, session_id: str) -> pd.DataFrame: + """ + Get all episodes for a given session. + + Parameters + ---------- + session_id : str + Session identifier + + Returns + ------- + pd.DataFrame + Episodes with columns: episode_id, episode_number, num_frames, + num_agents, frame_rate, file_path + """ + return self._execute_query("get_episodes", session_id=session_id) + + def get_episode_metadata(self, episode_id: str) -> pd.DataFrame: + """ + Get detailed metadata for a single episode. + + Parameters + ---------- + episode_id : str + Episode identifier + + Returns + ------- + pd.DataFrame + Episode metadata with columns: episode_id, session_id, episode_number, + num_frames, num_agents, frame_rate, file_path, session_name, + category_id, config + """ + return self._execute_query("get_episode_metadata", episode_id=episode_id) + + def get_agent_types(self, episode_id: str) -> pd.DataFrame: + """ + Get distinct agent types for an episode. + + Parameters + ---------- + episode_id : str + Episode identifier + + Returns + ------- + pd.DataFrame + Agent types with column: agent_type_id + """ + return self._execute_query("get_agent_types", episode_id=episode_id) + + def get_agent_types_for_session(self, session_id: str) -> pd.DataFrame: + """ + Get distinct agent types across all episodes in a session. + + Parameters + ---------- + session_id : str + Session identifier + + Returns + ------- + pd.DataFrame + Agent types with column: agent_type_id + """ + return self._execute_query("get_agent_types_for_session", session_id=session_id) + + # ==================== Spatial Analysis ==================== + + def get_spatial_heatmap( + self, + episode_id: Optional[str] = None, + session_id: Optional[str] = None, + bin_size: float = 10.0, + start_time: Optional[int] = None, + end_time: Optional[int] = None, + agent_type: str = "agent", + min_count: int = 1, + **kwargs, # Accept extra parameters (e.g., window_size, min_samples from shared context) + ) -> pd.DataFrame: + """ + Compute spatial density heatmap with binned positions. + + PERFORMANCE NOTE: This method uses separate optimized queries for episode + and session scopes to avoid query planner issues with NULL checks. + + Parameters + ---------- + episode_id : str, optional + Episode to analyze (mutually exclusive with session_id) + session_id : str, optional + Session to analyze - aggregates all episodes in session (mutually exclusive with episode_id) + bin_size : float, default=10.0 + Spatial bin size in scene units + start_time : int, optional + Start time index (None = from beginning) + end_time : int, optional + End time index (None = to end) + agent_type : str, default='agent' + Agent type to filter ('agent', 'target', 'all') + min_count : int, default=1 + Minimum observations per bin to include + **kwargs + Additional parameters (ignored) + + Returns + ------- + pd.DataFrame + Heatmap with columns: x_bin, y_bin, z_bin, density, avg_vx, avg_vy, avg_vz + """ + if episode_id is None and session_id is None: + raise ValueError("Either episode_id or session_id must be provided") + if episode_id is not None and session_id is not None: + raise ValueError("Cannot specify both episode_id and session_id") + + # Use scope-specific query for optimal performance + if episode_id is not None: + return self._execute_query( + "get_spatial_heatmap_episode", + episode_id=episode_id, + bin_size=bin_size, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + min_count=min_count, + ) + else: + return self._execute_query( + "get_spatial_heatmap_session", + session_id=session_id, + bin_size=bin_size, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + min_count=min_count, + ) + + # ==================== Basic Data Viewer ==================== + + def get_episode_tracks( + self, + episode_id: str, + start_time: Optional[int] = None, + end_time: Optional[int] = None, + agent_type: str = "agent", + **kwargs, + ) -> pd.DataFrame: + """ + Get position and velocity data for animation. + + Parameters + ---------- + episode_id : str + Episode to analyze + start_time : int, optional + Start time index + end_time : int, optional + End time index + agent_type : str, default='agent' + Agent type to filter ('agent', 'target', 'all') + **kwargs + Additional parameters (ignored) + + Returns + ------- + pd.DataFrame + Tracks with columns: agent_id, time_index, x, y, z, v_x, v_y, v_z, speed + """ + return self._execute_query( + "get_episode_tracks", + episode_id=episode_id, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + ) + + def get_extended_properties_timeseries( + self, + episode_id: str, + window_size: int = 100, + start_time: Optional[int] = None, + end_time: Optional[int] = None, + agent_type: str = "agent", + property_ids: Optional[list] = None, + lower_quantile: float = 0.10, + upper_quantile: float = 0.90, + **kwargs, + ) -> pd.DataFrame: + """ + Get aggregated time series for extended properties. + + This is a property-agnostic query that returns windowed statistics + for any extended properties. Filter by property_ids in Python after + retrieval if needed. + + Parameters + ---------- + episode_id : str + Episode to analyze + window_size : int, default=100 + Number of frames per window + start_time : int, optional + Start time index + end_time : int, optional + End time index + agent_type : str, default='agent' + Agent type to filter ('agent', 'target', 'all') + property_ids : list, optional + List of property IDs to filter (applied in Python after query) + lower_quantile : float, default=0.10 + Lower quantile for uncertainty band (e.g., 0.10 for 10th percentile) + upper_quantile : float, default=0.90 + Upper quantile for uncertainty band (e.g., 0.90 for 90th percentile) + **kwargs + Additional parameters (ignored) + + Returns + ------- + pd.DataFrame + Time series with columns: time_window, property_id, n_observations, + avg_value, std_value, min_value, max_value, median_value, q_lower, q_upper + Filtered to property_ids if provided. + """ + df = self._execute_query( + "get_extended_properties_timeseries", + episode_id=episode_id, + window_size=window_size, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + lower_quantile=lower_quantile, + upper_quantile=upper_quantile, + ) + + # Filter by property_ids if provided + if property_ids is not None and len(df) > 0: + df = df[df["property_id"].isin(property_ids)] + + return df + + def get_property_distributions( + self, + episode_id: Optional[str] = None, + session_id: Optional[str] = None, + start_time: Optional[int] = None, + end_time: Optional[int] = None, + agent_type: str = "agent", + property_ids: Optional[list] = None, + **kwargs, + ) -> pd.DataFrame: + """ + Get raw property values for histogram generation. + + This is a property-agnostic query that returns individual property + values for distribution analysis. Filter by property_ids in Python + after retrieval if needed. + + Supports both episode-level and session-level analysis. + + PERFORMANCE NOTE: This method uses separate optimized queries for episode + and session scopes to avoid query planner issues with NULL checks that + caused 2x performance degradation. + + Parameters + ---------- + episode_id : str, optional + Episode to analyze (mutually exclusive with session_id) + session_id : str, optional + Session to analyze - aggregates all episodes in session (mutually exclusive with episode_id) + start_time : int, optional + Start time index + end_time : int, optional + End time index + agent_type : str, default='agent' + Agent type to filter ('agent', 'target', 'all') + property_ids : list, optional + List of property IDs to filter (applied in Python after query) + **kwargs + Additional parameters (ignored) + + Returns + ------- + pd.DataFrame + Property values with columns: property_id, value_float + Filtered to property_ids if provided. + """ + if episode_id is None and session_id is None: + raise ValueError("Either episode_id or session_id must be provided") + if episode_id is not None and session_id is not None: + raise ValueError("Cannot specify both episode_id and session_id") + + # Use scope-specific query for optimal performance + if episode_id is not None: + df = self._execute_query( + "get_property_distributions_episode", + episode_id=episode_id, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + ) + else: + df = self._execute_query( + "get_property_distributions_session", + session_id=session_id, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + ) + + # Filter by property_ids if provided + if property_ids is not None and len(df) > 0: + df = df[df["property_id"].isin(property_ids)] + + return df + + def get_available_properties( + self, + episode_id: Optional[str] = None, + session_id: Optional[str] = None, + agent_type: str = "agent", + start_time: Optional[int] = None, + end_time: Optional[int] = None, + **kwargs, + ) -> pd.DataFrame: + """ + Get list of available extended properties for an episode or session. + + Supports both episode-level and session-level analysis. + + PERFORMANCE NOTE: This method uses separate optimized queries for episode + and session scopes to avoid query planner issues with NULL checks and OR + conditions that caused 3x performance degradation. + + Parameters + ---------- + episode_id : str, optional + Episode to analyze (mutually exclusive with session_id) + session_id : str, optional + Session to analyze - aggregates all episodes in session (mutually exclusive with episode_id) + agent_type : str, default='agent' + Agent type to filter ('agent', 'target', 'all') + start_time : int, optional + Start time index for filtering (session scope only) + end_time : int, optional + End time index for filtering (session scope only) + **kwargs + Additional parameters (ignored) + + Returns + ------- + pd.DataFrame + Available properties with columns: property_id, property_name, + description, unit, data_type + """ + if episode_id is None and session_id is None: + raise ValueError("Either episode_id or session_id must be provided") + if episode_id is not None and session_id is not None: + raise ValueError("Cannot specify both episode_id and session_id") + + # Use scope-specific query for optimal performance + if episode_id is not None: + return self._execute_query( + "get_available_properties_episode", + episode_id=episode_id, + agent_type=agent_type, + ) + else: + return self._execute_query( + "get_available_properties_session", + session_id=session_id, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + ) + + def get_extended_properties_raw( + self, + episode_id: str, + start_time: Optional[int] = None, + end_time: Optional[int] = None, + agent_type: str = "agent", + property_ids: Optional[list] = None, + **kwargs, + ) -> pd.DataFrame: + """ + Get raw (unaggregated) extended property values with time indices. + + Returns individual observations for plotting agent trajectories + as lines on time series plots. Data is in long format with + property_id as a column for flexibility. + + Parameters + ---------- + episode_id : str + Episode to analyze + start_time : int, optional + Start time index + end_time : int, optional + End time index + agent_type : str, default='agent' + Agent type to filter ('agent', 'target', 'all') + property_ids : list, optional + List of property IDs to filter (applied in Python after query) + **kwargs + Additional parameters (ignored) + + Returns + ------- + pd.DataFrame + Raw property values with columns: time_index, agent_id, property_id, value_float + Filtered to property_ids if provided. + """ + df = self._execute_query( + "get_extended_properties_raw", + episode_id=episode_id, + start_time=start_time, + end_time=end_time, + agent_type=agent_type, + ) + + # Filter by property_ids if provided + if property_ids is not None and len(df) > 0: + df = df[df["property_id"].isin(property_ids)] + + return df + + # ==================== Correlations ==================== + + def get_velocity_correlations( + self, + episode_id: str, + start_time: Optional[int] = None, + end_time: Optional[int] = None, + min_samples: int = 100, + agent_type: str = "agent", + **kwargs, # Accept extra parameters (e.g., bin_size, window_size from shared context) + ) -> pd.DataFrame: + """ + Compute pairwise velocity correlations between agents. + + Warning: O(n²) computation, can be slow for many agents. + Note: Only supports episode-level analysis. Session-level correlation is disabled. + + Parameters + ---------- + episode_id : str + Episode to analyze + start_time : int, optional + Start time index + end_time : int, optional + End time index + min_samples : int, default=100 + Minimum number of time points required for correlation + agent_type : str, default='agent' + Agent type to filter ('agent', 'target', 'all') + **kwargs + Additional parameters (ignored) + + Returns + ------- + pd.DataFrame + Correlations with columns: agent_i, agent_j, v_x_correlation, + v_y_correlation, v_z_correlation, n_samples + """ + return self._execute_query( + "get_velocity_correlations", + episode_id=episode_id, + start_time=start_time, + end_time=end_time, + min_samples=min_samples, + agent_type=agent_type, + ) + + def get_distance_correlations( + self, + episode_id: str, + start_time: Optional[int] = None, + end_time: Optional[int] = None, + min_samples: int = 100, + **kwargs, # Accept extra parameters (e.g., bin_size, window_size from shared context) + ) -> pd.DataFrame: + """ + Compute pairwise distance-to-target correlations between agents. + + Warning: O(n²) computation, can be slow for many agents. + Note: Only supports episode-level analysis. Session-level correlation is disabled. + + Parameters + ---------- + episode_id : str + Episode to analyze + start_time : int, optional + Start time index + end_time : int, optional + End time index + min_samples : int, default=100 + Minimum number of time points required for correlation + **kwargs + Additional parameters (ignored) + + Returns + ------- + pd.DataFrame + Correlations with columns: agent_i, agent_j, distance_correlation, + n_samples + """ + return self._execute_query( + "get_distance_correlations", + episode_id=episode_id, + start_time=start_time, + end_time=end_time, + min_samples=min_samples, + ) + + +# Convenience function for quick testing +def main(): + """ + Test query backend with basic queries. + """ + import sys + + print("=" * 60) + print("Query Backend Test") + print("=" * 60) + + try: + # Initialize + query = QueryBackend() + print(f"✓ Connected to {query.config.backend}") + print() + + # Get sessions + print("Sessions:") + sessions = query.get_sessions(category_id="boids_3d") + print(f" Found {len(sessions)} sessions") + if len(sessions) > 0: + print(f" First session: {sessions.iloc[0]['session_name']}") + print() + + # Get episodes + if len(sessions) > 0: + session_id = sessions.iloc[0]["session_id"] + print(f"Episodes for session {session_id}:") + episodes = query.get_episodes(session_id) + print(f" Found {len(episodes)} episodes") + + # Test spatial heatmap + if len(episodes) > 0: + episode_id = episodes.iloc[0]["episode_id"] + print(f"\nSpatial heatmap for episode {episode_id}:") + heatmap = query.get_spatial_heatmap(episode_id, bin_size=20.0) + print(f" Generated {len(heatmap)} bins") + print( + f" Density range: {heatmap['density'].min():.0f} - {heatmap['density'].max():.0f}" + ) + + # Display heatmap data + print("\n Heatmap sample (top 10 densest bins):") + top_bins = heatmap.nlargest(10, "density")[ + ["x_bin", "y_bin", "z_bin", "density", "avg_vx", "avg_vy", "avg_vz"] + ] + print(top_bins.to_string(index=False)) + + # Create and show 3D scatter plot + print("\n Creating 3D scatter plot...") + try: + import matplotlib.pyplot as plt + from mpl_toolkits.mplot3d import Axes3D # noqa: F401 + + # Create 3D plot + fig = plt.figure(figsize=(14, 10)) + ax = fig.add_subplot(111, projection="3d") + + # Create scatter plot with density as color and size + scatter = ax.scatter( + heatmap["x_bin"], + heatmap["y_bin"], + heatmap["z_bin"], + c=heatmap["density"], + s=heatmap["density"] + / heatmap["density"].max() + * 100, # Scale size by density + cmap="viridis", + alpha=0.6, + edgecolors="w", + linewidth=0.5, + ) + + # Add colorbar + cbar = plt.colorbar(scatter, ax=ax, shrink=0.5, aspect=5) + cbar.set_label("Density", rotation=270, labelpad=15) + + # Labels and title + ax.set_xlabel("X Position (bins)") + ax.set_ylabel("Y Position (bins)") + ax.set_zlabel("Z Position (bins)") + ax.set_title(f"3D Spatial Density Heatmap\nEpisode: {episode_id}") + + # Set viewing angle + ax.view_init(elev=20, azim=45) + + plt.tight_layout() + + # Save plot to file + output_file = "/tmp/spatial_heatmap_3d.png" + plt.savefig(output_file, dpi=150, bbox_inches="tight") + print(f" ✓ 3D scatter plot saved to {output_file}") + + # Show interactively if available + plt.show() + except ImportError: + print(" ✗ matplotlib not available, skipping plot") + except Exception as e: + print(f" ✗ Error creating plot: {e}") + + # Close + query.close() + print("\n✓ All tests passed") + + except Exception as e: + print(f"\n✗ Error: {e}") + import traceback + + traceback.print_exc() + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/collab_env/data/db/schema/01_core_tables.sql b/collab_env/data/db/schema/01_core_tables.sql new file mode 100644 index 00000000..a9dd1fe0 --- /dev/null +++ b/collab_env/data/db/schema/01_core_tables.sql @@ -0,0 +1,112 @@ +-- ============================================================================= +-- 01_core_tables.sql +-- Core dimension and fact tables for tracking analytics +-- PostgreSQL-compatible +-- ============================================================================= + +-- ============================================================================= +-- DIMENSION TABLES +-- ============================================================================= + +CREATE TABLE categories ( + category_id VARCHAR PRIMARY KEY, + category_name VARCHAR NOT NULL, + description TEXT +); + +COMMENT ON TABLE categories IS 'Categories for data source types (sessions only): boids_3d, boids_2d, tracking_csv'; +COMMENT ON COLUMN categories.category_id IS 'Unique category identifier (e.g., boids_3d, tracking_csv)'; + +-- ============================================================================= + +CREATE TABLE sessions ( + session_id VARCHAR PRIMARY KEY, + session_name VARCHAR NOT NULL, + category_id VARCHAR NOT NULL REFERENCES categories(category_id) ON DELETE CASCADE, + created_at TIMESTAMP DEFAULT now(), + config JSONB, -- Full configuration from YAML/config.pt + metadata JSONB -- Environment, mesh paths, notes +); + +CREATE INDEX idx_sessions_category ON sessions(category_id); + +COMMENT ON TABLE sessions IS 'Top-level container for related episodes (simulation run or fieldwork session)'; +COMMENT ON COLUMN sessions.category_id IS 'Category reference (defined in categories table)'; +COMMENT ON COLUMN sessions.config IS 'Full configuration as JSON (from YAML or .pt config)'; +COMMENT ON COLUMN sessions.metadata IS 'Additional metadata: notes, environment, mesh references'; + +-- ============================================================================= + +CREATE TABLE episodes ( + episode_id VARCHAR PRIMARY KEY, + session_id VARCHAR NOT NULL REFERENCES sessions(session_id) ON DELETE CASCADE, + episode_number INTEGER NOT NULL, + num_frames INTEGER NOT NULL, + num_agents INTEGER NOT NULL, + frame_rate DOUBLE PRECISION DEFAULT 30.0, + file_path VARCHAR NOT NULL, + created_at TIMESTAMP DEFAULT now() +); + +CREATE INDEX idx_episodes_session ON episodes(session_id); + +COMMENT ON TABLE episodes IS 'Single simulation run or video tracking session'; +COMMENT ON COLUMN episodes.num_frames IS 'Total number of timesteps/frames in episode'; +COMMENT ON COLUMN episodes.frame_rate IS 'Frames per second (typically 30)'; + +-- ============================================================================= + +CREATE TABLE agent_types ( + type_id VARCHAR PRIMARY KEY, + type_name VARCHAR NOT NULL, + description TEXT +); + +COMMENT ON TABLE agent_types IS 'Agent/track type definitions (agent, target, bird, rat, etc.)'; + +-- ============================================================================= +-- FACT TABLE - Core observations (positions and velocities only) +-- ============================================================================= + +CREATE TABLE observations ( + -- Surrogate key for foreign key references + observation_id BIGSERIAL UNIQUE NOT NULL, + + -- Natural composite primary key + episode_id VARCHAR NOT NULL REFERENCES episodes(episode_id) ON DELETE CASCADE, + time_index INTEGER NOT NULL, + agent_id INTEGER NOT NULL, + + -- Dimensions + agent_type_id VARCHAR NOT NULL REFERENCES agent_types(type_id), + + -- Core spatial data (required) + x DOUBLE PRECISION NOT NULL, + y DOUBLE PRECISION NOT NULL, + z DOUBLE PRECISION, -- NULL for 2D data + + -- Core velocity data (optional, may be computed) + v_x DOUBLE PRECISION, + v_y DOUBLE PRECISION, + v_z DOUBLE PRECISION, + + -- Primary key: ensures unique (episode, time, agent, type) tuple + -- Includes agent_type_id to allow same agent_id for different entity types (agent vs env) + PRIMARY KEY (episode_id, time_index, agent_id, agent_type_id) +); + +-- Essential indexes +CREATE INDEX idx_obs_episode ON observations(episode_id); +CREATE INDEX idx_obs_episode_time ON observations(episode_id, time_index); +CREATE INDEX idx_obs_agent_type ON observations(agent_type_id); + +COMMENT ON TABLE observations IS 'Core time-series data: positions and velocities (universal data only). Session-specific data in extended_properties.'; +COMMENT ON COLUMN observations.observation_id IS 'Surrogate key for foreign key references (auto-increment)'; +COMMENT ON COLUMN observations.time_index IS 'Frame number / timestep (0-indexed)'; +COMMENT ON COLUMN observations.agent_id IS 'Agent ID within episode'; +COMMENT ON COLUMN observations.z IS 'Z position (NULL for 2D data)'; +COMMENT ON COLUMN observations.v_x IS 'X velocity component (may be NULL if not stored)'; + +-- ============================================================================= +-- END OF CORE TABLES +-- ============================================================================= diff --git a/collab_env/data/db/schema/02_extended_properties.sql b/collab_env/data/db/schema/02_extended_properties.sql new file mode 100644 index 00000000..7cc927c1 --- /dev/null +++ b/collab_env/data/db/schema/02_extended_properties.sql @@ -0,0 +1,46 @@ +-- ============================================================================= +-- 02_extended_properties.sql +-- Extended properties EAV schema with category-based organization +-- PostgreSQL-compatible +-- ============================================================================= + +-- ============================================================================= +-- PROPERTY DEFINITIONS - Define available extended properties +-- ============================================================================= + +CREATE TABLE property_definitions ( + property_id VARCHAR PRIMARY KEY, + property_name VARCHAR NOT NULL, + data_type VARCHAR NOT NULL, -- float, vector, string + description TEXT, + unit VARCHAR -- meters, pixels, m/s^2, etc. +); + +COMMENT ON TABLE property_definitions IS 'Flat list of all available extended properties (computed and raw)'; +COMMENT ON COLUMN property_definitions.data_type IS 'Data type: float, vector, string'; +COMMENT ON COLUMN property_definitions.unit IS 'Unit of measurement (e.g., scene_units, pixels, m/s^2)'; + +-- ============================================================================= +-- EXTENDED PROPERTIES - EAV table for flexible property storage +-- ============================================================================= + +CREATE TABLE extended_properties ( + observation_id BIGINT NOT NULL REFERENCES observations(observation_id) ON DELETE CASCADE, + property_id VARCHAR NOT NULL REFERENCES property_definitions(property_id), + + value_float DOUBLE PRECISION, -- For numeric properties + value_text TEXT, -- For strings, arrays (JSON), etc. + + PRIMARY KEY (observation_id, property_id) +); + +CREATE INDEX idx_ext_props_observation ON extended_properties(observation_id); +CREATE INDEX idx_ext_props_property ON extended_properties(property_id); + +COMMENT ON TABLE extended_properties IS 'EAV table for flexible extended properties'; +COMMENT ON COLUMN extended_properties.value_float IS 'Use for numeric properties (distances, accelerations, etc.)'; +COMMENT ON COLUMN extended_properties.value_text IS 'Use for strings, arrays (stored as JSON), etc.'; + +-- ============================================================================= +-- END OF EXTENDED PROPERTIES +-- ============================================================================= diff --git a/collab_env/data/db/schema/03_seed_data.sql b/collab_env/data/db/schema/03_seed_data.sql new file mode 100644 index 00000000..b9489867 --- /dev/null +++ b/collab_env/data/db/schema/03_seed_data.sql @@ -0,0 +1,99 @@ +-- ============================================================================= +-- 03_seed_data.sql +-- Seed data: default agent types, property categories, and property definitions +-- PostgreSQL-compatible +-- ============================================================================= + +-- ============================================================================= +-- AGENT TYPES - Common agent/track types +-- ============================================================================= + +INSERT INTO agent_types (type_id, type_name, description) VALUES + ('agent', 'agent', 'Generic simulated agent (boid)'), + ('env', 'environment', 'Environment entity (walls, obstacles, boundaries)'), + ('target', 'target', 'Target object in simulation'), + ('food', 'food', 'Stationary food target in 2D boids simulation'), + ('bird', 'bird', 'Bird detected in video tracking'), + ('rat', 'rat', 'Rat detected in video tracking'), + ('gerbil', 'gerbil', 'Gerbil detected in video tracking') +ON CONFLICT (type_id) DO NOTHING; + +-- ============================================================================= +-- CATEGORIES - Session and property categories +-- ============================================================================= + +INSERT INTO categories (category_id, category_name, description) VALUES + ('boids_3d', '3D Boids Simulations', 'Sessions from 3D boid simulations'), + ('boids_2d', '2D Boids Simulations', 'Sessions from 2D boid simulations'), + ('boids_2d_rollout', '2D Boids GNN Rollout', 'GNN model predictions on 2D boids test data'), + ('tracking_csv', 'Real-World Tracking', 'Sessions from video tracking (CSV data)') +ON CONFLICT (category_id) DO NOTHING; + +-- ============================================================================= +-- PROPERTY DEFINITIONS - Extended properties +-- ============================================================================= + +-- 3D Boids properties +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) VALUES + -- Distance metrics + ('distance_to_target_center', 'Distance to Target Center', 'float', 'Euclidean distance to target centroid', 'scene_units'), + ('distance_to_target_mesh', 'Distance to Target Mesh', 'float', 'Distance to nearest point on target mesh', 'scene_units'), + ('distance_to_scene_mesh', 'Distance to Scene Mesh', 'float', 'Distance to scene boundary mesh', 'scene_units'), + + -- Target mesh closest point (stored as separate components) + ('target_mesh_closest_x', 'Target Mesh Closest Point X', 'float', 'X coordinate of closest point on target mesh', 'scene_units'), + ('target_mesh_closest_y', 'Target Mesh Closest Point Y', 'float', 'Y coordinate of closest point on target mesh', 'scene_units'), + ('target_mesh_closest_z', 'Target Mesh Closest Point Z', 'float', 'Z coordinate of closest point on target mesh', 'scene_units'), + + -- Scene mesh closest point + ('scene_mesh_closest_x', 'Scene Mesh Closest Point X', 'float', 'X coordinate of closest point on scene mesh', 'scene_units'), + ('scene_mesh_closest_y', 'Scene Mesh Closest Point Y', 'float', 'Y coordinate of closest point on scene mesh', 'scene_units'), + ('scene_mesh_closest_z', 'Scene Mesh Closest Point Z', 'float', 'Z coordinate of closest point on scene mesh', 'scene_units') +ON CONFLICT (property_id) DO NOTHING; + +-- Tracking CSV properties +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) VALUES + ('bbox_x1', 'Bounding Box X1', 'float', 'Top-left X coordinate of bounding box', 'pixels'), + ('bbox_y1', 'Bounding Box Y1', 'float', 'Top-left Y coordinate of bounding box', 'pixels'), + ('bbox_x2', 'Bounding Box X2', 'float', 'Bottom-right X coordinate of bounding box', 'pixels'), + ('bbox_y2', 'Bounding Box Y2', 'float', 'Bottom-right Y coordinate of bounding box', 'pixels') +ON CONFLICT (property_id) DO NOTHING; + +-- Computed properties +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) VALUES + ('acceleration_x', 'Acceleration X', 'float', 'X component of acceleration (computed from velocity)', 'scene_units/frame^2'), + ('acceleration_y', 'Acceleration Y', 'float', 'Y component of acceleration (computed from velocity)', 'scene_units/frame^2'), + ('acceleration_z', 'Acceleration Z', 'float', 'Z component of acceleration (computed from velocity)', 'scene_units/frame^2'), + ('speed', 'Speed', 'float', 'Magnitude of velocity vector', 'scene_units/frame'), + ('acceleration_magnitude', 'Acceleration Magnitude', 'float', 'Magnitude of acceleration vector', 'scene_units/frame^2') +ON CONFLICT (property_id) DO NOTHING; + +-- Tracking metadata properties (moved from observations table) +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) VALUES + ('confidence', 'Detection Confidence', 'float', 'Detection confidence score from tracking', 'probability'), + ('detection_class', 'Detection Class', 'string', 'Detected object class label', 'label') +ON CONFLICT (property_id) DO NOTHING; + +-- GNN Attention weight properties +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) VALUES + ('attn_weight_self', 'Self Attention Weight', 'float', 'Agent self-attention weight', 'dimensionless'), + ('attn_weight_boid', 'Boid Attention Weight', 'float', 'Sum of attention to other boid agents', 'dimensionless'), + ('attn_weight_food', 'Food Attention Weight', 'float', 'Attention to food agent', 'dimensionless') +ON CONFLICT (property_id) DO NOTHING; + +-- 2D Boids distance metrics +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) VALUES + ('distance_to_food', 'Distance to Food', 'float', 'Euclidean distance from boid to food location', 'scene_units'), + ('distance_to_food_actual', 'Distance to Actual Food', 'float', 'Euclidean distance from boid to true food location (from actual episode) - predicted episodes only', 'scene_units'), + ('distance_to_food_predicted', 'Distance to Predicted Food', 'float', 'Euclidean distance from boid to GNN-predicted food location - predicted episodes only', 'scene_units') +ON CONFLICT (property_id) DO NOTHING; + +-- GNN prediction metrics +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) VALUES + ('prediction_error', 'Position Prediction Error', 'float', 'Euclidean distance between actual and predicted agent position - predicted episodes only', 'scene_units'), + ('loss', 'Frame-Level MSE Loss', 'float', 'Mean squared error loss for acceleration prediction (averaged over all agents) - predicted episodes only', 'scene_units^2/frame^4') +ON CONFLICT (property_id) DO NOTHING; + +-- ============================================================================= +-- END OF SEED DATA +-- ============================================================================= diff --git a/collab_env/data/db/schema/04_views_examples.sql b/collab_env/data/db/schema/04_views_examples.sql new file mode 100644 index 00000000..2d36cb9d --- /dev/null +++ b/collab_env/data/db/schema/04_views_examples.sql @@ -0,0 +1,261 @@ +-- ============================================================================= +-- 04_views_examples.sql +-- Example queries and view templates (NOT created by default) +-- Use these as templates for application queries or create views as needed +-- ============================================================================= + +-- ============================================================================= +-- EXAMPLE 1: Query observations with extended properties for a session +-- ============================================================================= + +/* +-- Get all observations with extended properties for a session's episodes +SELECT + o.episode_id, + o.time_index, + o.agent_id, + o.agent_type_id, + o.x, o.y, o.z, + o.v_x, o.v_y, o.v_z, + pd.property_name, + ep.value_float as property_value, + pd.unit +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = 'episode-0-...' +ORDER BY o.time_index, o.agent_id, pd.property_name; +*/ + +-- ============================================================================= +-- EXAMPLE 2: Get available properties for a session (property discovery) +-- ============================================================================= + +/* +-- Discover all properties that exist for a session (query actual data) +SELECT DISTINCT + pd.property_id, + pd.property_name, + pd.data_type, + pd.description, + pd.unit +FROM property_definitions pd +WHERE pd.property_id IN ( + SELECT DISTINCT ep.property_id + FROM extended_properties ep + JOIN observations o ON ep.observation_id = o.observation_id + JOIN episodes e ON o.episode_id = e.episode_id + WHERE e.session_id = 'session-...' +) +ORDER BY pd.property_name; +*/ + +-- ============================================================================= +-- EXAMPLE 3: Pivot extended properties to columns (dynamic) +-- ============================================================================= + +/* +-- Pivot specific properties for an episode +-- Note: This requires knowing which properties to pivot +-- In practice, generate this SQL dynamically based on available properties + +SELECT + o.observation_id, + o.episode_id, + o.time_index, + o.agent_id, + o.x, o.y, o.z, + o.v_x, o.v_y, o.v_z, + MAX(CASE WHEN ep.property_id = 'distance_to_target_center' THEN ep.value_float END) as distance_to_target_center, + MAX(CASE WHEN ep.property_id = 'distance_to_target_mesh' THEN ep.value_float END) as distance_to_target_mesh, + MAX(CASE WHEN ep.property_id = 'distance_to_scene_mesh' THEN ep.value_float END) as distance_to_scene_mesh, + MAX(CASE WHEN ep.property_id = 'speed' THEN ep.value_float END) as speed +FROM observations o +LEFT JOIN extended_properties ep ON o.observation_id = ep.observation_id +WHERE o.episode_id = 'episode-0-...' +GROUP BY o.observation_id, o.episode_id, o.time_index, o.agent_id, + o.x, o.y, o.z, o.v_x, o.v_y, o.v_z +ORDER BY o.time_index, o.agent_id; +*/ + +-- ============================================================================= +-- EXAMPLE 4: Spatial heatmap (binned density) +-- ============================================================================= + +/* +-- 2D spatial density with velocity averaging +SELECT + floor(x / 10) * 10 as x_bin, + floor(y / 10) * 10 as y_bin, + count(*) as density, + avg(v_x) as avg_vx, + avg(v_y) as avg_vy +FROM observations +WHERE episode_id = 'episode-0-...' + AND time_index BETWEEN 500 AND 1000 +GROUP BY x_bin, y_bin +HAVING count(*) > 5 +ORDER BY density DESC; +*/ + +-- ============================================================================= +-- EXAMPLE 5: Time-series velocity statistics +-- ============================================================================= + +/* +-- Moving time window statistics (100-frame windows) +SELECT + floor(time_index / 100) * 100 as time_window, + agent_type_id, + count(*) as n_observations, + avg(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0))) as avg_speed, + stddev_pop(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0))) as std_speed, + percentile_cont(0.5) WITHIN GROUP (ORDER BY sqrt(v_x*v_x + v_y*v_y)) as median_speed +FROM observations +WHERE episode_id = 'episode-0-...' + AND v_x IS NOT NULL +GROUP BY time_window, agent_type_id +ORDER BY time_window, agent_type_id; +*/ + +-- ============================================================================= +-- EXAMPLE 6: Distance to target over time (with extended properties) +-- ============================================================================= + +/* +-- Average distance to target per time window +SELECT + floor(o.time_index / 100) * 100 as time_window, + avg(ep.value_float) as avg_distance_to_target, + stddev_pop(ep.value_float) as std_distance_to_target, + count(*) as n_observations +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +WHERE o.episode_id = 'episode-0-...' + AND ep.property_id = 'distance_to_target_center' + AND o.time_index > 500 -- After target appears +GROUP BY time_window +ORDER BY time_window; +*/ + +-- ============================================================================= +-- EXAMPLE 7: Agent correlation analysis (pairwise distances) +-- ============================================================================= + +/* +-- Correlation between agents' distances to target +WITH agent_distances AS ( + SELECT + o.time_index, + o.agent_id, + ep.value_float as dist_to_target + FROM observations o + JOIN extended_properties ep ON o.observation_id = ep.observation_id + WHERE o.episode_id = 'episode-0-...' + AND ep.property_id = 'distance_to_target_center' +) +SELECT + a.agent_id as agent_i, + b.agent_id as agent_j, + corr(a.dist_to_target, b.dist_to_target) as distance_correlation, + count(*) as n_samples +FROM agent_distances a +JOIN agent_distances b + ON a.time_index = b.time_index + AND a.agent_id < b.agent_id +GROUP BY a.agent_id, b.agent_id +HAVING count(*) > 100 +ORDER BY distance_correlation DESC; +*/ + +-- ============================================================================= +-- EXAMPLE 8: Grafana-friendly time-series query +-- ============================================================================= + +/* +-- Speed over time (suitable for Grafana time-series panel) +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + o.agent_id, + sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0)) as speed +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +WHERE o.episode_id = 'episode-0-...' + AND o.v_x IS NOT NULL +ORDER BY o.time_index, o.agent_id; +*/ + +-- ============================================================================= +-- EXAMPLE 9: Aggregate across episodes in a session +-- ============================================================================= + +/* +-- Average speed across all episodes in a session +SELECT + s.session_name, + e.episode_number, + avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as avg_speed, + count(DISTINCT o.agent_id) as num_agents, + max(o.time_index) as max_time +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +JOIN sessions s ON e.session_id = s.session_id +WHERE s.session_id = 'hackathon-boid-small-200-align-cohesion_sim_run-started-20250926-214330' + AND o.v_x IS NOT NULL +GROUP BY s.session_name, e.episode_number +ORDER BY e.episode_number; +*/ + +-- ============================================================================= +-- EXAMPLE 10: Database statistics +-- ============================================================================= + +/* +-- Check row counts and sizes +SELECT + 'sessions' as table_name, + count(*) as row_count +FROM sessions +UNION ALL +SELECT 'episodes', count(*) FROM episodes +UNION ALL +SELECT 'observations', count(*) FROM observations +UNION ALL +SELECT 'extended_properties', count(*) FROM extended_properties +UNION ALL +SELECT 'agent_types', count(*) FROM agent_types +UNION ALL +SELECT 'property_definitions', count(*) FROM property_definitions +ORDER BY table_name; +*/ + +-- ============================================================================= +-- OPTIONAL: Create a view for common 3D boids queries +-- ============================================================================= + +/* +-- Uncomment to create a view for 3D boids with common properties +CREATE VIEW boids_3d_observations AS +SELECT + o.observation_id, + o.episode_id, + o.time_index, + o.agent_id, + o.agent_type_id, + o.x, o.y, o.z, + o.v_x, o.v_y, o.v_z, + MAX(CASE WHEN ep.property_id = 'distance_to_target_center' THEN ep.value_float END) as distance_to_target_center, + MAX(CASE WHEN ep.property_id = 'distance_to_target_mesh' THEN ep.value_float END) as distance_to_target_mesh, + MAX(CASE WHEN ep.property_id = 'distance_to_scene_mesh' THEN ep.value_float END) as distance_to_scene_mesh +FROM observations o +LEFT JOIN extended_properties ep ON o.observation_id = ep.observation_id +GROUP BY o.observation_id, o.episode_id, o.time_index, o.agent_id, o.agent_type_id, + o.x, o.y, o.z, o.v_x, o.v_y, o.v_z; + +-- Then query the view: +-- SELECT * FROM boids_3d_observations WHERE episode_id = 'episode-0-...' AND time_index BETWEEN 500 AND 1000; +*/ + +-- ============================================================================= +-- END OF EXAMPLES +-- ============================================================================= diff --git a/collab_env/sim/boids_gnn_temp/analyze_dataset.py b/collab_env/sim/boids_gnn_temp/analyze_dataset.py new file mode 100755 index 00000000..53f33f00 --- /dev/null +++ b/collab_env/sim/boids_gnn_temp/analyze_dataset.py @@ -0,0 +1,561 @@ +#!/usr/bin/env python +""" +Exploratory Data Analysis (EDA) for InteractionParticle datasets. + +This script analyzes the distribution of input features and output accelerations +in boid trajectory datasets to understand the data characteristics. + +Generates: + - eda_distributions.png: 3x3 grid showing distributions of positions, velocities, + distances, relative positions/velocities, and accelerations + - true_boid_force_fields.png: 2x3 grid showing ground truth boid force decomposition + (if config file is available) + +Note: + For symmetric force decomposition (position-dependent vs velocity-dependent), + see run_training.py which generates learned_symmetric_decomposition.png after + training a model. This clean separation is most useful for learned models. + +Usage: + python analyze_dataset.py [--save-dir ] + +Example: + python analyze_dataset.py simulated_data/boid_single_species_basic.pt --save-dir analysis_output +""" + +import argparse +import os +import sys +import numpy as np +import torch +import matplotlib.pyplot as plt +from loguru import logger + +from collab_env.sim.boids_gnn_temp.plotting import ( + evaluate_true_boid_forces, + evaluate_true_boid_velocity_forces, + plot_force_decomposition, + plot_symmetric_force_decomposition, +) + + +def compute_pairwise_features(positions, velocities): + """ + Compute pairwise features (relative positions, distances, relative velocities). + + Parameters + ---------- + positions : np.ndarray + Positions [N, 2] + velocities : np.ndarray + Velocities [N, 2] + + Returns + ------- + dict + Dictionary with 'delta_pos', 'distances', 'delta_vel', 'pos_i', 'pos_j' + """ + N = positions.shape[0] + + # Compute all pairwise features + delta_pos = positions[None, :, :] - positions[:, None, :] # [N, N, 2] + distances = np.linalg.norm(delta_pos, axis=-1) # [N, N] + delta_vel = velocities[None, :, :] - velocities[:, None, :] # [N, N, 2] + + # Flatten and remove self-interactions (diagonal) + mask = ~np.eye(N, dtype=bool) + + delta_pos_flat = delta_pos[mask] # [N*(N-1), 2] + distances_flat = distances[mask] # [N*(N-1)] + delta_vel_flat = delta_vel[mask] # [N*(N-1), 2] + + # Also get absolute positions for both particles + # Create indices for i and j + i_indices = np.repeat(np.arange(N), N) # [0,0,...,1,1,...,N-1,N-1,...] + j_indices = np.tile(np.arange(N), N) # [0,1,...,N-1,0,1,...,N-1] + + # Remove self-interactions + mask_flat = mask.flatten() + i_indices_filtered = i_indices[mask_flat] + j_indices_filtered = j_indices[mask_flat] + + pos_i = positions[i_indices_filtered] # [N*(N-1), 2] + pos_j = positions[j_indices_filtered] # [N*(N-1), 2] + + return { + "delta_pos": delta_pos_flat, + "distances": distances_flat, + "delta_vel": delta_vel_flat, + "pos_i": pos_i, + "pos_j": pos_j, + } + + +def analyze_dataset(dataset_path, save_dir=None, device="cpu", scene_size=480.0): + """ + Perform exploratory data analysis on a boid trajectory dataset. + + Parameters + ---------- + dataset_path : str + Path to dataset .pt file + save_dir : str, optional + Directory to save analysis plots + device : str, optional + Device to use for computations (default: 'cpu') + scene_size : float, optional + Scene size in pixels for normalizing config parameters (default: 480.0) + + Notes + ----- + Uses natural timestep dt=1.0 from simulation for velocity/acceleration computation. + """ + logger.info(f"Loading dataset from {dataset_path}") + logger.info(f"Using device: {device}") + + # Load dataset + dataset = torch.load(dataset_path, weights_only=False, map_location=device) + logger.info(f"Dataset type: {type(dataset)}") + logger.info(f"Number of samples: {len(dataset)}") + + # Extract first sample to check structure + positions, species = dataset[0] + logger.info(f"Sample shape: positions={positions.shape}, species={species.shape}") + T, N, D = positions.shape + logger.info(f"Timesteps (T): {T}, Particles (N): {N}, Dimensions (D): {D}") + + # Create save directory + if save_dir: + os.makedirs(save_dir, exist_ok=True) + logger.info(f"Saving analysis to {save_dir}") + + # Collect all data + all_positions = [] + all_velocities = [] + all_accelerations = [] + all_delta_pos = [] + all_distances = [] + all_delta_vel = [] + all_pos_i = [] + all_pos_j = [] + + logger.info("Computing features from all samples...") + for idx, (positions_traj, _) in enumerate(dataset): + if idx % 10 == 0: + logger.info(f"Processing sample {idx}/{len(dataset)}") + + positions_np = positions_traj.numpy() # [T, N, 2] + + # Compute velocities (finite differences, natural timestep dt=1.0) + # v[t] = p[t+1] - p[t] + velocities_np = np.diff(positions_np, axis=0) # [T-1, N, 2] + velocities_np = np.concatenate( + [velocities_np, velocities_np[-1:]], axis=0 + ) # [T, N, 2] + + # Compute accelerations (natural timestep dt=1.0) + # a[t] = v[t+1] - v[t] + accelerations_np = np.diff(velocities_np, axis=0) # [T-1, N, 2] + + # Collect frame-by-frame + for t in range(T - 1): # -1 because acceleration is one shorter + pos_t = positions_np[t] # [N, 2] + vel_t = velocities_np[t] # [N, 2] + acc_t = accelerations_np[t] # [N, 2] + + all_positions.append(pos_t) + all_velocities.append(vel_t) + all_accelerations.append(acc_t) + + # Compute pairwise features + pairwise = compute_pairwise_features(pos_t, vel_t) + all_delta_pos.append(pairwise["delta_pos"]) + all_distances.append(pairwise["distances"]) + all_delta_vel.append(pairwise["delta_vel"]) + all_pos_i.append(pairwise["pos_i"]) + all_pos_j.append(pairwise["pos_j"]) + + # Concatenate all data + positions_all = np.concatenate(all_positions, axis=0) # [num_frames*N, 2] + velocities_all = np.concatenate(all_velocities, axis=0) + accelerations_all = np.concatenate(all_accelerations, axis=0) + delta_pos_all = np.concatenate(all_delta_pos, axis=0) # [num_pairs, 2] + distances_all = np.concatenate(all_distances, axis=0) # [num_pairs] + delta_vel_all = np.concatenate(all_delta_vel, axis=0) # [num_pairs, 2] + + logger.info(f"Total particles-frames: {len(positions_all)}") + logger.info(f"Total pairs: {len(distances_all)}") + + # Print statistics + print("\n" + "=" * 80) + print("DATASET STATISTICS") + print("=" * 80) + + print("\nPositions (absolute):") + print(f" Range: [{positions_all.min():.4f}, {positions_all.max():.4f}]") + print(f" Mean: {positions_all.mean(axis=0)}") + print(f" Std: {positions_all.std(axis=0)}") + + print("\nVelocities (absolute):") + print(f" Range: [{velocities_all.min():.4f}, {velocities_all.max():.4f}]") + print(f" Mean: {velocities_all.mean(axis=0)}") + print(f" Std: {velocities_all.std(axis=0)}") + print(f" Speed mean: {np.linalg.norm(velocities_all, axis=1).mean():.4f}") + print(f" Speed std: {np.linalg.norm(velocities_all, axis=1).std():.4f}") + + print("\nAccelerations (targets):") + print(f" Range: [{accelerations_all.min():.4f}, {accelerations_all.max():.4f}]") + print(f" Mean: {accelerations_all.mean(axis=0)}") + print(f" Std: {accelerations_all.std(axis=0)}") + print(f" Magnitude mean: {np.linalg.norm(accelerations_all, axis=1).mean():.4f}") + print(f" Magnitude std: {np.linalg.norm(accelerations_all, axis=1).std():.4f}") + + print("\nRelative positions (delta_pos):") + print(f" Range: [{delta_pos_all.min():.4f}, {delta_pos_all.max():.4f}]") + print(f" Mean: {delta_pos_all.mean(axis=0)}") + print(f" Std: {delta_pos_all.std(axis=0)}") + + print("\nDistances (between particles):") + print(f" Range: [{distances_all.min():.4f}, {distances_all.max():.4f}]") + print(f" Mean: {distances_all.mean():.4f}") + print(f" Std: {distances_all.std():.4f}") + print(f" Median: {np.median(distances_all):.4f}") + + print("\nRelative velocities (delta_vel):") + print(f" Range: [{delta_vel_all.min():.4f}, {delta_vel_all.max():.4f}]") + print(f" Mean: {delta_vel_all.mean(axis=0)}") + print(f" Std: {delta_vel_all.std(axis=0)}") + print(f" Magnitude mean: {np.linalg.norm(delta_vel_all, axis=1).mean():.4f}") + print(f" Magnitude std: {np.linalg.norm(delta_vel_all, axis=1).std():.4f}") + + print("=" * 80 + "\n") + + # Create visualizations + logger.info("Generating visualizations...") + + fig, axes = plt.subplots(3, 3, figsize=(18, 15)) + fig.suptitle( + f"Dataset EDA: {os.path.basename(dataset_path)}", fontsize=16, fontweight="bold" + ) + + # Row 1: Velocities + ax = axes[0, 0] + ax.scatter(positions_all[:, 0], positions_all[:, 1], alpha=0.1, s=1) + ax.set_xlabel("X Position") + ax.set_ylabel("Y Position") + ax.set_title("Absolute Positions") + ax.set_aspect("equal") + ax.grid(True, alpha=0.3) + + ax = axes[0, 1] + ax.hist2d( + velocities_all[:, 0], velocities_all[:, 1], bins=50, cmap="viridis", cmin=1 + ) + ax.set_xlabel("Velocity X") + ax.set_ylabel("Velocity Y") + ax.set_title("Velocity Vector Distribution") + ax.set_aspect("equal") + plt.colorbar(ax.collections[0], ax=ax, label="Count") + + ax = axes[0, 2] + speeds = np.linalg.norm(velocities_all, axis=1) + ax.hist(speeds, bins=50, alpha=0.7, color="green") + ax.set_xlabel("Speed") + ax.set_ylabel("Frequency") + ax.set_title("Speed Distribution") + ax.grid(True, alpha=0.3) + ax.axvline( + speeds.mean(), color="red", linestyle="--", label=f"Mean: {speeds.mean():.3f}" + ) + ax.legend() + + # Row 2: Pairwise features + ax = axes[1, 0] + ax.hist(distances_all, bins=50, alpha=0.7, color="purple") + ax.set_xlabel("Distance") + ax.set_ylabel("Frequency") + ax.set_title("Pairwise Distance Distribution") + ax.grid(True, alpha=0.3) + ax.axvline( + distances_all.mean(), + color="red", + linestyle="--", + label=f"Mean: {distances_all.mean():.3f}", + ) + ax.legend() + + ax = axes[1, 1] + ax.hist2d(delta_pos_all[:, 0], delta_pos_all[:, 1], bins=50, cmap="viridis", cmin=1) + ax.set_xlabel("Δx (relative position)") + ax.set_ylabel("Δy (relative position)") + ax.set_title("Relative Position Distribution") + ax.set_aspect("equal") + plt.colorbar(ax.collections[0], ax=ax, label="Count") + + ax = axes[1, 2] + delta_vel_mag = np.linalg.norm(delta_vel_all, axis=1) + ax.hist(delta_vel_mag, bins=50, alpha=0.7, color="orange") + ax.set_xlabel("|Δv| (relative velocity magnitude)") + ax.set_ylabel("Frequency") + ax.set_title("Relative Velocity Magnitude") + ax.grid(True, alpha=0.3) + ax.axvline( + delta_vel_mag.mean(), + color="red", + linestyle="--", + label=f"Mean: {delta_vel_mag.mean():.3f}", + ) + ax.legend() + + # Row 3: Accelerations (targets) + ax = axes[2, 0] + acc_mag = np.linalg.norm(accelerations_all, axis=1) + ax.hist(acc_mag, bins=50, alpha=0.7, color="red") + ax.set_xlabel("Acceleration Magnitude") + ax.set_ylabel("Frequency") + ax.set_title("Acceleration Magnitude Distribution") + ax.grid(True, alpha=0.3) + ax.axvline( + acc_mag.mean(), + color="blue", + linestyle="--", + label=f"Mean: {acc_mag.mean():.4f}", + ) + ax.legend() + + ax = axes[2, 1] + ax.hist2d( + accelerations_all[:, 0], + accelerations_all[:, 1], + bins=50, + cmap="coolwarm", + cmin=1, + ) + ax.set_xlabel("Acceleration X") + ax.set_ylabel("Acceleration Y") + ax.set_title("Acceleration Vector Distribution") + ax.set_aspect("equal") + plt.colorbar(ax.collections[0], ax=ax, label="Count") + + ax = axes[2, 2] + # Relative velocity vector distribution (sampled for performance) + sample_indices = np.random.choice( + len(delta_vel_all), size=min(50000, len(delta_vel_all)), replace=False + ) + ax.hist2d( + delta_vel_all[sample_indices, 0], + delta_vel_all[sample_indices, 1], + bins=50, + cmap="plasma", + cmin=1, + ) + ax.set_xlabel("Δv_x (relative velocity)") + ax.set_ylabel("Δv_y (relative velocity)") + ax.set_title("Relative Velocity Vector Distribution") + ax.set_aspect("equal") + plt.colorbar(ax.collections[0], ax=ax, label="Count") + + plt.tight_layout() + + if save_dir: + plot_path = os.path.join(save_dir, "eda_distributions.png") + plt.savefig(plot_path, dpi=300, bbox_inches="tight") + logger.info(f"Saved distribution plots to {plot_path}") + else: + plt.show() + + # Generate ground truth force field plots (if config is available) + logger.info("Generating ground truth force field plots...") + + # Try to load config + config_path = dataset_path.replace(".pt", "_config.pt") + if os.path.exists(config_path): + logger.info(f"Found config at {config_path}") + + try: + boids_config = torch.load(config_path, weights_only=False) + logger.info(f"Using config: {boids_config}") + + # Get the first species config + species_key = list(boids_config.keys())[0] if boids_config else None + if species_key and species_key != "scene_size": + logger.info(f"Using config for species '{species_key}'") + + # Extract species-specific config + species_config = boids_config[species_key] + + # Evaluate ground truth forces + # Determine plot boundary based on which forces are active + # For independent configs, use min_distance; otherwise use visual_range + if species_config.get("independent", False): + # Independent: only avoidance active (within min_distance) + relevant_range = species_config["min_distance"] / scene_size + else: + # Normal: cohesion/alignment active (within visual_range) + relevant_range = species_config["visual_range"] / scene_size + + plot_max_dist = relevant_range * 1.5 # 50% cushion + + true_forces = evaluate_true_boid_forces( + species_config, # Pass species-specific config + grid_size=50, + max_dist=plot_max_dist, + scene_size=scene_size, + ) + + # Plot ground truth forces + # Use visual_range and min_distance from config (normalized to [0,1] space) + visual_range_normalized = species_config["visual_range"] / scene_size + min_distance_normalized = None + if "min_distance" in species_config: + min_distance_normalized = ( + species_config["min_distance"] / scene_size + ) + + if save_dir: + true_plot_path = os.path.join( + save_dir, "true_boid_force_fields.png" + ) + plot_force_decomposition( + true_forces, + save_path=true_plot_path, + title_prefix="Ground Truth Boid", + visual_range=visual_range_normalized, + min_distance=min_distance_normalized, + ) + logger.info(f"Saved force field plot to {true_plot_path}") + else: + plot_force_decomposition( + true_forces, + save_path=None, + title_prefix="Ground Truth Boid", + visual_range=visual_range_normalized, + min_distance=min_distance_normalized, + ) + plt.show() + + # Generate SYMMETRIC force decomposition plots (NEW!) + logger.info("Generating symmetric force decomposition plots...") + + # Compute typical velocity magnitude from dataset + # Use mean relative velocity as a reference + speed_stats = np.linalg.norm(velocities_all, axis=1) + mean_speed = speed_stats.mean() + logger.info(f"Mean speed from dataset: {mean_speed:.4f}") + + # Estimate max relative velocity (2x mean speed as upper bound) + max_rel_vel = min(2.0 * mean_speed, 0.05) # Cap at 0.05 + + # Position-dependent forces (with delta_vel = 0) + pos_forces_true = evaluate_true_boid_forces( + species_config, + grid_size=50, + max_dist=plot_max_dist, + scene_size=scene_size, + ) + + # Velocity-dependent forces (with delta_pos = 0) + vel_forces_true = evaluate_true_boid_velocity_forces( + species_config, + grid_size=50, + max_vel=max_rel_vel, + scene_size=scene_size, + ) + + # Plot symmetric decomposition + if save_dir: + symmetric_plot_path = os.path.join( + save_dir, "true_boid_symmetric_decomposition.png" + ) + plot_symmetric_force_decomposition( + pos_forces_true, + vel_forces_true, + save_path=symmetric_plot_path, + title_prefix="Ground Truth Boid", + visual_range=visual_range_normalized, + ) + logger.info( + f"Saved symmetric decomposition plot to {symmetric_plot_path}" + ) + else: + plot_symmetric_force_decomposition( + pos_forces_true, + vel_forces_true, + save_path=None, + title_prefix="Ground Truth Boid", + visual_range=visual_range_normalized, + ) + plt.show() + + else: + logger.warning("Could not find species config in loaded config file") + + except Exception as e: + logger.warning(f"Could not generate force field plots: {e}") + else: + logger.info( + f"Config file not found at {config_path}, skipping force field plots" + ) + + logger.info("Analysis complete!") + + return { + "positions": positions_all, + "velocities": velocities_all, + "accelerations": accelerations_all, + "delta_pos": delta_pos_all, + "distances": distances_all, + "delta_vel": delta_vel_all, + } + + +def main(): + parser = argparse.ArgumentParser( + description="Exploratory Data Analysis for InteractionParticle datasets", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +Examples: + python analyze_dataset.py simulated_data/boid_single_species_basic.pt + python analyze_dataset.py simulated_data/runpod/boid_single_species_basic.pt --save-dir analysis_runpod + python analyze_dataset.py simulated_data/boid_single_species_basic.pt --save-dir analysis --device mps + """, + ) + + parser.add_argument("dataset", type=str, help="Path to dataset .pt file") + parser.add_argument( + "--save-dir", + type=str, + default=None, + help="Directory to save analysis plots (default: show plots)", + ) + parser.add_argument( + "--device", + type=str, + default="cpu", + help="Device to use for computations (default: cpu)", + ) + parser.add_argument( + "--scene-size", + type=float, + default=480.0, + help="Scene size in pixels (for normalizing config parameters)", + ) + + args = parser.parse_args() + + if not os.path.exists(args.dataset): + logger.error(f"Dataset not found: {args.dataset}") + return 1 + + analyze_dataset( + args.dataset, + save_dir=args.save_dir, + device=args.device, + scene_size=args.scene_size, + ) + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/collab_env/sim/boids_gnn_temp/plotting.py b/collab_env/sim/boids_gnn_temp/plotting.py new file mode 100644 index 00000000..8f842fe3 --- /dev/null +++ b/collab_env/sim/boids_gnn_temp/plotting.py @@ -0,0 +1,943 @@ +""" +Plotting and comparison utilities for InteractionParticle model. +""" + +import numpy as np +import matplotlib.pyplot as plt +from loguru import logger + +# Import actual boid functions for ground truth comparison +from collab_env.sim.boids_gnn_temp.boid import ( + fly_towards_center, + avoid_others, + match_velocity, +) + + +def boid_separation_force(distances, min_distance=15.0, avoid_factor=0.05): + """ + Compute true 2D boid separation force as a function of distance. + + From boid.py avoid_others(): + - For each neighbor within min_distance: + force += (self_pos - other_pos) * avoid_factor + - This is linear in displacement, not inverse-square + + Parameters + ---------- + distances : np.ndarray + Array of distances + min_distance : float + Minimum distance threshold (default: 15 from 2D boids) + avoid_factor : float + Avoidance weight (default: 0.05 from 2D boids) + + Returns + ------- + forces : np.ndarray + Separation forces + """ + forces = np.zeros_like(distances) + mask = distances < min_distance + # Linear repulsion: force = avoid_factor * distance + forces[mask] = avoid_factor * distances[mask] + return forces + + +def boid_alignment_force(distances, visual_range=50.0, matching_factor=0.5): + """ + Compute true 2D boid alignment force as a function of distance. + + From boid.py match_velocity(): + - For neighbors within visual_range: + force += (avg_velocity - self_velocity) * matching_factor + - This is a step function based on visual range + + Note: Actual alignment depends on relative velocities. + + Parameters + ---------- + distances : np.ndarray + Array of distances + visual_range : float + Visual range for alignment (default: 50 from 2D boids) + matching_factor : float + Alignment weight (default: 0.5 from 2D boids) + + Returns + ------- + forces : np.ndarray + Alignment indicator (1 if within visual range, 0 otherwise) + """ + forces = np.zeros_like(distances) + mask = distances < visual_range + forces[mask] = matching_factor + return forces + + +def boid_cohesion_force(distances, visual_range=50.0, centering_factor=0.005): + """ + Compute true 2D boid cohesion force as a function of distance. + + From boid.py fly_towards_center(): + - For neighbors within visual_range: + force += (center_of_mass - self_pos) * centering_factor + - This is linear in distance to center of mass + + Note: Actual cohesion is to center of neighbors, not pairwise. + + Parameters + ---------- + distances : np.ndarray + Array of distances + visual_range : float + Visual range for cohesion (default: 50 from 2D boids) + centering_factor : float + Cohesion weight (default: 0.005 from 2D boids) + + Returns + ------- + forces : np.ndarray + Cohesion forces (proportional to distance) + """ + forces = np.zeros_like(distances) + mask = distances < visual_range + # Cohesion force pulls towards center, so it increases with distance + forces[mask] = centering_factor * distances[mask] + return forces + + +def plot_true_boid_rules_2d(config=None, scene_size=480.0, save_path=None): + """ + Visualize true 2D boid rules as 2D heatmaps. + + Separation and cohesion depend only on position (radially symmetric). + Alignment depends on relative velocity (not visualized here as it's velocity-dependent). + + Parameters + ---------- + config : dict, optional + Boid configuration dict + scene_size : float + Scene size in pixels + save_path : str, optional + Path to save plot + + Returns + ------- + fig : matplotlib.figure.Figure + Figure object + """ + # Default config + if config is None: + config = { + "visual_range": 50.0, + "min_distance": 15.0, + "avoid_factor": 0.05, + "matching_factor": 0.5, + "centering_factor": 0.005, + } + + # Create 2D grid in pixel space + grid_size = 100 + visual_range_normalized = config["visual_range"] / scene_size + x = np.linspace(-visual_range_normalized, visual_range_normalized, grid_size) + y = np.linspace(-visual_range_normalized, visual_range_normalized, grid_size) + X, Y = np.meshgrid(x, y) + + # Compute distances in pixels + distances_px = np.sqrt(X**2 + Y**2) * scene_size + + # Compute true boid forces + separation = np.zeros_like(distances_px) + cohesion = np.zeros_like(distances_px) + + # Separation (repulsion within min_distance) + mask_sep = distances_px < config["min_distance"] + separation[mask_sep] = config["avoid_factor"] * distances_px[mask_sep] + + # Cohesion (attraction within visual_range) + mask_coh = distances_px < config["visual_range"] + cohesion[mask_coh] = config["centering_factor"] * distances_px[mask_coh] + + # Convert to force vectors (radial direction) + # Separation: pushes away (positive radial) + # Cohesion: pulls toward (negative radial) + sep_force_x = np.zeros_like(X) + sep_force_y = np.zeros_like(Y) + coh_force_x = np.zeros_like(X) + coh_force_y = np.zeros_like(Y) + + for i in range(grid_size): + for j in range(grid_size): + dist = np.sqrt(X[i, j] ** 2 + Y[i, j] ** 2) + if dist > 1e-8: + # Unit vector in radial direction + r_hat_x = X[i, j] / dist + r_hat_y = Y[i, j] / dist + + # Separation pushes away + sep_force_x[i, j] = separation[i, j] * r_hat_x * scene_size + sep_force_y[i, j] = separation[i, j] * r_hat_y * scene_size + + # Cohesion pulls toward (negative) + coh_force_x[i, j] = -cohesion[i, j] * r_hat_x * scene_size + coh_force_y[i, j] = -cohesion[i, j] * r_hat_y * scene_size + + # Combined force + total_force_x = sep_force_x + coh_force_x + total_force_y = sep_force_y + coh_force_y + total_magnitude = np.sqrt(total_force_x**2 + total_force_y**2) + sep_magnitude = np.sqrt(sep_force_x**2 + sep_force_y**2) + coh_magnitude = np.sqrt(coh_force_x**2 + coh_force_y**2) + + # Create figure + fig = plt.figure(figsize=(18, 12)) + + # 1. Separation force + ax1 = plt.subplot(2, 3, 1) + skip = 5 + quiver1 = ax1.quiver( + X[::skip, ::skip] * scene_size, + Y[::skip, ::skip] * scene_size, + sep_force_x[::skip, ::skip], + sep_force_y[::skip, ::skip], + sep_magnitude[::skip, ::skip], + cmap="Reds", + scale=None, + scale_units="xy", + ) + circle1 = plt.Circle( + (0, 0), + config["min_distance"], + fill=False, + edgecolor="red", + linestyle="--", + linewidth=2, + label="min_distance", + ) + ax1.add_patch(circle1) + ax1.set_xlabel("Relative Position X (px)", fontsize=10) + ax1.set_ylabel("Relative Position Y (px)", fontsize=10) + ax1.set_title( + "Separation Force\n(Repulsion within min_distance)", + fontsize=11, + fontweight="bold", + ) + ax1.set_aspect("equal") + ax1.grid(True, alpha=0.3) + ax1.legend() + plt.colorbar(quiver1, ax=ax1, label="Force") + + # 2. Separation magnitude heatmap + ax2 = plt.subplot(2, 3, 2) + im2 = ax2.contourf( + X * scene_size, Y * scene_size, sep_magnitude, levels=20, cmap="Reds" + ) + circle2 = plt.Circle( + (0, 0), + config["min_distance"], + fill=False, + edgecolor="darkred", + linestyle="--", + linewidth=2, + ) + ax2.add_patch(circle2) + ax2.set_xlabel("Relative Position X (px)", fontsize=10) + ax2.set_ylabel("Relative Position Y (px)", fontsize=10) + ax2.set_title("Separation Magnitude", fontsize=11, fontweight="bold") + ax2.set_aspect("equal") + plt.colorbar(im2, ax=ax2, label="Force") + + # 3. Cohesion force + ax3 = plt.subplot(2, 3, 3) + quiver3 = ax3.quiver( + X[::skip, ::skip] * scene_size, + Y[::skip, ::skip] * scene_size, + coh_force_x[::skip, ::skip], + coh_force_y[::skip, ::skip], + coh_magnitude[::skip, ::skip], + cmap="Blues_r", + scale=None, + scale_units="xy", + ) + circle3 = plt.Circle( + (0, 0), + config["visual_range"], + fill=False, + edgecolor="blue", + linestyle="--", + linewidth=2, + label="visual_range", + ) + ax3.add_patch(circle3) + ax3.set_xlabel("Relative Position X (px)", fontsize=10) + ax3.set_ylabel("Relative Position Y (px)", fontsize=10) + ax3.set_title( + "Cohesion Force\n(Attraction within visual_range)", + fontsize=11, + fontweight="bold", + ) + ax3.set_aspect("equal") + ax3.grid(True, alpha=0.3) + ax3.legend() + plt.colorbar(quiver3, ax=ax3, label="Force") + + # 4. Cohesion magnitude heatmap + ax4 = plt.subplot(2, 3, 4) + im4 = ax4.contourf( + X * scene_size, Y * scene_size, coh_magnitude, levels=20, cmap="Blues_r" + ) + circle4 = plt.Circle( + (0, 0), + config["visual_range"], + fill=False, + edgecolor="darkblue", + linestyle="--", + linewidth=2, + ) + ax4.add_patch(circle4) + ax4.set_xlabel("Relative Position X (px)", fontsize=10) + ax4.set_ylabel("Relative Position Y (px)", fontsize=10) + ax4.set_title("Cohesion Magnitude", fontsize=11, fontweight="bold") + ax4.set_aspect("equal") + plt.colorbar(im4, ax=ax4, label="Force") + + # 5. Combined force + ax5 = plt.subplot(2, 3, 5) + quiver5 = ax5.quiver( + X[::skip, ::skip] * scene_size, + Y[::skip, ::skip] * scene_size, + total_force_x[::skip, ::skip], + total_force_y[::skip, ::skip], + total_magnitude[::skip, ::skip], + cmap="viridis", + scale=None, + scale_units="xy", + ) + circle5a = plt.Circle( + (0, 0), + config["min_distance"], + fill=False, + edgecolor="red", + linestyle="--", + linewidth=1.5, + alpha=0.7, + ) + circle5b = plt.Circle( + (0, 0), + config["visual_range"], + fill=False, + edgecolor="blue", + linestyle="--", + linewidth=1.5, + alpha=0.7, + ) + ax5.add_patch(circle5a) + ax5.add_patch(circle5b) + ax5.set_xlabel("Relative Position X (px)", fontsize=10) + ax5.set_ylabel("Relative Position Y (px)", fontsize=10) + ax5.set_title( + "Combined Force\n(Separation + Cohesion)", fontsize=11, fontweight="bold" + ) + ax5.set_aspect("equal") + ax5.grid(True, alpha=0.3) + plt.colorbar(quiver5, ax=ax5, label="Force") + + # 6. Combined magnitude heatmap + ax6 = plt.subplot(2, 3, 6) + im6 = ax6.contourf( + X * scene_size, Y * scene_size, total_magnitude, levels=20, cmap="viridis" + ) + circle6a = plt.Circle( + (0, 0), + config["min_distance"], + fill=False, + edgecolor="red", + linestyle="--", + linewidth=1.5, + alpha=0.7, + ) + circle6b = plt.Circle( + (0, 0), + config["visual_range"], + fill=False, + edgecolor="blue", + linestyle="--", + linewidth=1.5, + alpha=0.7, + ) + ax6.add_patch(circle6a) + ax6.add_patch(circle6b) + ax6.set_xlabel("Relative Position X (px)", fontsize=10) + ax6.set_ylabel("Relative Position Y (px)", fontsize=10) + ax6.set_title("Combined Magnitude", fontsize=11, fontweight="bold") + ax6.set_aspect("equal") + plt.colorbar(im6, ax=ax6, label="Force") + + plt.suptitle( + "True 2D Boid Rules (Position-Dependent Forces)", + fontsize=14, + fontweight="bold", + y=0.995, + ) + plt.tight_layout() + + if save_path: + plt.savefig(save_path, dpi=300, bbox_inches="tight") + logger.info(f"Saved true boid rules plot to {save_path}") + + return fig + + +def plot_force_decomposition( + forces_dict, + save_path=None, + title_prefix="Learned", + visual_range=None, + min_distance=None, +): + """ + Plot force decomposition for both velocity slices. + + Creates a 2x3 grid: + - Row 1: Away scenario (Total | Position-Only | Velocity Residual) + - Row 2: Towards scenario (Total | Position-Only | Velocity Residual) + + Parameters + ---------- + forces_dict : dict + Output from evaluate_forces_on_grid or evaluate_true_boid_forces + save_path : str, optional + Path to save figure + title_prefix : str + Prefix for title (e.g., "Learned" or "True Boid") + visual_range : float, optional + Visual range radius to draw as reference circle (in normalized units) + + Returns + ------- + fig : matplotlib.figure.Figure + """ + X = forces_dict["X"] + Y = forces_dict["Y"] + + fig = plt.figure(figsize=(18, 12)) + + # Common settings + skip = 3 # For quiver plots + + def plot_force_field(ax, force_dict, title): + """Helper to plot a single force field.""" + fx, fy, mag = force_dict["x"], force_dict["y"], force_dict["mag"] + + # Filter out near-zero vectors to help with autoscaling + # Define threshold as 1% of max magnitude + max_mag = np.max(mag) + if max_mag > 1e-10: + threshold = max_mag * 0.01 + else: + threshold = 1e-10 + + # Apply skip and create mask for non-zero vectors + X_skip = X[::skip, ::skip] + Y_skip = Y[::skip, ::skip] + fx_skip = fx[::skip, ::skip] + fy_skip = fy[::skip, ::skip] + mag_skip = mag[::skip, ::skip] + + # Mask for vectors above threshold + mask = mag_skip > threshold + + # Only plot non-trivial vectors + if np.sum(mask) > 0: + X_plot = X_skip[mask] + Y_plot = Y_skip[mask] + fx_plot = fx_skip[mask] + fy_plot = fy_skip[mask] + mag_plot = mag_skip[mask] + + # Vector field with autoscaling (filtering fixed the autoscale issue) + quiver = ax.quiver( + X_plot, + Y_plot, + fx_plot, + fy_plot, + mag_plot, + cmap="viridis", + scale=None, + scale_units="xy", + alpha=0.8, + ) + else: + # Fallback: create empty quiver + quiver = ax.quiver([], [], [], [], [], cmap="viridis") + + # Mark origin (node i position) + ax.scatter( + [0], + [0], + c="red", + s=200, + marker="o", + edgecolors="black", + linewidth=2, + zorder=10, + label="Node i (origin)", + ) + + # Draw visual range circle if provided + if visual_range is not None: + circle = plt.Circle( + (0, 0), + visual_range, + fill=False, + edgecolor="gray", + linestyle="--", + linewidth=1.5, + alpha=0.6, + zorder=5, + label=f"Visual range ({visual_range:.3f})", + ) + ax.add_patch(circle) + + # Draw min_distance circle if provided (for true boid forces) + if min_distance is not None: + min_circle = plt.Circle( + (0, 0), + min_distance, + fill=False, + edgecolor="blue", + linestyle="--", + linewidth=1.5, + alpha=0.6, + zorder=5, + label=f"Min distance ({min_distance:.3f})", + ) + ax.add_patch(min_circle) + + ax.set_xlabel("Relative x position (j - i)", fontsize=10) + ax.set_ylabel("Relative y position (j - i)", fontsize=10) + ax.set_title(title, fontsize=11, fontweight="bold") + ax.set_aspect("equal") + ax.grid(True, alpha=0.3) + ax.legend(loc="upper right", fontsize=8) + + return quiver + + # Row 1: Away scenario + ax1 = plt.subplot(2, 3, 1) + q1 = plot_force_field( + ax1, forces_dict["away_total"], "I) Total Force\n(vel_j away from i)" + ) + plt.colorbar(q1, ax=ax1, label="Force mag") + + ax2 = plt.subplot(2, 3, 2) + q2 = plot_force_field(ax2, forces_dict["away_pos"], "II) Position-Only\n(vel=0)") + plt.colorbar(q2, ax=ax2, label="Force mag") + + ax3 = plt.subplot(2, 3, 3) + q3 = plot_force_field( + ax3, forces_dict["away_vel"], "III) Velocity Residual\n(I - II)" + ) + plt.colorbar(q3, ax=ax3, label="Force mag") + + # Row 2: Towards scenario + ax4 = plt.subplot(2, 3, 4) + q4 = plot_force_field( + ax4, forces_dict["towards_total"], "I) Total Force\n(vel_j towards i)" + ) + plt.colorbar(q4, ax=ax4, label="Force mag") + + ax5 = plt.subplot(2, 3, 5) + q5 = plot_force_field(ax5, forces_dict["towards_pos"], "II) Position-Only\n(vel=0)") + plt.colorbar(q5, ax=ax5, label="Force mag") + + ax6 = plt.subplot(2, 3, 6) + q6 = plot_force_field( + ax6, forces_dict["towards_vel"], "III) Velocity Residual\n(I - II)" + ) + plt.colorbar(q6, ax=ax6, label="Force mag") + + plt.suptitle( + f"{title_prefix} Force on j due to i at origin (arrows show force on j at that position)", + fontsize=14, + fontweight="bold", + y=0.995, + ) + plt.tight_layout(rect=[0, 0, 1, 0.99]) + + if save_path: + plt.savefig(save_path, dpi=300, bbox_inches="tight") + logger.info(f"Saved force decomposition plot to {save_path}") + + return fig + + +def evaluate_true_boid_forces(config, grid_size=60, max_dist=50.0, scene_size=480.0): + """ + Evaluate true 2D boid forces on a grid using actual boid.py functions. + + Computes the force experienced by particle j (at grid positions) due to + particle i (at origin). This matches the natural interpretation: arrows show + the force on a particle at that position relative to a reference particle at origin. + + Computes forces from the 3 boid rules: + 1. Cohesion (fly_towards_center): attraction within visual_range + 2. Separation (avoid_others): repulsion within min_distance + 3. Alignment (match_velocity): velocity matching within visual_range + + Parameters + ---------- + config : dict + Boid config with parameters in PIXEL SPACE: + - min_distance: Separation threshold (pixels) + - visual_range: Cohesion and alignment threshold (pixels) + - avoid_factor: Separation weight + - centering_factor: Cohesion weight + - matching_factor: Alignment weight + - speed_limit: Maximum speed (pixels/timestep) + - independent: Whether to skip cohesion/alignment (default: False) + grid_size : int + Grid resolution + max_dist : float + Maximum distance in normalized space (recommend: visual_range * 1.5 / scene_size) + scene_size : float + Scene size in pixels (used to normalize config parameters) + + Returns + ------- + dict with same structure as evaluate_forces_on_grid + """ + # Create 2D grid in normalized space + x = np.linspace(-max_dist, max_dist, grid_size) + y = np.linspace(-max_dist, max_dist, grid_size) + X, Y = np.meshgrid(x, y) + + # Normalize config parameters from pixel space to normalized space + # The grid is in normalized space [-max_dist, max_dist], so we need to + # convert pixel-space thresholds to normalized space + normalized_config = config.copy() + if "min_distance" in config: + normalized_config["min_distance"] = config["min_distance"] / scene_size + if "visual_range" in config: + normalized_config["visual_range"] = config["visual_range"] / scene_size + + # Flatten for iteration + positions = np.stack([X.flatten(), Y.flatten()], axis=-1) + n_points = len(positions) + + # Compute radial unit vectors (direction from i to j) + distances = np.sqrt(X**2 + Y**2).flatten() + r_hat = np.zeros_like(positions) + mask_nonzero = distances > 1e-8 + r_hat[mask_nonzero] = positions[mask_nonzero] / distances[mask_nonzero, np.newaxis] + + # Add 'independent' flag if not present in normalized config + if "independent" not in normalized_config: + normalized_config["independent"] = False + + # Function to compute forces using actual boid functions + def compute_boid_forces(vel_j_array): + """ + Compute forces for all grid points using actual boid.py functions. + + vel_j_array: [n_points, 2] array of velocities for particle j + """ + forces_total = np.zeros_like(positions) + forces_pos_only = np.zeros_like(positions) + + for idx in range(n_points): + # Create boid i at origin (stationary reference point) + boid_i = {"x": 0.0, "y": 0.0, "dx": 0.0, "dy": 0.0, "species": "A"} + + # Create boid j at grid position (this is the boid we compute forces FOR) + pos_j = positions[idx] + vel_j = vel_j_array[idx] + + boid_j = { + "x": pos_j[0], + "y": pos_j[1], + "dx": vel_j[0], + "dy": vel_j[1], + "species": "A", + } + + # Compute force ON boid_j (at grid position) due TO boid_i (at origin) + # Put boid_j in the list and call force functions on it + boids = [boid_j, boid_i] + + fly_towards_center(boid_j, boids, normalized_config) # Rule 1: Cohesion + avoid_others(boid_j, boids, normalized_config) # Rule 2: Separation + match_velocity(boid_j, boids, normalized_config) # Rule 3: Alignment + + # Force is change in velocity (from initial velocity) + forces_total[idx] = [boid_j["dx"] - vel_j[0], boid_j["dy"] - vel_j[1]] + + # Compute position-only force (set velocities to zero) + boid_j_zero = { + "x": pos_j[0], + "y": pos_j[1], + "dx": 0.0, + "dy": 0.0, + "species": "A", + } + boid_i_zero = {"x": 0.0, "y": 0.0, "dx": 0.0, "dy": 0.0, "species": "A"} + boids_zero = [boid_j_zero, boid_i_zero] + + fly_towards_center(boid_j_zero, boids_zero, normalized_config) + avoid_others(boid_j_zero, boids_zero, normalized_config) + match_velocity(boid_j_zero, boids_zero, normalized_config) + + forces_pos_only[idx] = [boid_j_zero["dx"], boid_j_zero["dy"]] + + return forces_total, forces_pos_only + + # Use realistic velocity magnitude from config's speed_limit instead of unit vectors + # The speed_limit is in pixel space, so normalize it + if "speed_limit" in config: + speed_magnitude = config["speed_limit"] / scene_size + else: + # Fallback: use a typical speed (mean from basic datasets ~0.014) + speed_magnitude = 0.015 + + # Scenario 1: vel_j moving away from i (with realistic speed) + vel_away = r_hat.copy() * speed_magnitude + forces_away_total, forces_away_pos = compute_boid_forces(vel_away) + forces_away_vel = forces_away_total - forces_away_pos + + # Scenario 2: vel_j moving towards i (with realistic speed) + vel_towards = -r_hat.copy() * speed_magnitude + forces_towards_total, forces_towards_pos = compute_boid_forces(vel_towards) + forces_towards_vel = forces_towards_total - forces_towards_pos + + # Reshape to grid + def make_force_dict(forces): + return { + "x": forces[:, 0].reshape(grid_size, grid_size), + "y": forces[:, 1].reshape(grid_size, grid_size), + "mag": np.linalg.norm(forces, axis=1).reshape(grid_size, grid_size), + } + + return { + "X": X, + "Y": Y, + "away_total": make_force_dict(forces_away_total), + "away_pos": make_force_dict(forces_away_pos), + "away_vel": make_force_dict(forces_away_vel), + "towards_total": make_force_dict(forces_towards_total), + "towards_pos": make_force_dict(forces_towards_pos), + "towards_vel": make_force_dict(forces_towards_vel), + } + + +def evaluate_true_boid_velocity_forces( + config, grid_size=60, max_vel=0.05, scene_size=480.0 +): + """ + Evaluate true boid forces on a 2D velocity grid (symmetric decomposition). + + Setup: + - Two boids at SAME position (delta_pos = 0) at square center + - Vary relative velocity on a 2D grid + + Parameters + ---------- + config : dict + Boid config with parameters in PIXEL SPACE (same as evaluate_true_boid_forces) + grid_size : int + Grid resolution + max_vel : float + Maximum relative velocity magnitude to evaluate (in normalized space) + scene_size : float + Scene size in pixels (used to normalize config parameters) + + Returns + ------- + dict with keys: + - VX, VY: meshgrid coordinates (relative velocity components) + - forces: force vectors [grid_size, grid_size, 2] + - force_mag: force magnitudes [grid_size, grid_size] + """ + # Create 2D velocity grid in normalized space + vx = np.linspace(-max_vel, max_vel, grid_size) + vy = np.linspace(-max_vel, max_vel, grid_size) + VX, VY = np.meshgrid(vx, vy) + + # Normalize config parameters from pixel space to normalized space + normalized_config = config.copy() + if "min_distance" in config: + normalized_config["min_distance"] = config["min_distance"] / scene_size + if "visual_range" in config: + normalized_config["visual_range"] = config["visual_range"] / scene_size + + # Add 'independent' flag if not present + if "independent" not in normalized_config: + normalized_config["independent"] = False + + # Flatten for iteration + delta_vels = np.stack([VX.flatten(), VY.flatten()], axis=-1) # [N, 2] + n_points = len(delta_vels) + + # Compute forces at each velocity grid point + forces = np.zeros_like(delta_vels) + + for idx in range(n_points): + # Both boids at the same position (square center: 0.5, 0.5 in normalized space) + # Boid i: stationary reference + boid_i = {"x": 0.5, "y": 0.5, "dx": 0.0, "dy": 0.0, "species": "A"} + + # Boid j: has relative velocity + vel_j = delta_vels[idx] + boid_j = { + "x": 0.5, # Same position as i + "y": 0.5, + "dx": vel_j[0], + "dy": vel_j[1], + "species": "A", + } + + # Initial velocity of boid_j + initial_vel = np.array([boid_j["dx"], boid_j["dy"]]) + + # Compute force ON boid_j due TO boid_i + # Put boids in a list and call force functions + boids = [boid_j, boid_i] + + fly_towards_center(boid_j, boids, normalized_config) # Rule 1: Cohesion + avoid_others(boid_j, boids, normalized_config) # Rule 2: Separation + match_velocity(boid_j, boids, normalized_config) # Rule 3: Alignment + + # Force is change in velocity + final_vel = np.array([boid_j["dx"], boid_j["dy"]]) + forces[idx] = final_vel - initial_vel + + # Reshape to grid + forces_x = forces[:, 0].reshape(grid_size, grid_size) + forces_y = forces[:, 1].reshape(grid_size, grid_size) + forces_mag = np.sqrt(forces_x**2 + forces_y**2) + + return { + "VX": VX, + "VY": VY, + "forces": forces.reshape(grid_size, grid_size, 2), + "forces_x": forces_x, + "forces_y": forces_y, + "force_mag": forces_mag, + } + + +def plot_symmetric_force_decomposition( + position_forces, + velocity_forces, + save_path=None, + title_prefix="Learned", + visual_range=None, +): + """ + Plot symmetric force decomposition: position-dependent and velocity-dependent forces. + + Creates a 1x2 grid: + - Left: Position-dependent forces (velocity=0, vary position) + - Right: Velocity-dependent forces (position=0, vary velocity) + + Parameters + ---------- + position_forces : dict + Output from evaluate_forces_on_grid (with delta_vel=0) + velocity_forces : dict + Output from evaluate_velocity_forces_on_grid (with delta_pos=0) + save_path : str, optional + Path to save figure + title_prefix : str + Prefix for title (e.g., "Learned" or "True Boid") + visual_range : float, optional + Visual range radius to draw as reference circle + + Returns + ------- + fig : matplotlib.figure.Figure + """ + fig, axes = plt.subplots(1, 2, figsize=(16, 7)) + + # LEFT: Position-dependent forces (velocity = 0) + ax = axes[0] + X, Y = position_forces["X"], position_forces["Y"] + + # Plot force magnitude as heatmap + im = ax.pcolormesh( + X, Y, position_forces["away_pos"]["mag"], cmap="viridis", shading="auto" + ) + plt.colorbar(im, ax=ax, label="Force Magnitude") + + # Overlay force vectors (subsample for clarity) + step = max(1, len(X) // 15) + ax.quiver( + X[::step, ::step], + Y[::step, ::step], + position_forces["away_pos"]["x"][::step, ::step], + position_forces["away_pos"]["y"][::step, ::step], + color="white", + alpha=0.7, + scale=None, + scale_units="xy", + ) + + ax.set_xlabel("Δx (relative position)") + ax.set_ylabel("Δy (relative position)") + ax.set_title(f"{title_prefix}: Position-Dependent Forces\n(Δv = 0)") + ax.set_aspect("equal") + ax.axhline(0, color="white", linestyle="--", alpha=0.3, linewidth=0.5) + ax.axvline(0, color="white", linestyle="--", alpha=0.3, linewidth=0.5) + + # Add visual range circle if provided + if visual_range is not None: + circle = plt.Circle( + (0, 0), + visual_range, + fill=False, + edgecolor="red", + linestyle="--", + linewidth=2, + label=f"Visual range = {visual_range:.2f}", + ) + ax.add_patch(circle) + ax.legend(loc="upper right") + + # RIGHT: Velocity-dependent forces (position = 0) + ax = axes[1] + VX, VY = velocity_forces["VX"], velocity_forces["VY"] + + # Plot force magnitude as heatmap + im = ax.pcolormesh( + VX, VY, velocity_forces["force_mag"], cmap="plasma", shading="auto" + ) + plt.colorbar(im, ax=ax, label="Force Magnitude") + + # Overlay force vectors (subsample for clarity) + step = max(1, len(VX) // 15) + ax.quiver( + VX[::step, ::step], + VY[::step, ::step], + velocity_forces["forces_x"][::step, ::step], + velocity_forces["forces_y"][::step, ::step], + color="white", + alpha=0.7, + scale=None, + scale_units="xy", + ) + + ax.set_xlabel("Δv_x (relative velocity)") + ax.set_ylabel("Δv_y (relative velocity)") + ax.set_title(f"{title_prefix}: Velocity-Dependent Forces\n(Δpos = 0)") + ax.set_aspect("equal") + ax.axhline(0, color="white", linestyle="--", alpha=0.3, linewidth=0.5) + ax.axvline(0, color="white", linestyle="--", alpha=0.3, linewidth=0.5) + + plt.tight_layout() + + if save_path: + plt.savefig(save_path, dpi=300, bbox_inches="tight") + logger.info(f"Saved symmetric force decomposition plot to {save_path}") + + return fig diff --git a/docs/MIGRATION-PLAN.md b/docs/MIGRATION-PLAN.md new file mode 100644 index 00000000..beed1ccc --- /dev/null +++ b/docs/MIGRATION-PLAN.md @@ -0,0 +1,137 @@ +# Migration Plan — Remove DB + Dashboards from collab-environment + +## Context + +The database layer (`collab_env/data/db/`) and the two Panel dashboards (`collab_env/dashboard/`) are being moved to the [collab-data](https://github.com/anthropics/collab-data) repo, where they belong conceptually (data storage, querying, and exploration — not environment/sim/gnn/tracking). PR anthropics/collab-environment#73 introduced the analysis dashboard + db layer; the GCS browser predates it. + +This document covers **only the cleanup of this repo**. It is **Phase 2**, and only runs after the collab-data import PR has merged and been verified end-to-end. For the corresponding Phase 1 plan see `docs/MIGRATION-PLAN.md` in the collab-data repo (branch `migrate-db-and-dashboards`). + +## Decisions captured up front + +- `collab_env/data/file_utils.py` and `collab_env/data/gcs_utils.py` **stay in this repo**. Roughly 12 modules across `sim/`, `gnn/`, and `tracking/` import from them; we are not rewriting those import sites and not taking a cross-repo dependency on `collab-data`. Accept that these two files are now duplicated between repos and may drift. +- One PR for the entire cleanup. +- No history rewrite in this repo — just `git rm` the moved tree. + +## Preconditions before starting + +- collab-data PR `migrate-db-and-dashboards` is merged to `master`. +- A clean checkout of collab-data on a fresh venv passes: + - `pip install -e .[dev]` + - imports for `collab_data.db.*`, `collab_data.data_dashboard.app`, `collab_data.analysis_dashboard.spatial_analysis_gui` + - `pytest tests/db tests/analysis_dashboard` + - launching both `scripts/data_dashboard.sh` and `scripts/analysis_dashboard.sh` and clicking through widgets / video viewer +- A note in this repo's PR description pointing at the corresponding collab-data merge commit. + +## Branch + +Cut a new branch off `main` (e.g. `cleanup-db-and-dashboards`). + +## Files and directories to delete + +### Python packages + +- `collab_env/data/db/` — entire subpackage (config, db_loader, init_database, query_backend, schema/, queries/) +- `collab_env/dashboard/` — entire package (app, cli, dashboard_app, file_viewers, persistent_video_server, rclone_client, session_manager, spatial_analysis_app, spatial_analysis_gui, analysis_widgets.yaml, widgets/, templates/, static/, utils/simulation_loader.py) + +`collab_env/data/__init__.py`, `file_utils.py`, `gcs_utils.py` — **keep**. + +### Tests + +- `tests/db/` — entire directory +- `tests/dashboard/` — entire directory +- `tests/test_dashboard.py` +- `tests/conftest.py` — review: keep the parts unrelated to db/dashboard skipping; drop any DB-specific collect_ignore logic + +### Scripts + +- `scripts/dev_dashboard.sh` +- `scripts/analysis_dashboard.sh` +- `scripts/deploy/` — entire directory (config.sh, cloudbuild.yaml, Dockerfile.dashboard, build_and_deploy.sh, setup_cloud_sql.sh, start_proxy.sh, README.md) + +### Docs + +- `docs/data/db/` — entire directory +- `docs/dashboard/` — entire directory (README.md, DATA_DASHBOARD_README.md, CLOUD_SETUP.md, spatial_analysis.md, grafana/) +- `docs/data/gcloud_*.ipynb` — these moved to collab-data; remove from here too +- Leave `docs/data/` itself only if other files remain in it (otherwise remove the directory) + +### Top-level + +- `requirements-db.txt` — delete + +## Files to edit + +### `pyproject.toml` + +- Remove from `[tool.setuptools] packages`: + - `collab_env.data.db` + - `collab_env.dashboard` +- Remove from `[tool.setuptools.package-data]`: + - `"collab_env.data.db" = [...]` + - `"collab_env.dashboard" = [...]` +- Remove the entire `db` and `db-dashboard` optional dependency groups from `[project.optional-dependencies]` +- Edit the `dev` optional group to drop the DB/dashboard transitive deps (`aiosql`, `sqlalchemy`, `psycopg2`, `panel`, `holoviews`, `bokeh`, `plotly`, `duckdb*`, `pyarrow` if not needed elsewhere) + +After editing, run `pip install -e .[dev]` in a clean venv and verify the resolve has shrunk. + +### `README.rst` + +- Drop the **Dashboard** section entirely +- Remove the rclone / ffmpeg / exiftool setup steps from the prerequisites section, **unless** any of these are still required by tracking or another module (verify before deleting — `exiftool` in particular may still be used by tracking; grep before removing) +- Update the docs links section to remove the now-deleted `docs/dashboard/README.md` link + +### `Makefile` + +- Currently has no dashboard-specific targets per inventory; verify with a grep and remove anything that does reference dashboards/db. + +### `.github/workflows/test.yml` + +- Currently runs `./scripts/test.sh`, which discovers all of `tests/`. After the test directories are deleted no workflow change is required, but verify nothing references the deleted paths or env vars (`POSTGRES_*`, `DB_BACKEND`, etc.). + +### `scripts/test.sh`, `scripts/lint.sh`, `scripts/clean.sh` + +- Verify none of them reference the deleted paths. They are general-purpose, so likely no edits needed. + +## Critical files to read while executing + +- `pyproject.toml` — to know exactly which optional groups and package_data entries to prune +- `README.rst` — for the dashboard section and prerequisites +- `tests/conftest.py` — to understand the SKIP_GCS_TESTS hook and not break GCS test gating +- `scripts/test.sh` and `.github/workflows/test.yml` — to confirm no hardcoded references to the deleted directories + +## Cross-dependency check (must pass before deletion) + +Before deleting, grep the **rest of** `collab_env/` for any remaining imports from the dirs being removed: + +```bash +rg "from collab_env\.(data\.db|dashboard)" collab_env/ +rg "import collab_env\.(data\.db|dashboard)" collab_env/ +``` + +Both should return zero hits. (Per inventory: only the dashboard itself imports from `collab_env.data.db`, and nothing else in the repo imports from `collab_env.dashboard`.) + +Also verify the surviving `collab_env/data/file_utils.py` imports are still satisfied: + +```bash +rg "from collab_env\.data\.file_utils" collab_env/ +rg "from collab_env\.data\.gcs_utils" collab_env/ +``` + +These should still resolve (the files remain). The ~12 sim/gnn/tracking import sites identified during exploration must continue to work — this is the whole reason we kept those two files. + +## Verification + +1. `pip install -e .[dev]` in a fresh venv succeeds and the resolve no longer pulls in panel / holoviz / sqlalchemy / psycopg2 / aiosql / duckdb. +2. `python -c "from collab_env.data.file_utils import expand_path, get_project_root; from collab_env.data.gcs_utils import GCSClient"` still works. +3. Smoke import the modules that were the heaviest file_utils consumers: + + ```bash + python -c "import collab_env.sim.boids.run_simulator" + python -c "import collab_env.gnn.train" + python -c "import collab_env.gnn.gnn_3D.train_3DGNN" + ``` + +4. `./scripts/test.sh` (with `SKIP_GCS_TESTS=1`) passes. The test count should drop by exactly the deleted db + dashboard tests; sim / gnn / tracking tests must still pass. +5. `./scripts/lint.sh` passes. +6. CI: open PR, confirm `test.yml`, `lint.yml`, `test_notebooks.yml`, `lint_notebooks.yml` are all green. +7. Verify the PR description links to the merged collab-data import PR. diff --git a/docs/dashboard/CLOUD_SETUP.md b/docs/dashboard/CLOUD_SETUP.md new file mode 100644 index 00000000..ae29a888 --- /dev/null +++ b/docs/dashboard/CLOUD_SETUP.md @@ -0,0 +1,469 @@ +# Cloud Deployment Setup + +Production setup for spatial analysis dashboard with Cloud SQL and Cloud Run. + +## Architecture + +``` +┌─────────────────┐ +│ Cloud SQL │ ← Managed PostgreSQL/TimescaleDB +│ (PostgreSQL) │ +└────────▲────────┘ + │ + ┌────┴─────┐ + │ │ +┌───┴────┐ ┌──┴─────────┐ +│ Local │ │ Cloud Run │ +│ Dev + │ │ Dashboard │ +│ Loader │ │ (read-only)│ +└────────┘ └────────────┘ +``` + +**Benefits:** +- ✅ Centralized database in the cloud +- ✅ Load data from local machine (fast upload from source files) +- ✅ View/analyze from anywhere via Cloud Run dashboard +- ✅ Multiple users can access the same data + +--- + +## Prerequisites + +- Google Cloud Project with billing enabled +- `.envrc` with `GOOGLE_APPLICATION_CREDENTIALS` set +- Local Python environment: `.venv-310` + +```bash +# Load credentials +source .envrc + +# Verify authentication +gcloud auth list +``` + +--- + +## 1. Create Cloud SQL Instance + +```bash +# Set variables +export PROJECT_ID=$(gcloud config get-value project) +export REGION="us-central1" +export INSTANCE_NAME="spatial-analysis-db" +export DB_NAME="tracking_analytics" +export DB_USER="postgres" +export DB_PASSWORD="$(openssl rand -base64 32)" + +# Create PostgreSQL instance +gcloud sql instances create ${INSTANCE_NAME} \ + --database-version=POSTGRES_15 \ + --tier=db-g1-small \ + --region=${REGION} \ + --database-flags=max_connections=100 \ + --backup-start-time=03:00 + +# Create database +gcloud sql databases create ${DB_NAME} \ + --instance=${INSTANCE_NAME} + +# Set password +gcloud sql users set-password ${DB_USER} \ + --instance=${INSTANCE_NAME} \ + --password="${DB_PASSWORD}" + +# Store password in Secret Manager +echo -n "${DB_PASSWORD}" | gcloud secrets create postgres-password \ + --data-file=- \ + --replication-policy="automatic" + +echo "✅ Cloud SQL instance created: ${INSTANCE_NAME}" +echo "📝 Database password stored in Secret Manager: postgres-password" +``` + +### Grant IAM Permissions + +Your account needs permission to connect to Cloud SQL via the proxy: + +```bash +# Get your current account +USER_EMAIL=$(gcloud config get-value account) + +# Grant Cloud SQL Client role +gcloud projects add-iam-policy-binding ${PROJECT_ID} \ + --member="user:${USER_EMAIL}" \ + --role="roles/cloudsql.client" + +# OR if using service account from GOOGLE_APPLICATION_CREDENTIALS +SA_EMAIL=$(cat ${GOOGLE_APPLICATION_CREDENTIALS} | python3 -c "import sys, json; print(json.load(sys.stdin)['client_email'])") +gcloud projects add-iam-policy-binding ${PROJECT_ID} \ + --member="serviceAccount:${SA_EMAIL}" \ + --role="roles/cloudsql.client" + +# Refresh credentials (important!) +gcloud auth application-default login + +echo "✅ IAM permissions granted" +``` + +**Note:** IAM changes can take up to 60 seconds to propagate. + +### Initialize Database Schema + +```bash +# Download and start Cloud SQL Auth Proxy +curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.13.0/cloud-sql-proxy.darwin.amd64 +chmod +x cloud-sql-proxy + +# Start proxy in background (use port 5433 if you have local postgres on 5432) +./cloud-sql-proxy ${PROJECT_ID}:${REGION}:${INSTANCE_NAME} \ + --credentials-file ${GOOGLE_APPLICATION_CREDENTIALS} \ + --port 5433 & +PROXY_PID=$! + +# Wait for connection +sleep 3 + +# Initialize database +export DB_BACKEND=postgres +export POSTGRES_HOST=localhost +export POSTGRES_PORT=5433 +export POSTGRES_DB=${DB_NAME} +export POSTGRES_USER=${DB_USER} +export POSTGRES_PASSWORD=$(gcloud secrets versions access latest --secret=postgres-password) + +source .venv-310/bin/activate +python -m collab_env.data.db.init_database --backend postgres + +# Stop proxy +kill $PROXY_PID + +echo "✅ Database schema initialized" +``` + +--- + +## 2. Local Development Setup + +### Install Cloud SQL Auth Proxy + +```bash +# Download proxy (macOS ARM64) +curl -o cloud-sql-proxy \ + https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.13.0/cloud-sql-proxy.darwin.arm64 + +# OR macOS Intel +curl -o cloud-sql-proxy \ + https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.13.0/cloud-sql-proxy.darwin.amd64 + +# OR Linux +curl -o cloud-sql-proxy \ + https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.13.0/cloud-sql-proxy.linux.amd64 + +chmod +x cloud-sql-proxy +mv cloud-sql-proxy ~/bin/ # or keep in project root +``` + +### Configure Local Environment + +Add to `.envrc`: + +```bash +# Cloud SQL Configuration +export PROJECT_ID="your-project-id" +export REGION="us-central1" +export INSTANCE_NAME="spatial-analysis-db" + +# Database connection (via Cloud SQL Auth Proxy) +export DB_BACKEND=postgres +export POSTGRES_HOST=localhost +export POSTGRES_PORT=5433 # Use 5433 if local postgres is on 5432 +export POSTGRES_DB=tracking_analytics +export POSTGRES_USER=postgres +export POSTGRES_PASSWORD=$(gcloud secrets versions access latest --secret=postgres-password 2>/dev/null || echo "password") + +# Cloud SQL connection string for convenience +export CLOUD_SQL_INSTANCE="${PROJECT_ID}:${REGION}:${INSTANCE_NAME}" +``` + +Reload environment: +```bash +direnv allow # if using direnv +# OR +source .envrc +``` + +### Daily Workflow + +**Terminal 1: Start Cloud SQL Proxy** +```bash +source .envrc + +# Use port 5433 to avoid conflict with local postgres +./cloud-sql-proxy ${CLOUD_SQL_INSTANCE} \ + --credentials-file ${GOOGLE_APPLICATION_CREDENTIALS} \ + --port 5433 + +# Leave running... +``` + +**Terminal 2: Load Data** +```bash +source .envrc +source .venv-310/bin/activate + +# Load 2D boids data +python -m collab_env.data.db.db_loader \ + --source boids2d \ + --path simulated_data/boid_food_basic.pt + +# Load GNN rollout data +python -m collab_env.data.db.db_loader \ + --source boids2d_rollout \ + --path trained_models/food/basic/n0_h1_vr0.5_s2/rollout_results/ +``` + +**Terminal 3: Run Dashboard Locally** +```bash +source .envrc +source .venv-310/bin/activate + +panel serve collab_env/dashboard/spatial_analysis_app.py \ + --show \ + --dev \ + --port 5007 +``` + +Open: http://localhost:5007 + +--- + +## 3. Deploy Dashboard to Cloud Run + +### Create Dockerfile + +Create `Dockerfile.dashboard`: + +```dockerfile +FROM python:3.10-slim + +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + libpq-dev \ + git \ + && rm -rf /var/lib/apt/lists/* + +# Copy requirements +COPY requirements-db.txt . +COPY pyproject.toml . +COPY README.rst . + +# Install Python dependencies +RUN pip install --no-cache-dir -r requirements-db.txt +RUN pip install --no-cache-dir -e . + +# Copy application code +COPY collab_env/ /app/collab_env/ +COPY schema/ /app/schema/ + +# Environment +ENV PORT=8080 +ENV PYTHONUNBUFFERED=1 + +# Run dashboard +CMD panel serve collab_env/dashboard/spatial_analysis_app.py \ + --address 0.0.0.0 \ + --port ${PORT} \ + --allow-websocket-origin="*" \ + --num-threads 4 +``` + +### Build and Deploy + +```bash +# Set variables (if not already set) +export PROJECT_ID=$(gcloud config get-value project) +export REGION="us-central1" +export INSTANCE_NAME="spatial-analysis-db" + +# Build and submit to Artifact Registry +gcloud builds submit \ + --tag gcr.io/${PROJECT_ID}/spatial-dashboard \ + -f Dockerfile.dashboard + +# Grant Cloud Run service account access to secrets +export PROJECT_NUMBER=$(gcloud projects describe ${PROJECT_ID} --format="value(projectNumber)") +gcloud secrets add-iam-policy-binding postgres-password \ + --member="serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com" \ + --role="roles/secretmanager.secretAccessor" + +# Deploy to Cloud Run +gcloud run deploy spatial-analysis-dashboard \ + --image gcr.io/${PROJECT_ID}/spatial-dashboard \ + --region ${REGION} \ + --platform managed \ + --allow-unauthenticated \ + --memory 2Gi \ + --cpu 2 \ + --timeout 3600 \ + --add-cloudsql-instances ${PROJECT_ID}:${REGION}:${INSTANCE_NAME} \ + --set-env-vars="DB_BACKEND=postgres,POSTGRES_DB=tracking_analytics,POSTGRES_USER=postgres" \ + --set-env-vars="POSTGRES_HOST=/cloudsql/${PROJECT_ID}:${REGION}:${INSTANCE_NAME}" \ + --set-secrets="POSTGRES_PASSWORD=postgres-password:latest" + +# Get the URL +gcloud run services describe spatial-analysis-dashboard \ + --region ${REGION} \ + --format="value(status.url)" +``` + +Your dashboard is now live! 🚀 + +--- + +## 4. Update and Redeploy + +```bash +# Rebuild and deploy +gcloud builds submit --tag gcr.io/${PROJECT_ID}/spatial-dashboard -f Dockerfile.dashboard + +gcloud run deploy spatial-analysis-dashboard \ + --image gcr.io/${PROJECT_ID}/spatial-dashboard \ + --region ${REGION} +``` + +--- + +## 5. Maintenance + +### View Logs + +```bash +# Dashboard logs +gcloud run logs read spatial-analysis-dashboard --region ${REGION} --limit 50 + +# Database logs +gcloud sql operations list --instance ${INSTANCE_NAME} --limit 10 +``` + +### Database Backup + +```bash +# Manual backup +gcloud sql backups create --instance ${INSTANCE_NAME} + +# List backups +gcloud sql backups list --instance ${INSTANCE_NAME} + +# Restore from backup +gcloud sql backups restore BACKUP_ID --backup-instance ${INSTANCE_NAME} +``` + +### Connect to Database Directly + +```bash +# Via Cloud SQL Proxy (use port 5433 to avoid conflict with local postgres) +./cloud-sql-proxy ${PROJECT_ID}:${REGION}:${INSTANCE_NAME} \ + --credentials-file ${GOOGLE_APPLICATION_CREDENTIALS} \ + --port 5433 + +# In another terminal +psql "host=localhost port=5433 dbname=tracking_analytics user=postgres" +``` + +### Delete Session Data + +```bash +# Connect via proxy, then: +source .venv-310/bin/activate +python -c " +from collab_env.data.db.query_backend import QueryBackend +qb = QueryBackend() +# List sessions +print(qb.get_sessions()) +# Delete specific session (cascading delete) +# qb.delete_session('session-id-here') +" +``` + +--- + +## Cost Estimation + +**Cloud SQL (db-g1-small):** +- Instance: ~$25-35/month +- Storage: ~$0.17/GB/month +- Backups: ~$0.08/GB/month + +**Cloud Run:** +- Free tier: 2M requests/month +- Beyond free: $0.00002400/request +- Idle: $0 (scales to zero) + +**Total:** ~$30-40/month for small-medium usage + +**Cost optimization:** +- Use `db-f1-micro` ($7/month) for testing +- Stop Cloud SQL instance when not in use: `gcloud sql instances patch ${INSTANCE_NAME} --activation-policy=NEVER` +- Restart: `gcloud sql instances patch ${INSTANCE_NAME} --activation-policy=ALWAYS` + +--- + +## Troubleshooting + +### Cloud SQL Proxy Connection Failed + +```bash +# Check if instance is running +gcloud sql instances describe ${INSTANCE_NAME} --format="value(state)" + +# Check connection name +gcloud sql instances describe ${INSTANCE_NAME} --format="value(connectionName)" + +# Test with verbose logging +./cloud-sql-proxy ${PROJECT_ID}:${REGION}:${INSTANCE_NAME} --verbose +``` + +### Cloud Run Can't Connect to Database + +```bash +# Verify Cloud SQL connection is configured +gcloud run services describe spatial-analysis-dashboard \ + --region ${REGION} \ + --format="value(spec.template.spec.containers[0].env)" + +# Check service account permissions +gcloud sql instances describe ${INSTANCE_NAME} \ + --format="value(serviceAccountEmailAddress)" +``` + +### Password Not Found + +```bash +# Verify secret exists +gcloud secrets versions access latest --secret=postgres-password + +# Recreate if needed +echo -n "your_password" | gcloud secrets versions add postgres-password --data-file=- +``` + +--- + +## Security Best Practices + +1. **Private IP (Optional):** Configure Cloud SQL with private IP for VPC-only access +2. **IAM Authentication:** Use Cloud SQL IAM authentication instead of passwords +3. **Restricted Access:** Add `--no-allow-unauthenticated` to Cloud Run for internal-only access +4. **Audit Logs:** Enable Cloud SQL audit logging for compliance + +--- + +## References + +- [Cloud SQL for PostgreSQL](https://cloud.google.com/sql/docs/postgres) +- [Cloud SQL Auth Proxy](https://cloud.google.com/sql/docs/postgres/connect-auth-proxy) +- [Cloud Run Documentation](https://cloud.google.com/run/docs) +- [Database Schema](../data/db/README.md) +- [Dashboard Widgets](../data/dashboard/README.md) diff --git a/docs/dashboard/DATA_DASHBOARD_README.md b/docs/dashboard/DATA_DASHBOARD_README.md new file mode 100644 index 00000000..12b9cfdc --- /dev/null +++ b/docs/dashboard/DATA_DASHBOARD_README.md @@ -0,0 +1,981 @@ +# Dashboard System: Design & Implementation Guide + +**Last Updated:** 2025-11-12 +**Status:** Phase 6 Complete ✅ | Phase 7.1 Complete ✅ (Basic Data Viewer with Integrated Heatmap) + +> **Note**: This document covers the **query and visualization layer** of the system. +> For database schema and data loading, see [docs/data/db/README.md](../data/db/README.md). + +--- + +## Table of Contents + +1. [Overview](#overview) +2. [Architecture](#architecture) +3. [Current Status](#current-status) +4. [Planned Features](#planned-features) +5. [Implementation Roadmap](#implementation-roadmap) +6. [Technical Reference](#technical-reference) +7. [Usage Examples](#usage-examples) + +--- + +## Overview + +### What is the Dashboard System? + +The Dashboard System provides interactive web-based visualization and analysis for 3D boids simulation data and animal tracking data. It consists of two major components: + +1. **Data Layer** (QueryBackend): SQL-based query interface for efficient data retrieval +2. **GUI Layer** (Analysis Widgets): Modular, plugin-based visualization framework + +### Key Features + +**Current (Production Ready):** + +- **Basic Data Viewer** (Phase 7.1): Unified episode viewer with 4 synchronized panels: + - Animated 2D track visualization with client-side playback (smooth 60fps) + - Full-screen modal viewer with embedded data (no server round-trips) + - Spatial density heatmaps (integrated, replaces standalone widget) + - Multi-property time series with synchronized timeline + - Dynamic histogram panel for property distributions + - *Note: 3D client-side animation not yet implemented (requires three.js)* +- **Extended Properties Viewer** ✨ NEW: Property-agnostic viewer with session support + - **Dual scope support**: Episode-level OR session-level analysis + - **Time series panel** (episode only): Multi-property time series with configurable quantile bands (default: 10th-90th percentile) + - **Distribution panel**: Histogram or violin plot toggle + - **Configurable histogram bins** (10-100) + - **Z-score normalization** for multi-scale properties + - **Optional agent trajectories**: Individual agent lines with configurable opacity and markers + - **Session aggregation**: Combines distributions across all episodes in a session + - **Scope validation**: Clear error messages for incompatible scopes +- Enhanced legacy widgets (Phase 6+): + - **Velocity Stats**: Comprehensive velocity analysis (episode-only) + - Individual agent speed (histogram + time series with median and IQR bands) + - Mean velocity magnitude (normalized velocities, then magnitude of mean vector) + - Relative velocity magnitude (pairwise ||v_i - v_j|| with median and IQR bands) + - Distinct color schemes per group with interactive legends + - **Distances**: Relative locations analysis (episode-only) + - Pairwise distances ||x_i - x_j|| between agents + - Histogram + time series with median and IQR (25th-75th percentile) bands + - Distinct color scheme (darkviolet/plum) with interactive legends + - **Velocity Correlations**: Episode-level correlation analysis +- **Flexible scope selection**: Episode/Session toggle with dynamic UI + - Episode mode: Shows all selectors and time controls + - Session mode: Hides episode selector and time controls + - Automatic validation with user-friendly error messages +- SQL-optimized episode and session-level aggregation +- Modular widget architecture + +**Planned (Phase 7.2-7.3):** + +- Relative Quantities Viewer: Pairwise interaction analysis +- Correlation Viewer: Property correlation with dual modes (windowed/lagged) + +**Future (Phase 8):** + +- Property computation framework (speed, acceleration) + +### Design Goals + +1. **Extensibility**: Add new analyses without modifying core code +2. **Performance**: SQL-level aggregation for efficiency +3. **Flexibility**: Support multiple data scopes (episode, session, custom) +4. **Usability**: Clear, intuitive interface with real-time feedback +5. **Maintainability**: Modular architecture with clear separation of concerns + +--- + +## Architecture + +### System Overview + +``` +┌─────────────────────────────────────────────────────────────┐ +│ Spatial Analysis GUI │ +│ (Panel/HoloViz Web Interface) │ +│ │ +│ Scope: Episode | Session | Custom │ +│ Shared: Bin Size | Time Window | Agent Type │ +│ Tabs: [Dynamic Widget Registry] │ +└─────────────────────┬───────────────────────────────────────┘ + │ + │ AnalysisContext (shared state) + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ QueryBackend │ +│ (collab_env/data/db/query_backend.py) │ +│ │ +│ Session Queries │ Spatial Analysis │ Correlations │ +│ - get_sessions │ - get_heatmap │ - velocity │ +│ - get_episodes │ - get_velocities │ - distance │ +│ - get_metadata │ - get_distances │ │ +└─────────────────────┬───────────────────────────────────────┘ + │ + │ aiosql (driver-specific adapters) + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ SQL Query Files (.sql) │ +│ (collab_env/data/db/queries/) │ +│ │ +│ - session_metadata.sql (3 queries) │ +│ - spatial_analysis.sql (6 queries) │ +│ - correlations.sql (2 queries) │ +└─────────────────────┬───────────────────────────────────────┘ + │ + │ Executed via psycopg2/duckdb + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ Database (PostgreSQL or DuckDB) │ +│ │ +│ Tables: observations, extended_properties, episodes, ... │ +└─────────────────────────────────────────────────────────────┘ +``` + +### Data Layer: QueryBackend + +**Purpose**: Provide clean Python API for database queries, abstracting SQL details + +**Key Features**: +- **aiosql Integration**: SQL queries in separate `.sql` files for easy modification +- **Driver-Specific Adapters**: Direct use of psycopg2/duckdb (not SQLAlchemy) +- **Dual Backend Support**: PostgreSQL and DuckDB with same API +- **Session-Level Aggregation**: Efficient SQL subqueries for multi-episode analysis +- **Parameterized Queries**: Named parameters (`:episode_id`, `:bin_size`, etc.) + +**File Structure**: +``` +collab_env/data/db/ +├── config.py # Database configuration +├── init_database.py # Schema initialization +├── db_loader.py # Data loading utilities +├── query_backend.py # Main QueryBackend class ✅ +└── queries/ # SQL query files ✅ + ├── session_metadata.sql + ├── spatial_analysis.sql + └── correlations.sql +``` + +### GUI Layer: Widget System + +**Purpose**: Modular, extensible analysis visualization framework + +**Key Components**: + +1. **SpatialAnalysisGUI** (`spatial_analysis_gui.py`) + - Main application class + - Scope selection (episode/session/custom) + - Shared parameter controls + - Widget registry management + - Status indicators and error handling + +2. **AnalysisContext** (`widgets/analysis_context.py`) + - Shared state container + - QueryBackend instance + - QueryScope (what to analyze) + - Shared parameters (bin_size, window_size, etc.) + - Status callbacks (loading, success, error) + +3. **BaseAnalysisWidget** (`widgets/base_analysis_widget.py`) + - Abstract base class for all widgets + - Standard lifecycle: create controls → create display → load data + - Error handling and loading indicators + - Context-aware query helpers + +4. **Concrete Widgets** (`widgets/*_widget.py`) + - **BasicDataViewerWidget**: Comprehensive unified viewer (Phase 7.1) with integrated heatmap + - **VelocityStatsWidget**: Enhanced velocity analysis (3 groups: individual speed, mean velocity magnitude, relative velocity magnitude) + - **DistanceStatsWidget**: Relative locations (pairwise distances between agents) + - **CorrelationWidget**: Velocity correlations (episode-level) + +5. **Widget Registry** (`analysis_widgets.yaml`) + - YAML-based widget configuration + - Enable/disable widgets + - Control display order + - Set default parameters + +**File Structure**: +``` +collab_env/dashboard/ +├── spatial_analysis_gui.py # Main GUI (~300 lines) ✅ +├── spatial_analysis_app.py # Entry point ✅ +├── analysis_widgets.yaml # Widget configuration ✅ +└── widgets/ + ├── __init__.py + ├── query_scope.py # QueryScope + ScopeType ✅ + ├── analysis_context.py # AnalysisContext ✅ + ├── base_analysis_widget.py # Abstract base ✅ + ├── widget_registry.py # Config loader ✅ + ├── basic_data_viewer_widget.py # Unified viewer with heatmap (Phase 7.1) ✅ + ├── velocity_widget.py # Speed stats (legacy) ✅ + ├── distance_widget.py # Distance stats (legacy) ✅ + └── correlation_widget.py # Correlations (legacy) ✅ +``` + +--- + +## Current Status + +### ✅ Production Ready (Phase 6 Complete) + +**Data Layer:** +- [x] QueryBackend class with aiosql integration +- [x] 11 SQL queries across 3 files +- [x] Session-level aggregation (4 spatial queries) +- [x] Episode-only correlations (2 queries) +- [x] PostgreSQL and DuckDB support +- [x] Comprehensive API validation tests (45 tests passing) + +**GUI Layer:** +- [x] Modular widget architecture +- [x] **Basic Data Viewer** (Phase 7.1) - unified episode viewer with integrated heatmap +- [x] **Enhanced Velocity Stats Widget** - comprehensive velocity analysis with three groups: + - [x] Individual agent speed (histogram + time series with median and IQR) + - [x] Mean velocity magnitude (normalized velocities, then magnitude of mean vector) + - [x] Relative velocity magnitude (pairwise ||v_i - v_j|| with histogram + time series with median and IQR) + - [x] Robust NaN/None handling for 2D/3D data compatibility + - [x] Temporal windowing applied consistently across all time series + - [x] Quantile-based uncertainty bands (25th-75th percentile) for robust statistics + - [x] HoloViews Spread element for IQR visualization with plotly backend + - [x] Distinct color schemes: darkblue/lightblue (speed), darkgreen/lightgreen (mean), darkorange/lightsalmon (relative) + - [x] Interactive legends showing "Median" and "IQR (25th-75th)" labels +- [x] **Enhanced Distance Stats Widget** - pairwise distance analysis: + - [x] Pairwise distances ||x_i - x_j|| between all agents + - [x] Distribution histogram + time series with median and IQR (25th-75th percentile) bands + - [x] Robust NaN/None handling for 2D/3D data compatibility + - [x] HoloViews Spread element for IQR visualization with plotly backend + - [x] Distinct color scheme: darkviolet (median line), plum (IQR bands) + - [x] Interactive legends showing "Median" and "IQR (25th-75th)" labels +- [x] Correlation widget (velocity correlations, episode-level) +- [x] YAML-based widget registry +- [x] Episode and session scope support +- [x] Shared parameter context +- [x] Loading indicators and error handling +- [x] All widget tests passing + +**Running the Dashboard:** +```bash +# Development mode with autoreload and static file serving (REQUIRED for animation viewer) +panel serve collab_env/dashboard/spatial_analysis_app.py --dev --show --port 5008 --static-dirs dashboard-static=collab_env/dashboard/static + +# Production mode +panel serve collab_env/dashboard/spatial_analysis_app.py --port 5008 --static-dirs dashboard-static=collab_env/dashboard/static +``` + +### Known Limitations + +1. **Correlation Analysis**: Episode-level only (session scope disabled) + - Correlations only meaningful within single episodes + - Attempting session scope shows clear error message + +2. **Current Widgets**: Specialized, not property-agnostic + - Hardcoded for specific metrics (speed, distance) + - New properties require new widget code + +3. **Performance**: Pairwise computations (O(n²)) for large agent counts + - Velocity and distance widgets compute all pairs i= 500] + +# Plot comparison +fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4)) + +ax1.plot(before_target['time_window'], before_target['avg_value']) +ax1.fill_between(before_target['time_window'], + before_target['avg_value'] - before_target['std_value'], + before_target['avg_value'] + before_target['std_value'], + alpha=0.3) +ax1.set_title('Distance to Target Before Appearance (t<500)') +ax1.set_xlabel('Time') +ax1.set_ylabel('Distance') + +ax2.plot(after_target['time_window'], after_target['avg_value']) +ax2.fill_between(after_target['time_window'], + after_target['avg_value'] - after_target['std_value'], + after_target['avg_value'] + after_target['std_value'], + alpha=0.3) +ax2.set_title('Distance to Target After Appearance (t>=500)') +ax2.set_xlabel('Time') +ax2.set_ylabel('Distance') + +plt.tight_layout() +plt.show() + +query.close() +``` + +### Example 2: Session-Level Aggregation + +```python +query = QueryBackend() + +# Get session +sessions = query.get_sessions(category_id='boids_3d') +session_id = sessions.iloc[0]['session_id'] + +# Get aggregated heatmap across ALL episodes in session +# (SQL efficiently aggregates at database level) +heatmap = query.get_spatial_heatmap( + session_id=session_id, + bin_size=20.0, + agent_type='agent' +) + +# Plot +pivot = heatmap.pivot(index='y_bin', columns='x_bin', values='density') +plt.imshow(pivot, origin='lower', cmap='viridis') +plt.colorbar(label='Density (aggregated across all episodes)') +plt.title(f'Session-Level Spatial Distribution') +plt.show() + +query.close() +``` + +### Example 3: Agent-Type Comparison + +```python +query = QueryBackend() +episode_id = '...' + +# Get heatmaps for agents and targets +heatmap_agents = query.get_spatial_heatmap( + episode_id=episode_id, + bin_size=20.0, + agent_type='agent' +) +heatmap_targets = query.get_spatial_heatmap( + episode_id=episode_id, + bin_size=20.0, + agent_type='target' +) + +# Pivot and plot side-by-side +grid_agents = heatmap_agents.pivot(index='y_bin', columns='x_bin', values='density').fillna(0) +grid_targets = heatmap_targets.pivot(index='y_bin', columns='x_bin', values='density').fillna(0) + +fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5)) + +im1 = ax1.imshow(grid_agents, origin='lower', cmap='viridis') +ax1.set_title('Agents') +plt.colorbar(im1, ax=ax1) + +im2 = ax2.imshow(grid_targets, origin='lower', cmap='plasma') +ax2.set_title('Targets') +plt.colorbar(im2, ax=ax2) + +plt.tight_layout() +plt.show() +``` + +--- + +## Appendix + +### Database Schema + +See [`collab_env/data/db/README.md`](../../collab_env/data/db/README.md) for complete schema documentation. + +**Key Tables:** +- `sessions`: Session metadata +- `episodes`: Episode metadata and configuration +- `observations`: Position, velocity, agent type per timestep +- `extended_properties`: Derived properties (speed, distance, etc.) +- `property_definitions`: Property metadata + +### Dependencies + +**Core:** +- `sqlalchemy` - Database toolkit +- `psycopg2-binary` - PostgreSQL driver +- `duckdb` - DuckDB driver +- `aiosql>=9.0` - SQL query management +- `pandas` - Data manipulation + +**GUI:** +- `panel>=1.3.0` - Dashboard framework +- `holoviews>=1.18.0` - Visualization library +- `bokeh>=3.3.0` - Plotting backend +- `param` - Parameterized classes + +### Running Tests + +```bash +# All dashboard tests +pytest tests/dashboard/ -v + +# Specific test modules +pytest tests/dashboard/test_analysis_widgets.py -v +pytest tests/dashboard/test_api_validation.py -v + +# With coverage +pytest tests/dashboard/ --cov=collab_env.dashboard --cov-report=html +``` + +### Performance Notes + +**Expected Query Performance** (DuckDB, ~90K observations per episode): +- Heatmap: < 1 second +- Velocity distribution: < 2 seconds +- Speed statistics: < 1 second +- Distance statistics: < 2 seconds +- Correlations: < 5 seconds (O(n²) pairwise) + +**Session Aggregation** (10 episodes): +- Heatmap: 2-3 seconds (vs 10-15s Python-level) +- Speed statistics: 3-4 seconds (vs 20-30s Python-level) + +**Scalability**: +- Episodes: Tested up to 100 episodes per session +- Agents: Tested up to 50 agents per episode +- Correlation queries slow beyond 30 agents (O(n²)) + +--- + +**End of Document** diff --git a/docs/dashboard/grafana/README.md b/docs/dashboard/grafana/README.md new file mode 100644 index 00000000..e91afb9f --- /dev/null +++ b/docs/dashboard/grafana/README.md @@ -0,0 +1,38 @@ +# Grafana Integration + +This directory contains all Grafana-related documentation and dashboard templates for visualizing tracking data. + +## Contents + +- **[grafana_integration.md](grafana_integration.md)** - Complete setup and usage guide + - PostgreSQL setup and configuration + - Grafana installation and data source setup + - Dashboard creation and panel configuration + - Troubleshooting common issues + +- **[grafana_queries.md](grafana_queries.md)** - Comprehensive SQL query library + - 30+ tested SQL queries for all visualizations + - Time-series queries (velocity, speed, distances) + - Spatial queries (heatmaps, histograms) + - Statistical queries (aggregations, correlations) + +- **[grafana_dashboard_template.json](grafana_dashboard_template.json)** - Full-featured dashboard template + - 10+ panels covering all visualization types + - Time-series analysis + - Spatial heatmaps + - Statistical summaries + +- **[grafana_template_simple.json](grafana_template_simple.json)** - Simplified dashboard template + - Basic visualization panels + - Good starting point for customization + +## Quick Start + +1. **Setup PostgreSQL and Grafana** - See [grafana_integration.md](grafana_integration.md#setup) +2. **Import Dashboard** - Use one of the JSON templates +3. **Browse Queries** - See [grafana_queries.md](grafana_queries.md) for all available queries + +## Related Documentation + +- [Database Schema](../../data/db/README.md) - Database design and structure +- [Spatial Analysis Dashboard](../spatial_analysis.md) - Panel-based dashboard for spatial analysis diff --git a/docs/dashboard/grafana/grafana_dashboard_template.json b/docs/dashboard/grafana/grafana_dashboard_template.json new file mode 100644 index 00000000..f813f743 --- /dev/null +++ b/docs/dashboard/grafana/grafana_dashboard_template.json @@ -0,0 +1,794 @@ +{ + "__inputs": [ + { + "name": "DS_TRACKING_ANALYTICS", + "label": "tracking_analytics", + "description": "PostgreSQL datasource for tracking analytics database", + "type": "datasource", + "pluginId": "postgres", + "pluginName": "PostgreSQL" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "12.0.0" + }, + { + "type": "datasource", + "id": "postgres", + "name": "PostgreSQL", + "version": "1.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\n avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as \"Current Avg Speed\"\nFROM observations o\nWHERE o.episode_id = '$episode_id'\n AND o.agent_type_id = 'agent'\n AND o.v_x IS NOT NULL\n AND o.time_index = (\n SELECT MAX(time_index)\n FROM observations\n WHERE episode_id = '$episode_id'\n )", + "refId": "A", + "sql": { + "columns": [], + "groupBy": [], + "limit": 50 + } + } + ], + "title": "Current Avg Speed", + "type": "stat" + }, + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 6, + "y": 0 + }, + "id": 2, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\n COUNT(DISTINCT agent_id) as \"Total Agents\"\nFROM observations\nWHERE episode_id = '$episode_id'\n AND agent_type_id = 'agent'", + "refId": "A" + } + ], + "title": "Total Agents", + "type": "stat" + }, + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 12, + "y": 0 + }, + "id": 3, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT num_frames as \"Total Frames\"\nFROM episodes\nWHERE episode_id = '$episode_id'", + "refId": "A" + } + ], + "title": "Total Frames", + "type": "stat" + }, + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "orange", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 6, + "x": 18, + "y": 0 + }, + "id": 4, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\n avg(ep.value_float) as \"Avg Distance to Target\"\nFROM observations o\nJOIN extended_properties ep ON o.observation_id = ep.observation_id\nJOIN property_definitions pd ON ep.property_id = pd.property_id\nWHERE o.episode_id = '$episode_id'\n AND o.agent_type_id = 'agent'\n AND pd.property_name = 'Distance to Target Center'\n AND o.time_index = (\n SELECT MAX(time_index)\n FROM observations\n WHERE episode_id = '$episode_id'\n )", + "refId": "A" + } + ], + "title": "Current Avg Distance to Target", + "type": "stat" + }, + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "Speed (scene_units/frame)", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "tooltip": false, + "viz": false, + "legend": false + }, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 4 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "SELECT\n to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time,\n avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as \"Average Speed\"\nFROM observations o\nJOIN episodes e ON o.episode_id = e.episode_id\nWHERE o.episode_id = '$episode_id'\n AND o.agent_type_id = 'agent'\n AND o.v_x IS NOT NULL\nGROUP BY o.time_index, e.frame_rate\nORDER BY o.time_index", + "refId": "A" + } + ], + "title": "Average Agent Speed Over Time", + "type": "timeseries" + }, + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "Distance (scene_units)", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "none", + "hideFrom": { + "tooltip": false, + "viz": false, + "legend": false + }, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 4 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "SELECT\n to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time,\n avg(ep.value_float) as \"Average Distance\",\n min(ep.value_float) as \"Min Distance\",\n max(ep.value_float) as \"Max Distance\"\nFROM observations o\nJOIN episodes e ON o.episode_id = e.episode_id\nJOIN extended_properties ep ON o.observation_id = ep.observation_id\nJOIN property_definitions pd ON ep.property_id = pd.property_id\nWHERE o.episode_id = '$episode_id'\n AND o.agent_type_id = 'agent'\n AND pd.property_name = 'Distance to Target Center'\nGROUP BY o.time_index, e.frame_rate\nORDER BY o.time_index", + "refId": "A" + } + ], + "title": "Distance to Target Over Time", + "type": "timeseries" + }, + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "bars", + "fillOpacity": 100, + "gradientMode": "scheme", + "hideFrom": { + "tooltip": false, + "viz": false, + "legend": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 12 + }, + "id": 7, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "SELECT\n to_timestamp((floor(o.time_index / 100) * 100) * (1.0 / 30)) as time,\n avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as \"Avg Speed (100-frame window)\"\nFROM observations o\nWHERE o.episode_id = '$episode_id'\n AND o.agent_type_id = 'agent'\n AND o.v_x IS NOT NULL\nGROUP BY floor(o.time_index / 100)\nORDER BY floor(o.time_index / 100)", + "refId": "A" + } + ], + "title": "Speed per Time Window (100 frames)", + "type": "timeseries" + }, + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "Count", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "bars", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "tooltip": false, + "viz": false, + "legend": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 12 + }, + "id": 8, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\n floor(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0)) / 0.5) * 0.5 as \"Speed Bin\",\n count(*) as \"Count\"\nFROM observations\nWHERE episode_id = '$episode_id'\n AND agent_type_id = 'agent'\n AND v_x IS NOT NULL\nGROUP BY \"Speed Bin\"\nORDER BY \"Speed Bin\"", + "refId": "A" + } + ], + "title": "Speed Distribution Histogram", + "type": "barchart" + }, + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Speed" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + "mode": "gradient" + } + }, + { + "id": "color", + "value": { + "mode": "continuous-GrYlRd" + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 9, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "12.0.0", + "targets": [ + { + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\n o.agent_id as \"Agent ID\",\n o.x as \"X\",\n o.y as \"Y\",\n o.z as \"Z\",\n sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0)) as \"Speed\",\n o.v_x as \"VX\",\n o.v_y as \"VY\",\n o.v_z as \"VZ\"\nFROM observations o\nWHERE o.episode_id = '$episode_id'\n AND o.agent_type_id = 'agent'\n AND o.time_index = 1000\nORDER BY o.agent_id", + "refId": "A" + } + ], + "title": "Agent States at Frame 1000", + "type": "table" + } + ], + "refresh": "", + "schemaVersion": 38, + "style": "dark", + "tags": [ + "boids", + "tracking", + "simulation" + ], + "templating": { + "list": [ + { + "current": {}, + "datasource": { + "type": "postgres", + "uid": "${DS_TRACKING_ANALYTICS}" + }, + "definition": "SELECT episode_id as __text, episode_id as __value FROM episodes ORDER BY episode_number", + "hide": 0, + "includeAll": false, + "label": "Episode", + "multi": false, + "name": "episode_id", + "options": [], + "query": "SELECT episode_id as __text, episode_id as __value FROM episodes ORDER BY episode_number", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Boid Simulation Analytics - Complete Overview", + "uid": "boid_sim_complete", + "version": 1, + "weekStart": "" +} diff --git a/docs/dashboard/grafana/grafana_integration.md b/docs/dashboard/grafana/grafana_integration.md new file mode 100644 index 00000000..633f7d61 --- /dev/null +++ b/docs/dashboard/grafana/grafana_integration.md @@ -0,0 +1,800 @@ +# Grafana Integration Guide + +Complete guide for visualizing boid simulation data from the `tracking_analytics` PostgreSQL database in Grafana. + +## Table of Contents + +1. [Prerequisites](#prerequisites) +2. [Installation](#installation) +3. [Data Source Configuration](#data-source-configuration) +4. [Creating Your First Dashboard](#creating-your-first-dashboard) +5. [Dashboard 1: Time Series Overview](#dashboard-1-time-series-overview) +6. [Dashboard 2: Spatial Analysis](#dashboard-2-spatial-analysis) +7. [Dashboard 3: Time-Windowed Statistics](#dashboard-3-time-windowed-statistics) +8. [Importing JSON Dashboard Template](#importing-json-dashboard-template) +9. [Troubleshooting](#troubleshooting) +10. [Next Steps](#next-steps) + +--- + +## Prerequisites + +Before starting, ensure you have: + +- ✅ **PostgreSQL server running** on `localhost:5432` +- ✅ **Database initialized** with tracking_analytics schema +- ✅ **Data loaded** - at least one simulation loaded via `db_loader.py` +- ✅ **Network access** to PostgreSQL from Grafana + +**Verify prerequisites**: +```bash +# Check PostgreSQL is running +PGPASSWORD=password psql -h localhost -U postgres tracking_analytics -c "SELECT COUNT(*) FROM episodes;" + +# Should return a count > 0 +``` + +--- + +## Installation + +### macOS + +```bash +# Install Grafana via Homebrew +brew install grafana + +# Start Grafana service +brew services start grafana + +# Verify Grafana is running +brew services info grafana +# Should show: Running: true + +# Access Grafana +open http://localhost:3000 +``` + +**Default credentials**: +- Username: `admin` +- Password: `admin` +- You'll be prompted to change the password on first login + +### Linux (Ubuntu/Debian) + +```bash +# Add Grafana repository +sudo apt-get install -y software-properties-common +sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main" +wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add - + +# Install Grafana +sudo apt-get update +sudo apt-get install grafana + +# Start Grafana service +sudo systemctl start grafana-server +sudo systemctl enable grafana-server + +# Verify status +sudo systemctl status grafana-server + +# Access Grafana +# Open browser to http://localhost:3000 +``` + +### Docker (Alternative) + +```bash +# Run Grafana in Docker +docker run -d \ + --name=grafana \ + -p 3000:3000 \ + --network=host \ + grafana/grafana-oss:latest + +# Access Grafana +open http://localhost:3000 +``` + +**Note**: Use `--network=host` to access PostgreSQL on localhost. Alternatively, use Docker networking if PostgreSQL is also in Docker. + +--- + +## Data Source Configuration + +### Step 1: Access Data Sources + +1. Log in to Grafana at http://localhost:3000 +2. Click **⚙️ Configuration** → **Data sources** (left sidebar) +3. Click **Add data source** +4. Select **PostgreSQL** + +### Step 2: Configure PostgreSQL Connection + +Fill in the following settings: + +| Field | Value | Notes | +|-------|-------|-------| +| **Name** | `tracking_analytics` | Data source display name | +| **Host** | `localhost:5432` | PostgreSQL server address | +| **Database** | `tracking_analytics` | Database name | +| **User** | `postgres` | Database username | +| **Password** | `password` | Database password (from Docker setup) | +| **SSL Mode** | `disable` | For local development | +| **Version** | `17` | PostgreSQL version | +| **TimescaleDB** | ☑️ Enabled | Check this box (optional optimization) | + +### Step 3: Test Connection + +1. Scroll down and click **Save & test** +2. You should see: ✅ **"Database Connection OK"** + +**If connection fails**: +- Verify PostgreSQL is running: `brew services list | grep postgresql` +- Check credentials: `psql -h localhost -U postgres -d tracking_analytics` +- Check firewall settings if remote connection + +--- + +## Creating Your First Dashboard + +### Basic Dashboard Setup + +1. Click **+** → **Create** → **Dashboard** (left sidebar) +2. Click **Add visualization** +3. Select **tracking_analytics** data source +4. Start building panels! + +### Adding Dashboard Variables + +Variables enable dynamic filtering across all panels. + +#### Create Episode Selector Variable + +1. Click **⚙️ Dashboard settings** → **Variables** +2. Click **Add variable** +3. Configure: + - **Name**: `episode_id` + - **Type**: `Query` + - **Data source**: `tracking_analytics` + - **Query**: + ```sql + SELECT episode_id as __text, episode_id as __value + FROM episodes + ORDER BY episode_number + ``` + - **Multi-value**: ❌ (unchecked) + - **Include All**: ❌ (unchecked) +4. Click **Apply** + +Now you'll see an **Episode ID** dropdown at the top of your dashboard! + +#### Create Frame Range Variables (Optional) + +**Start Frame Variable**: +- **Name**: `start_frame` +- **Type**: `Interval` +- **Values**: `0,100,500,1000,1500,2000,2500,3000` +- **Default**: `0` + +**End Frame Variable**: +- **Name**: `end_frame` +- **Type**: `Interval` +- **Values**: `0,100,500,1000,1500,2000,2500,3000` +- **Default**: `3000` + +--- + +## Dashboard 1: Time Series Overview + +This dashboard shows agent speeds and distances over time. + +### Panel 1.1: Average Speed Over Time + +**Type**: Time series (line chart) + +1. Add new panel +2. Enter query: + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as avg_speed +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +WHERE o.episode_id = '$episode_id' + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL +GROUP BY o.time_index, e.frame_rate +ORDER BY o.time_index +``` + +3. **Panel settings**: + - **Title**: "Average Agent Speed Over Time" + - **Unit**: Custom → `scene_units/frame` + - **Legend**: Show + - **Y-axis label**: "Speed" + +4. Click **Apply** + +### Panel 1.2: Individual Agent Speeds + +**Type**: Time series (multi-line) + +Query: +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0)) as speed, + o.agent_id::text as metric +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +WHERE o.episode_id = '$episode_id' + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL +ORDER BY o.time_index, o.agent_id +``` + +**Panel settings**: +- **Title**: "Individual Agent Speeds" +- **Legend**: Show (one line per agent) +- **Series override**: Optional - limit to first 10 agents for readability + +### Panel 1.3: Distance to Target Center + +**Type**: Time series with multi-line (avg/min/max) + +Query: +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + avg(ep.value_float) as "Average Distance", + min(ep.value_float) as "Min Distance", + max(ep.value_float) as "Max Distance" +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = '$episode_id' + AND o.agent_type_id = 'agent' + AND pd.property_name = 'Distance to Target Center' +GROUP BY o.time_index, e.frame_rate +ORDER BY o.time_index +``` + +**Panel settings**: +- **Title**: "Distance to Target Over Time" +- **Unit**: `scene_units` +- **Fill opacity**: 20% for area chart effect + +### Panel 1.4: Current Speed Statistics + +**Type**: Stat panel (single value) + +Query: +```sql +SELECT + avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as avg_speed +FROM observations o +WHERE o.episode_id = '$episode_id' + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL + AND o.time_index = ( + SELECT MAX(time_index) + FROM observations + WHERE episode_id = '$episode_id' + ) +``` + +**Panel settings**: +- **Title**: "Current Average Speed" +- **Value**: Show last value +- **Unit**: Custom → `scene_units/frame` +- **Sparkline**: Enabled (for mini trend) + +### Dashboard Layout (Row 1) + +Arrange panels in this layout: +``` +┌─────────────────────────────────────────────────────────────┐ +│ Dashboard Title: "Time Series Overview" │ +│ Variables: [Episode ID ▼] │ +├────────────┬───────────┬───────────┬────────────────────────┤ +│ [Stat] │ [Stat] │ [Stat] │ [Stat] │ +│ Avg Speed │ Min Dist │ Max Dist │ Total Agents │ +│ 0.85 │ 145.3 │ 301.1 │ 30 │ +├────────────────────────────────────┬────────────────────────┤ +│ [Time Series] │ [Time Series] │ +│ Average Agent Speed Over Time │ Distance to Target │ +│ │ │ +├────────────────────────────────────┴────────────────────────┤ +│ [Time Series - Multi-line] │ +│ Individual Agent Speeds │ +│ │ +└─────────────────────────────────────────────────────────────┘ +``` + +**Save the dashboard**: Click **💾 Save dashboard** → Name it "Time Series Overview" + +--- + +## Dashboard 2: Spatial Analysis + +This dashboard visualizes spatial distributions and movement patterns. + +### Panel 2.1: Position Heatmap + +**Type**: Heatmap + +Query: +```sql +SELECT + floor(x / 10) * 10 as x_bin, + floor(y / 10) * 10 as y_bin, + count(*) as value +FROM observations +WHERE episode_id = '$episode_id' + AND agent_type_id = 'agent' + AND time_index BETWEEN $start_frame AND $end_frame +GROUP BY x_bin, y_bin +ORDER BY x_bin, y_bin +``` + +**Panel settings**: +- **Title**: "Agent Position Density Heatmap" +- **Format**: Table +- **Calculation**: Total +- **Color scheme**: Choose Spectral or YlOrRd +- **Data format**: Set X-axis to `x_bin`, Y-axis to `y_bin` + +**Note**: Grafana's heatmap can be tricky. Alternative: use a scatter plot with color by density. + +### Panel 2.2: Speed Distribution Histogram + +**Type**: Bar chart + +Query: +```sql +SELECT + floor(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0)) / 0.5) * 0.5 as speed_bin, + count(*) as count +FROM observations +WHERE episode_id = '$episode_id' + AND agent_type_id = 'agent' + AND v_x IS NOT NULL + AND time_index BETWEEN $start_frame AND $end_frame +GROUP BY speed_bin +ORDER BY speed_bin +``` + +**Panel settings**: +- **Title**: "Speed Distribution" +- **X-axis**: `speed_bin` (speed ranges) +- **Y-axis**: `count` (frequency) +- **Bar width**: Auto + +### Panel 2.3: Agent Positions at Current Frame + +**Type**: Table (can export for external plotting) + +Query: +```sql +SELECT + o.agent_id, + o.x, + o.y, + o.z, + sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0)) as speed +FROM observations o +WHERE o.episode_id = '$episode_id' + AND o.agent_type_id = 'agent' + AND o.time_index = $end_frame +ORDER BY o.agent_id +``` + +**Panel settings**: +- **Title**: "Agent Positions (Frame $end_frame)" +- **Table columns**: Show all +- **Color by value**: Enable for speed column + +### Panel 2.4: Velocity Quiver Data + +**Type**: Table (for export to Python/external tools) + +Query: +```sql +SELECT + o.x, + o.y, + o.v_x, + o.v_y +FROM observations o +WHERE o.episode_id = '$episode_id' + AND o.agent_type_id = 'agent' + AND o.time_index = $end_frame + AND o.v_x IS NOT NULL +ORDER BY o.agent_id +``` + +**Usage**: Export this data for quiver plots in matplotlib/plotly. + +--- + +## Dashboard 3: Time-Windowed Statistics + +This dashboard shows aggregated metrics over time windows. + +### Panel 3.1: Speed Statistics per 100-Frame Window + +**Type**: Time series (bar chart) + +Query: +```sql +SELECT + to_timestamp((floor(o.time_index / 100) * 100) * (1.0 / 30)) as time, + avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as avg_speed, + stddev(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as speed_stddev +FROM observations o +WHERE o.episode_id = '$episode_id' + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL +GROUP BY floor(o.time_index / 100) +ORDER BY floor(o.time_index / 100) +``` + +**Panel settings**: +- **Title**: "Average Speed per Time Window (100 frames)" +- **Style**: Bars +- **Fill**: 80% + +### Panel 3.2: Before/After t=500 Comparison + +**Type**: Two Stat panels side-by-side + +**Panel 3.2a - Before t=500**: +```sql +SELECT + avg(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0))) as avg_speed_early +FROM observations +WHERE episode_id = '$episode_id' + AND agent_type_id = 'agent' + AND v_x IS NOT NULL + AND time_index < 500 +``` + +**Panel 3.2b - After t=500**: +```sql +SELECT + avg(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0))) as avg_speed_late +FROM observations +WHERE episode_id = '$episode_id' + AND agent_type_id = 'agent' + AND v_x IS NOT NULL + AND time_index >= 500 +``` + +**Panel settings**: +- **Title**: "Early Phase (t<500)" and "Late Phase (t≥500)" +- **Color**: Different colors for comparison +- **Sparkline**: Disabled + +### Panel 3.3: Distance Convergence Over Time + +**Type**: Time series + +Query: +```sql +SELECT + to_timestamp((floor(o.time_index / 100) * 100) * (1.0 / 30)) as time, + avg(ep.value_float) as avg_distance +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = '$episode_id' + AND o.agent_type_id = 'agent' + AND pd.property_name = 'Distance to Target Center' + AND o.time_index > 500 +GROUP BY floor(o.time_index / 100) +ORDER BY floor(o.time_index / 100) +``` + +**Panel settings**: +- **Title**: "Distance to Target (Post t=500, 100-frame windows)" +- **Unit**: `scene_units` + +### Panel 3.4: Agent Type Summary + +**Type**: Table + +Query: +```sql +SELECT + o.agent_type_id as "Agent Type", + count(DISTINCT o.agent_id) as "Unique Agents", + count(*) as "Total Observations", + avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as "Avg Speed" +FROM observations o +WHERE o.episode_id = '$episode_id' + AND o.v_x IS NOT NULL +GROUP BY o.agent_type_id +ORDER BY o.agent_type_id +``` + +**Panel settings**: +- **Title**: "Agent Type Statistics" +- **Column formatting**: Apply number formatting to statistics + +--- + +## Importing JSON Dashboard Template + +Instead of creating dashboards manually, you can import a pre-built template. + +### Step 1: Locate Template File + +The dashboard template is located at: +``` +docs/data/db/grafana_dashboard_template.json +``` + +### Step 2: Import Dashboard + +1. In Grafana, click **+** (Create) → **Import** (left sidebar) +2. Click **Upload JSON file** +3. Select `grafana_dashboard_template.json` from `docs/data/db/` +4. **Important**: You'll see a datasource selector dropdown: + - Look for your PostgreSQL datasource (should be named something like "PostgreSQL" or "tracking_analytics") + - Select it from the dropdown + - If you don't see it, go back to [Data Source Configuration](#data-source-configuration) and create it first +5. Click **Import** + +**Troubleshooting Import Issues**: + +- **Error: "datasource ${DS_TRACKING_ANALYTICS} not found"** + - This means the datasource selector step was skipped + - Solution: Make sure you select your PostgreSQL datasource from the dropdown before clicking Import + +- **No datasource appears in dropdown** + - You need to create a PostgreSQL datasource first + - Go to Configuration → Data sources → Add data source → PostgreSQL + - Follow the configuration steps in [Data Source Configuration](#data-source-configuration) + +- **Dashboard imports but shows "No data"** + - The datasource might not be properly selected + - Edit any panel and check that the datasource is set to your PostgreSQL connection + - Or delete the dashboard and re-import, making sure to select the datasource + +### Step 3: Verify Import + +After importing, you should see: + +- A dashboard titled "Boid Simulation Analytics - Complete Overview" +- An episode selector dropdown at the top +- 9 panels arranged in rows +- Some panels may show "No data" until you select an episode + +### Step 4: Customize + +After importing: + +- Select an episode from the dropdown variable at the top +- Adjust panel positions and sizes if desired +- Modify queries for your use case +- Add/remove panels as needed +- Save with a new name if making significant changes + +--- + +## Troubleshooting + +### Issue: "Database Connection Failed" + +**Cause**: PostgreSQL not accessible from Grafana + +**Solutions**: +1. Verify PostgreSQL is running: + ```bash + brew services list | grep postgresql + # Or + docker ps | grep timescaledb + ``` + +2. Test connection manually: + ```bash + PGPASSWORD=password psql -h localhost -U postgres tracking_analytics -c "SELECT 1;" + ``` + +3. Check firewall/network settings if PostgreSQL is remote + +4. Verify credentials in `.env` or Data Source settings + +--- + +### Issue: Query Returns No Data + +**Cause**: Episode ID variable not set or wrong filter + +**Solutions**: +1. Check variable is selected (top of dashboard) + +2. Verify episode exists: + ```sql + SELECT episode_id FROM episodes; + ``` + +3. Check time_index range (episodes have 0-3000 frames) + +4. Verify agent_type_id filter: `'agent'` not `'env'` + +--- + +### Issue: Slow Query Performance + +**Cause**: Large dataset, missing indexes, or inefficient query + +**Solutions**: +1. Add `LIMIT 1000` for testing: + ```sql + SELECT ... LIMIT 1000 + ``` + +2. Use time windows instead of raw observations + +3. Filter by `episode_id` early (indexed) + +4. Check query execution plan: + ```sql + EXPLAIN ANALYZE + ``` + +--- + +### Issue: Heatmap Not Rendering + +**Cause**: Grafana heatmap requires specific data format + +**Solutions**: +1. Ensure query returns exactly 3 columns: X, Y, value + +2. Format as **Table** in panel settings + +3. Alternative: Use scatter plot with color gradient instead + +--- + +### Issue: Time Series Not Showing + +**Cause**: Time column format issue + +**Solutions**: +1. Ensure first column is named `time`: + ```sql + SELECT ... as time, ... + ``` + +2. Verify timestamp conversion: + ```sql + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time + ``` + +3. Check timezone settings in Grafana (Settings → Preferences) + +--- + +## Next Steps + +### 1. Advanced Visualizations + +Explore additional panel types: +- **Gauge panels**: Show current metrics with min/max +- **Pie charts**: Agent type distribution +- **Geo map**: If you add lat/lon to observations +- **Node graph**: Visualize agent interactions + +### 2. Alerts + +Set up alerts for anomalous behavior: +- Speed exceeds threshold +- Distance to boundary too small (collision risk) +- Agent count changes unexpectedly + +### 3. Multi-Episode Analysis + +Create dashboards comparing multiple episodes: +- Use `IN ($episode_ids)` with multi-select variable +- Add episode comparison bar charts +- Track metric evolution across runs + +### 4. Export and Share + +- **Snapshots**: Create shareable static views +- **PDF export**: Install Grafana Image Renderer +- **API access**: Query Grafana data via REST API +- **Embed**: Embed panels in external dashboards + +### 5. TimescaleDB Optimizations + +If using TimescaleDB (enabled in PostgreSQL setup): + +```sql +-- Create hypertable for time-series optimization +SELECT create_hypertable('observations', 'time_index', chunk_time_interval => 500); + +-- Add compression +ALTER TABLE observations SET (timescaledb.compress); +SELECT add_compression_policy('observations', INTERVAL '7 days'); +``` + +### 6. Query Materialized Views + +For frequently-accessed aggregations: + +```sql +-- Create materialized view for speed statistics +CREATE MATERIALIZED VIEW mv_agent_speed_stats AS +SELECT + episode_id, + floor(time_index / 100) * 100 as time_window, + agent_id, + avg(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0))) as avg_speed +FROM observations +WHERE agent_type_id = 'agent' + AND v_x IS NOT NULL +GROUP BY episode_id, time_window, agent_id; + +-- Refresh periodically +REFRESH MATERIALIZED VIEW mv_agent_speed_stats; +``` + +Then query the view instead of raw observations for faster performance. + +### 7. Integration with Analysis Pipeline + +Connect Grafana to your broader workflow: +- **Trigger alerts** → Run analysis scripts +- **Export dashboard data** → Feed into ML models +- **Link to video** → Add annotations with video timestamps +- **Correlate with logs** → Join with experiment metadata + +--- + +## Additional Resources + +- **Grafana Documentation**: https://grafana.com/docs/grafana/latest/ +- **PostgreSQL Data Source**: https://grafana.com/docs/grafana/latest/datasources/postgres/ +- **Query Library**: [grafana_queries.md](grafana_queries.md) +- **Schema Documentation**: [schema.md](../../data/db/schema.md) +- **Database Setup**: [README.md](README.md) + +--- + +## Example Gallery + +### Time Series Dashboard +![Expected: Multi-line time series chart showing agent speeds over time] + +### Spatial Heatmap Dashboard +![Expected: Heatmap showing agent position density] + +### Statistics Dashboard +![Expected: Stat panels with key metrics and comparisons] + +**Note**: Add screenshots after creating dashboards for visual reference. + +--- + +## Feedback and Improvements + +Have suggestions for additional visualizations or found issues? + +1. Check existing issues: [GitHub Issues](https://github.com/your-org/collab-environment/issues) +2. Create a new issue with tag `grafana` +3. Contribute dashboard templates to `docs/data/db/dashboards/` + +--- + +**Last Updated**: 2025-11-06 +**Grafana Version Tested**: 12.2.1 +**PostgreSQL Version**: 17 + TimescaleDB +**Database Schema**: Phase 4 Complete (3D Boids) diff --git a/docs/dashboard/grafana/grafana_queries.md b/docs/dashboard/grafana/grafana_queries.md new file mode 100644 index 00000000..c74852ac --- /dev/null +++ b/docs/dashboard/grafana/grafana_queries.md @@ -0,0 +1,634 @@ +# Grafana SQL Queries for Tracking Analytics + +Curated collection of SQL queries for visualizing boid simulation data in Grafana. + +## Quick Reference + +- **Database**: `tracking_analytics` +- **Primary Tables**: `observations`, `episodes`, `extended_properties`, `property_definitions` +- **Sample Episode**: `episode-0-episode-0-completed-20250926-221003` +- **Dataset**: 10 episodes × 3,001 frames × 30 agents = ~900K observations +- **Frame Rate**: 30 FPS (frames per second) + +## Table of Contents + +1. [Time Series Queries](#time-series-queries) +2. [Spatial Statistics](#spatial-statistics) +3. [Extended Properties](#extended-properties) +4. [Time-Windowed Aggregations](#time-windowed-aggregations) +5. [Multi-Episode Comparisons](#multi-episode-comparisons) +6. [Grafana-Specific Tips](#grafana-specific-tips) + +--- + +## Time Series Queries + +### 1.1 Agent Speed Over Time + +**Use Case**: Track individual agent speeds as time-series lines +**Panel Type**: Time series (line chart) +**Visualization**: One line per agent + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0)) as speed, + o.agent_id::text as metric +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL +ORDER BY o.time_index, o.agent_id +``` + +**Grafana Variables**: +- `$episode_id`: Episode selector (see Variable Queries section) + +**Notes**: +- Returns speed in scene units per frame +- `metric` column tells Grafana to create separate series per agent +- Use `$__timeFilter(time)` for Grafana time range filtering + +--- + +### 1.2 Average Speed Across All Agents + +**Use Case**: Population-level speed trend +**Panel Type**: Time series (single line) or Stat panel with sparkline + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as avg_speed, + stddev(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as speed_stddev +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL +GROUP BY o.time_index, e.frame_rate +ORDER BY o.time_index +``` + +**Notes**: +- Returns both mean and standard deviation +- Useful for detecting emergent behavior patterns + +--- + +### 1.3 Velocity Components (X, Y, Z) + +**Use Case**: Analyze directional movement patterns +**Panel Type**: Time series (multi-line) + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + avg(o.v_x) as velocity_x, + avg(o.v_y) as velocity_y, + avg(o.v_z) as velocity_z +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL +GROUP BY o.time_index, e.frame_rate +ORDER BY o.time_index +``` + +--- + +### 1.4 Current Speed Statistics + +**Use Case**: Latest speed metrics +**Panel Type**: Stat panel (single value) + +```sql +SELECT + avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as avg_speed +FROM observations o +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL + AND o.time_index = ( + SELECT MAX(time_index) + FROM observations + WHERE episode_id = $episode_id + ) +``` + +--- + +## Spatial Statistics + +### 2.1 Position Heatmap + +**Use Case**: Agent density visualization +**Panel Type**: Heatmap + +```sql +SELECT + floor(x / 10) * 10 as x_bin, + floor(y / 10) * 10 as y_bin, + count(*) as value +FROM observations +WHERE episode_id = $episode_id + AND agent_type_id = 'agent' + AND time_index BETWEEN $start_frame AND $end_frame +GROUP BY x_bin, y_bin +ORDER BY x_bin, y_bin +``` + +**Grafana Variables**: +- `$start_frame`: Start frame number (default: 0) +- `$end_frame`: End frame number (default: 3000) + +**Notes**: +- Bin size of 10 scene units (adjust `/10` for finer/coarser resolution) +- For Grafana heatmap, set format to "Time series buckets" or use "Table" format with Transform + +--- + +### 2.2 Position Scatter Plot + +**Use Case**: Agent positions at specific time +**Panel Type**: Scatter plot or Table + +```sql +SELECT + o.x, + o.y, + o.z, + sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0)) as speed, + o.agent_id +FROM observations o +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND o.time_index = $frame_number +ORDER BY o.agent_id +``` + +**Notes**: +- Color by speed for velocity field visualization +- Use with frame slider variable + +--- + +### 2.3 Speed Distribution (Histogram Data) + +**Use Case**: Velocity distribution analysis +**Panel Type**: Bar chart or Histogram + +```sql +SELECT + floor(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0)) / 0.5) * 0.5 as speed_bin, + count(*) as count +FROM observations +WHERE episode_id = $episode_id + AND agent_type_id = 'agent' + AND v_x IS NOT NULL + AND time_index BETWEEN $start_frame AND $end_frame +GROUP BY speed_bin +ORDER BY speed_bin +``` + +**Notes**: +- Bin width: 0.5 scene units per frame +- Adjust binning: change `/0.5` and `*0.5` values + +--- + +### 2.4 Agent Trajectories (Path Traces) + +**Use Case**: Movement paths over time +**Panel Type**: Table or export for external plotting + +```sql +SELECT + o.agent_id, + o.time_index, + o.x, + o.y, + o.z +FROM observations o +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND o.agent_id = $selected_agent_id +ORDER BY o.time_index +``` + +--- + +## Extended Properties + +### 3.1 Distance to Target Center Over Time + +**Use Case**: Track target approach behavior +**Panel Type**: Time series + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + avg(ep.value_float) as avg_distance, + min(ep.value_float) as min_distance, + max(ep.value_float) as max_distance +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND pd.property_name = 'Distance to Target Center' +GROUP BY o.time_index, e.frame_rate +ORDER BY o.time_index +``` + +**Notes**: +- Shows min/avg/max distance trends +- Useful for detecting convergence behavior + +--- + +### 3.2 Distance to Target Mesh (Individual Agents) + +**Use Case**: Per-agent target proximity +**Panel Type**: Time series (multi-line) + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + ep.value_float as distance, + o.agent_id::text as metric +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND pd.property_name = 'Distance to Target Mesh' +ORDER BY o.time_index, o.agent_id +``` + +--- + +### 3.3 Distance to Scene Boundary + +**Use Case**: Wall avoidance analysis +**Panel Type**: Time series + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + avg(ep.value_float) as avg_boundary_distance, + min(ep.value_float) as min_boundary_distance +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND pd.property_name = 'Distance to Scene Mesh' +GROUP BY o.time_index, e.frame_rate +ORDER BY o.time_index +``` + +**Notes**: +- Low values indicate boundary proximity +- Useful for collision avoidance analysis + +--- + +### 3.4 All Extended Properties for Single Agent + +**Use Case**: Detailed agent state inspection +**Panel Type**: Table + +```sql +SELECT + o.time_index, + pd.property_name, + ep.value_float, + pd.unit +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = $episode_id + AND o.agent_id = $selected_agent_id + AND o.agent_type_id = 'agent' +ORDER BY o.time_index, pd.property_name +``` + +--- + +## Time-Windowed Aggregations + +### 4.1 Speed Statistics per 100-Frame Window + +**Use Case**: Temporal dynamics at coarser resolution +**Panel Type**: Bar chart or Time series + +```sql +SELECT + floor(o.time_index / 100) * 100 as time_window, + avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as avg_speed, + stddev(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as speed_stddev, + count(*) as n_observations +FROM observations o +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL +GROUP BY time_window +ORDER BY time_window +``` + +**Notes**: +- Window size: 100 frames (~3.3 seconds at 30 FPS) +- Adjust window: change `/100` and `*100` + +--- + +### 4.2 Before/After t=500 Comparison + +**Use Case**: Compare early vs. late simulation dynamics +**Panel Type**: Stat panels (side-by-side) + +**Before t=500**: +```sql +SELECT + avg(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0))) as avg_speed_early +FROM observations +WHERE episode_id = $episode_id + AND agent_type_id = 'agent' + AND v_x IS NOT NULL + AND time_index < 500 +``` + +**After t=500**: +```sql +SELECT + avg(sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0))) as avg_speed_late +FROM observations +WHERE episode_id = $episode_id + AND agent_type_id = 'agent' + AND v_x IS NOT NULL + AND time_index >= 500 +``` + +--- + +### 4.3 Distance to Target per Time Window + +**Use Case**: Target approach trends over time +**Panel Type**: Time series + +```sql +SELECT + floor(o.time_index / 100) * 100 as time_window, + avg(ep.value_float) as avg_distance, + count(*) as n_observations +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND pd.property_name = 'Distance to Target Center' + AND o.time_index > 500 +GROUP BY time_window +ORDER BY time_window +``` + +--- + +## Multi-Episode Comparisons + +### 5.1 Average Speed Across All Episodes + +**Use Case**: Compare behavior consistency across runs +**Panel Type**: Bar chart or Table + +```sql +SELECT + o.episode_id, + avg(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as avg_speed, + stddev(sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0))) as speed_stddev +FROM observations o +WHERE o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL +GROUP BY o.episode_id +ORDER BY o.episode_id +``` + +--- + +### 5.2 Episode Summary Statistics + +**Use Case**: Episode metadata overview +**Panel Type**: Table + +```sql +SELECT + e.episode_id, + e.episode_number, + e.num_frames, + e.num_agents, + e.frame_rate, + s.session_name, + c.category_name +FROM episodes e +JOIN sessions s ON e.session_id = s.session_id +JOIN categories c ON s.category_id = c.category_id +ORDER BY e.episode_number +``` + +--- + +### 5.3 Distance to Target: Multi-Episode Comparison + +**Use Case**: Compare target approach across runs +**Panel Type**: Time series (one line per episode) + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + avg(ep.value_float) as avg_distance, + o.episode_id as metric +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.agent_type_id = 'agent' + AND pd.property_name = 'Distance to Target Center' +GROUP BY o.episode_id, o.time_index, e.frame_rate +ORDER BY o.time_index, o.episode_id +``` + +**Warning**: High cardinality query - may be slow with many episodes. + +--- + +## Grafana-Specific Tips + +### Variable Queries + +#### Episode Selector Variable +```sql +SELECT episode_id as __text, episode_id as __value +FROM episodes +ORDER BY episode_number +``` + +#### Frame Number Slider Variable +- Type: Interval +- Values: `0,100,500,1000,1500,2000,2500,3000` + +#### Agent ID Selector Variable +```sql +SELECT DISTINCT agent_id::text as __text, agent_id as __value +FROM observations +WHERE episode_id = '$episode_id' + AND agent_type_id = 'agent' +ORDER BY agent_id +``` + +--- + +### Time Range Filtering + +Grafana provides `$__timeFilter(column)` macro for automatic time range filtering: + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + -- your metrics here +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +WHERE $__timeFilter(to_timestamp(o.time_index * (1.0 / e.frame_rate))) + AND o.episode_id = $episode_id +``` + +--- + +### Panel-Specific Formatting + +#### For Time Series Panels +- Ensure first column is named `time` (timestamp type) +- Use `as metric` for series names +- Use `$__timeFilter()` for time range support + +#### For Heatmap Panels +- Format: "Time series buckets" or "Table" +- X-axis: Categorical (bin values) +- Y-axis: Time or categorical +- Value: Aggregation count/sum + +#### For Stat Panels +- Single value query (one row, one column) +- Add sparkline by including time series data + +#### For Table Panels +- Any column structure works +- Use column aliases for readable headers + +--- + +### Performance Optimization + +1. **Always filter by `episode_id`** - uses index +2. **Filter by `agent_type_id`** early - reduces scan +3. **Limit time ranges** - use `time_index BETWEEN` +4. **Use time windows** - aggregate with `floor(time_index / N)` +5. **Avoid SELECT \*** - specify needed columns only +6. **Test queries in psql first** - validate before Grafana + +--- + +### Connection Settings + +**Data Source Configuration**: +- Host: `localhost:5432` +- Database: `tracking_analytics` +- User: `postgres` +- Password: `password` (from Docker setup) +- SSL Mode: `disable` (local development) +- Version: PostgreSQL 17 with TimescaleDB + +--- + +## Available Properties Reference + +Current extended properties in the database: + +| Property Name | Data Type | Unit | Description | +|---------------|-----------|------|-------------| +| Distance to Target Center | float | scene_units | Euclidean distance to target centroid | +| Distance to Target Mesh | float | scene_units | Distance to nearest point on target mesh | +| Distance to Scene Mesh | float | scene_units | Distance to scene boundary | +| Target Mesh Closest Point X | float | scene_units | X coordinate of closest target mesh point | +| Target Mesh Closest Point Y | float | scene_units | Y coordinate of closest target mesh point | +| Target Mesh Closest Point Z | float | scene_units | Z coordinate of closest target mesh point | +| Scene Mesh Closest Point X | float | scene_units | X coordinate of closest scene mesh point | +| Scene Mesh Closest Point Y | float | scene_units | Y coordinate of closest scene mesh point | +| Scene Mesh Closest Point Z | float | scene_units | Z coordinate of closest scene mesh point | +| Speed | float | scene_units/frame | Magnitude of velocity vector | +| Acceleration X/Y/Z | float | scene_units/frame² | Acceleration components | +| Acceleration Magnitude | float | scene_units/frame² | Magnitude of acceleration | +| Bounding Box X1/X2/Y1/Y2 | float | pixels | Tracking bounding boxes (tracking_csv only) | + +--- + +## Example Dashboard Structure + +Recommended dashboard layout: + +``` +Row 1: Overview Statistics +├─ [Stat] Current Avg Speed +├─ [Stat] Total Agents +├─ [Stat] Avg Distance to Target +└─ [Stat] Frames Loaded + +Row 2: Time Series Analysis +├─ [Time Series] Agent Speed Over Time (multi-line) +└─ [Time Series] Distance to Target (avg/min/max) + +Row 3: Spatial Analysis +├─ [Heatmap] Position Density +└─ [Scatter] Current Agent Positions + +Row 4: Distribution Analysis +├─ [Bar Chart] Speed Distribution +└─ [Bar Chart] Distance Distribution + +Variables: +- Episode ID (dropdown) +- Start Frame (slider: 0-3000) +- End Frame (slider: 0-3000) +- Selected Agent ID (dropdown) +``` + +--- + +## Troubleshooting + +**Query returns no data**: +- Verify episode_id exists: `SELECT * FROM episodes` +- Check time_index range: episodes have 0-3000 frames +- Verify agent_type_id filter: use `'agent'` for boids + +**Slow queries**: +- Add `LIMIT` for testing +- Use time windows instead of raw observations +- Filter by episode_id first (indexed) +- Avoid joining extended_properties if not needed + +**Grafana time formatting issues**: +- Ensure `time` column is timestamp type +- Use `to_timestamp()` function +- Check timezone settings in Grafana + +--- + +**Last Updated**: 2025-11-06 +**Database Version**: PostgreSQL 17 + TimescaleDB +**Schema Version**: Phase 4 Complete (3D Boids) diff --git a/docs/dashboard/grafana/grafana_template_simple.json b/docs/dashboard/grafana/grafana_template_simple.json new file mode 100644 index 00000000..b82d14d8 --- /dev/null +++ b/docs/dashboard/grafana/grafana_template_simple.json @@ -0,0 +1,570 @@ +{ + "__inputs": [ + { + "name": "DS_DS-TRACKING-ANALYTICS", + "label": "ds-tracking-analytics", + "description": "", + "type": "datasource", + "pluginId": "grafana-postgresql-datasource", + "pluginName": "PostgreSQL" + } + ], + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "gauge", + "name": "Gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "12.2.1" + }, + { + "type": "datasource", + "id": "grafana-postgresql-datasource", + "name": "PostgreSQL", + "version": "12.2.1" + }, + { + "type": "panel", + "id": "histogram", + "name": "Histogram", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 4, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "12.2.1", + "targets": [ + { + "dataset": "tracking_analytics", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "select count(*) as __value, count(*) || 'sessions' as __text from sessions", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Total Sessions", + "type": "gauge" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 4, + "x": 4, + "y": 0 + }, + "id": 2, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "12.2.1", + "targets": [ + { + "dataset": "tracking_analytics", + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "select count(*) from episodes", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + } + } + ], + "title": "Total Episodes", + "type": "gauge" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 4, + "x": 8, + "y": 0 + }, + "id": 3, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "12.2.1", + "targets": [ + { + "dataset": "tracking_analytics", + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "select count(distinct(o.agent_id)) from observations o where o.episode_id = '$episode_id'", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + } + } + ], + "title": "Total agents", + "type": "gauge" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "showValues": false, + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 5 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.2.1", + "targets": [ + { + "dataset": "tracking_analytics", + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "select e.created_at + (o.time_index / e.frame_rate) * interval '1 second' as \"time\", sqrt(o.v_x*o.v_x + o.v_y * o.v_y + o.v_z * o.v_z) as \"speed\", agent_id::text as \"metric\"\nfrom observations o, episodes e\nwhere e.episode_id = o.episode_id and o.episode_id = '$episode_id' and agent_type_id='agent'\nORDER BY time asc", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + } + } + ], + "title": "Speeds", + "type": "timeseries" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "fillOpacity": 51, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "stacking": { + "group": "A", + "mode": "none" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": 0 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 13 + }, + "id": 4, + "options": { + "combine": false, + "legend": { + "calcs": [], + "displayMode": "table", + "placement": "right", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.2.1", + "targets": [ + { + "dataset": "tracking_analytics", + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT\n sqrt(v_x*v_x + v_y*v_y + COALESCE(v_z*v_z, 0)) as speed\nFROM observations\nWHERE episode_id = '$episode_id'\n AND agent_type_id = 'agent'\n AND v_x IS NOT NULL\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "${DS_DS-TRACKING-ANALYTICS}" + } + } + ], + "title": "Speed distribution", + "type": "histogram" + } + ], + "schemaVersion": 42, + "tags": [], + "templating": { + "list": [ + { + "current": {}, + "definition": "SELECT \n s.session_id as __value,\n s.session_name as __text\nFROM sessions s\nORDER BY s.created_at DESC", + "name": "session_id", + "options": [], + "query": "SELECT \n s.session_id as __value,\n s.session_name as __text\nFROM sessions s\nORDER BY s.created_at DESC", + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": {}, + "definition": "SELECT \n e.episode_id as __value,\n 'Episode ' || e.episode_number || ' (' || e.num_frames || ' frames, ' || e.num_agents || ' agents)' as __text\nFROM episodes e\nWHERE e.session_id = '$session_id'\nORDER BY e.episode_number", + "label": "Episode", + "name": "episode_id", + "options": [], + "query": "SELECT \n e.episode_id as __value,\n 'Episode ' || e.episode_number || ' (' || e.num_frames || ' frames, ' || e.num_agents || ' agents)' as __text\nFROM episodes e\nWHERE e.session_id = '$session_id'\nORDER BY e.episode_number", + "refresh": 1, + "regex": "", + "type": "query" + } + ] + }, + "time": { + "from": "2025-11-06T02:43:12.860Z", + "to": "2025-11-06T02:44:52.860Z" + }, + "timepicker": {}, + "timezone": "browser", + "title": "dima test", + "uid": "ad8x2wx", + "version": 6, + "weekStart": "" + } \ No newline at end of file diff --git a/docs/dashboard/spatial_analysis.md b/docs/dashboard/spatial_analysis.md new file mode 100644 index 00000000..97a9778e --- /dev/null +++ b/docs/dashboard/spatial_analysis.md @@ -0,0 +1,59 @@ +Descriptive Data Dashboard +========================== + +**Note**: This is a legacy requirements document. For current implementation status, +see [README.md](README.md). + +Original Requirements +--------------------- + +* General + * all statistics either global or with moving time window + * if boid type is available, all plots for each type and "global" plot + * before and after t=500 (3d) + * aggregate episodes from same config / across configs + +* Self-statistics + * ✅ heatmap of visited locations (implemented in Basic Data Viewer) + * heatmap of velocities (quiver plots) + * ✅ velocity (speed distribution, mean velocity magnitude) (implemented in Velocity Stats widget) + * acceleration (distribution), acceleration (vector) + * ✅ Mean velocity direction over time (distribution / time series) (implemented in Velocity Stats widget) + +* pairwise statistics - both "point clouds" (vector quantities) and distributions of magnitude + * ✅ relative positions (distances) (implemented in Distance widget) + * ✅ relative velocities (implemented in Velocity Stats widget) + +* correlations + * ✅ velocities (legacy Correlation widget) + * distances to target + * distances to mesh + * mutual distances (for each pair) + +* clustering statistics (TBD) + +Implementation Status +--------------------- + +✅ Completed: + +- [x] DB backend (QueryBackend with PostgreSQL/DuckDB support) +- [x] Basic Data Viewer (Phase 7.1) with integrated heatmap, animation, and time series +- [x] Enhanced Velocity Stats widget with three analysis groups: + - Individual agent speed (histogram + time series with mean ± std) + - Mean velocity magnitude (normalized velocities, magnitude of mean vector) + - Relative velocity magnitude (pairwise ||v_i - v_j|| analysis) +- [x] Enhanced Distance widget with pairwise relative locations: + - Relative distances ||x_i - x_j|| between all agent pairs + - Histogram + time series with mean ± std bands +- [x] Velocity Correlations widget (episode-level) + +🚧 Planned (Phase 7.2-7.3): + +- [ ] Enhanced Correlation Viewer (windowed/lagged modes) + +📝 Future: + +- [ ] Clustering statistics +- [ ] Velocity vector distributions (quiver plots) +- [ ] Acceleration analysis diff --git a/docs/data/db/README.md b/docs/data/db/README.md new file mode 100644 index 00000000..ef9b10c1 --- /dev/null +++ b/docs/data/db/README.md @@ -0,0 +1,874 @@ +# Database Layer Documentation + +Unified tracking analytics database supporting PostgreSQL and DuckDB. + +## Quick Links + +**Data Layer:** +- **[Schema Documentation](schema.md)** - Database schema details and SQL files +- **[Data Formats](data_formats.md)** - Source data documentation +- **[Cascading Deletes](cascading_deletes.md)** - How to safely delete data with automatic cleanup +- **[Data Loader Improvements](data_loader_plan.md)** - Planned data loading performance improvements (COPY, optimizations) + +**Query & Visualization Layer:** +- **[Dashboard System](../dashboard/README.md)** - 🎯 **QueryBackend API + GUI Widgets** - Complete guide to querying and visualizing data +- **[Grafana Integration](../../dashboard/grafana/grafana_integration.md)** - Grafana dashboards and queries +- **[Grafana Query Library](../../dashboard/grafana/grafana_queries.md)** - 30+ tested SQL queries + +**Historical:** +- **[Schema Refactoring](archive/schema_refactoring.md)** - ✅ COMPLETE (2025-11-08) +- **[Implementation Progress](implementation_progress.md)** - ⚠️ DEPRECATED - See current docs above + +## Overview + +The database layer provides a unified interface for storing and querying tracking data from multiple sources: +- **3D Boids**: Parquet files from `collab_env.sim.boids` +- **2D Boids**: PyTorch `.pt` files from GNN training +- **2D Boids GNN Rollout**: Pickle files with GNN model predictions (actual vs predicted trajectories) +- **Tracking CSV**: Real-world video tracking data + +### Architecture + +``` +┌─────────────────────────────────────────┐ +│ collab_env.data.db.config │ +│ - Environment variable configuration │ +│ - SQLAlchemy URL generation │ +└─────────────────┬───────────────────────┘ + │ + ┌────────┴────────┐ + │ │ +┌────────▼──────────┐ ┌───▼────────────────────┐ +│ init_database.py │ │ db_loader.py │ +│ ─────────────── │ │ ────────────── │ +│ Initialize DB │ │ Load data from: │ +│ - Create tables │ │ - 3D boids (parquet) │ +│ - Seed data │ │ - 2D boids (.pt) ✅ │ +│ - Verify setup │ │ - CSV tracking ✅ │ +└───────────────────┘ └────────────────────────┘ +``` + +## Key Features + +✅ **Unified Interface**: SQLAlchemy-based abstraction for both PostgreSQL and DuckDB +✅ **Flexible Schema**: EAV pattern for extended properties +✅ **Fast Loading**: Bulk inserts via pandas (~18s per 90K observations) +✅ **Multi-Session Loading**: Load multiple datasets/simulations in a single transaction +✅ **Environment Config**: Configure via environment variables or CLI args +✅ **Automatic Adaptation**: SQL dialect conversion for DuckDB +✅ **Environment Entities**: Full support for agents and environment entities with composite primary keys +✅ **Cascading Deletes**: Automatic cleanup when deleting sessions, episodes, or categories + +## Quick Start + +### 1. Install Dependencies + +```bash +source .venv-310/bin/activate +pip install -r requirements-db.txt +``` + +### 2. Configure Environment (Optional) + +```bash +# Copy example environment file +cp .env.example .env + +# Edit .env with your database settings +# DB_BACKEND=duckdb (or postgres) +# POSTGRES_DB=tracking_analytics +# POSTGRES_USER=dima +# etc. +``` + +Environment variables will be used as defaults. Command-line arguments override them. + +Optional - install PostgreSQL server: +```bash +docker run -v timescaledb_data:/var/lib/postgresql/data \ + -d --name timescaledb -p 127.0.0.1:5432:5432 -e POSTGRES_PASSWORD=password timescale/timescaledb:latest-pg17 +``` + +### 3. Initialize Database + +**Option A: DuckDB (recommended for local development)** +```bash +python -m collab_env.data.db.init_database --backend duckdb --dbpath ./data/tracking.duckdb +``` + +**Option B: PostgreSQL (for production/Grafana)** +```bash +# Requires PostgreSQL server running +# This will drop and recreate the database 'tracking_analytics' +python -m collab_env.data.db.init_database --backend postgres + +# Or, if you want to preserve existing database and only create tables: +python -m collab_env.data.db.init_database --backend postgres --no-drop +``` + +**Option C: Use Environment Variables** +```bash +# Set DB_BACKEND in .env, then run without arguments +python -m collab_env.data.db.init_database +``` + +### 4. Verify Installation + +```bash +# DuckDB +duckdb ./data/tracking.duckdb -c "SHOW TABLES;" + +# PostgreSQL +psql tracking_analytics -c "\dt" +``` + +## Loading Data + +### Load 3D Boids Simulation + +**Single Simulation:** +```bash +# Load a complete simulation directory (auto-detected from config.yaml) +python -m collab_env.data.db.db_loader \ + --source boids3d \ + --path simulated_data/hackathon/hackathon-boid-small-200-sim_run-started-20250926-220926 + +# With specific backend +python -m collab_env.data.db.db_loader \ + --source boids3d \ + --path simulated_data/hackathon/hackathon-boid-small-200-sim_run-started-20250926-220926 \ + --backend duckdb \ + --dbpath ./data/tracking.duckdb + +# Load only first 5 episodes per simulation (useful for testing) +python -m collab_env.data.db.db_loader \ + --source boids3d \ + --path simulated_data/hackathon/hackathon-boid-small-200-sim_run-started-20250926-220926 \ + --max_episodes_per_session 5 +``` + +**Multiple Simulations (Bulk Loading):** +```bash +# Load all simulations from a parent directory in single transaction +python -m collab_env.data.db.db_loader \ + --source boids3d \ + --path simulated_data/hackathon/ + +# Load only first 3 episodes from each simulation (useful for large datasets) +python -m collab_env.data.db.db_loader \ + --source boids3d \ + --path simulated_data/hackathon/ \ + --max_episodes_per_session 3 + +# The loader auto-detects subdirectories with config.yaml files +# Progress: [1/5] Loading simulation_1... +# [2/5] Loading simulation_2... +# etc. +``` + +The 3D loader will: +- Create session metadata from config.yaml +- Load all episode-*.parquet files +- Extract observations (positions, velocities) for all entity types (agents and environment) +- Load extended properties (distances, mesh data) + +### Load 2D Boids Simulation + +**Single Dataset:** + +```bash +# Load a single PyTorch .pt file +python -m collab_env.data.db.db_loader \ + --source boids2d \ + --path simulated_data/boid_food_basic.pt + +# With specific backend +python -m collab_env.data.db.db_loader \ + --source boids2d \ + --path simulated_data/boid_food_basic.pt \ + --backend postgres + +# Load only first 100 episodes (useful for large datasets) +python -m collab_env.data.db.db_loader \ + --source boids2d \ + --path simulated_data/boid_food_basic.pt \ + --max_episodes_per_session 100 +``` + +**Multiple Datasets (Bulk Loading):** + +```bash +# Load all .pt datasets from a directory in single transaction +python -m collab_env.data.db.db_loader \ + --source boids2d \ + --path simulated_data/ + +# Load only first 50 episodes from each dataset +python -m collab_env.data.db.db_loader \ + --source boids2d \ + --path simulated_data/ \ + --max_episodes_per_session 50 + +# The loader auto-discovers all .pt files (excluding *_config.pt) +# Progress: [1/16] Loading boid_food_basic.pt... +# [2/16] Loading boid_food_basic_independent.pt... +# etc. +``` + +The 2D loader will: + +- Load PyTorch dataset from .pt file +- Load configuration from matching *_config.pt file +- Compute velocities from position differences: `v[t] = p[t+1] - p[t]` +- Scale coordinates from normalized [0,1] to scene coordinates [0, scene_size] +- Create 2D observations (z and v_z are NULL) +- **Compute extended properties** (if food is present in config): + - `distance_to_food`: Euclidean distance from each boid to food location + +**Performance**: 8,000+ observations/second for bulk loading + +### Load Tracking CSV Data + +**Single Session:** + +```bash +# Load a single tracking session (auto-detected from aligned_frames/) +python -m collab_env.data.db.db_loader \ + --source tracking \ + --path data/processed_tracks/2024_06_01-session_0003 + +# With specific backend +python -m collab_env.data.db.db_loader \ + --source tracking \ + --path data/processed_tracks/2024_06_01-session_0003 \ + --backend postgres + +# Load only first 2 camera episodes (useful for testing multi-camera setups) +python -m collab_env.data.db.db_loader \ + --source tracking \ + --path data/processed_tracks/2024_06_01-session_0003 \ + --max_episodes_per_session 2 +``` + +**Multiple Sessions (Bulk Loading):** + +```bash +# Load all tracking sessions from a parent directory in single transaction +python -m collab_env.data.db.db_loader \ + --source tracking \ + --path data/processed_tracks/ + +# Load only first camera from each session (faster for initial exploration) +python -m collab_env.data.db.db_loader \ + --source tracking \ + --path data/processed_tracks/ \ + --max_episodes_per_session 1 + +# The loader auto-discovers all session directories with aligned_frames/ +# Progress: [1/8] Loading 2023_11_05-session_0001... +# [2/8] Loading 2023_11_05-session_0002... +# etc. +``` + +The tracking loader will: + +- Load session metadata from optional `Metadata.yaml` file +- Discover all camera directories in `aligned_frames/` subdirectory +- **Auto-detect and load all CSV files** in each camera directory (not just `*_tracks.csv`) +- Compute velocities from positions: `v[t] = (p[t+1] - p[t]) / dt` where `dt = frame_diff / frame_rate` +- Handle frame gaps by setting velocity to NaN when frames are missing +- Store velocities in pixels/second (2D) or world units/second (3D) + +**Supported CSV Formats**: + +| Format | Columns | Episodes Created | Notes | +| ------ | ------- | ---------------- | ----- | +| **2D Tracks** | `track_id, frame, x, y` | 1 (2D) | Simple centroid tracking | +| **2D Bounding Boxes** | `track_id, frame, x1, y1, x2, y2, confidence, class` | 1 (2D) | Centroid computed as `(x1+x2)/2, (y1+y2)/2` | +| **3D Centroids** | `track_id, frame, x1, y1, x2, y2, confidence, class, u, v, x, y, z` | **2** (3D + 2D) | Creates separate episodes for world coords (x,y,z) and image coords (u,v) | + +**Episode Naming**: + +- 2D tracks: `episode-{camera}_{csv_stem}-{session}` +- 2D bounding boxes: `episode-{camera}_{csv_stem}-{session}` +- 3D centroids: `episode-{camera}_{csv_stem}_3d-{session}` and `episode-{camera}_{csv_stem}_2d-{session}` + +**Example**: A camera directory with both `rgb_1_tracked_bboxes.csv` and `rgb_1_tracked_centroids_3d.csv` will create 3 episodes: + +1. `episode-rgb_1_rgb_1_tracked_bboxes-{session}` (2D centroids from bounding boxes) +2. `episode-rgb_1_rgb_1_tracked_centroids_3d_3d-{session}` (3D world coordinates) +3. `episode-rgb_1_rgb_1_tracked_centroids_3d_2d-{session}` (2D image coordinates) + +**Performance**: ~5,000 observations/second for bulk loading + +### Load GNN Rollout Data + +**Single Rollout File:** + +```bash +# Load a single rollout pickle file +python -m collab_env.data.db.db_loader \ + --source boids2d_rollout \ + --path trained_models/food/basic/n0_h1_vr0.5_s2/rollout_results/file260_foodbasic_n0_h1_vr0.5_s2_30.pkl + +# With specific scene size (default: 480.0) +python -m collab_env.data.db.db_loader \ + --source boids2d_rollout \ + --path trained_models/food/basic/n0_h1_vr0.5_s2/rollout_results/file260_foodbasic_n0_h1_vr0.5_s2_30.pkl \ + --backend duckdb \ + --dbpath ./data/tracking.duckdb + +# Load only first 100 trajectories (useful for large rollout files) +python -m collab_env.data.db.db_loader \ + --source boids2d_rollout \ + --path trained_models/food/basic/n0_h1_vr0.5_s2/rollout_results/file260_foodbasic_n0_h1_vr0.5_s2_30.pkl \ + --max_episodes_per_session 100 +``` + +**Multiple Rollout Files (Bulk Loading):** + +```bash +# Load all rollout files from a directory in single transaction +python -m collab_env.data.db.db_loader \ + --source boids2d_rollout \ + --path trained_models/food/basic/n0_h1_vr0.5_s2/rollout_results/ + +# Load only first 50 trajectories from each rollout file +python -m collab_env.data.db.db_loader \ + --source boids2d_rollout \ + --path trained_models/food/basic/n0_h1_vr0.5_s2/rollout_results/ \ + --max_episodes_per_session 50 + +# The loader auto-discovers all .pkl files in the directory +# Progress: [1/10] Loading file260_foodbasic_n0_h1_vr0.5_s2_30.pkl... +# [2/10] Loading file260_foodbasic_n0_h1_vr0.5_s2_35.pkl... +# etc. +``` + +The GNN rollout loader will: + +- Load rollout pickle files containing GNN model predictions +- Create **paired episodes** for each trajectory: + - **Actual episode**: Ground truth trajectory from test data (positions, velocities, accelerations only) + - **Predicted episode**: GNN model prediction for same initial conditions (positions, velocities, accelerations, attention weights) +- Extract positions and velocities from rollout tensors +- Compute acceleration from velocity differences: `a[t] = v[t+1] - v[t]` +- Process multi-head attention weights (average across heads) - **predicted episodes only** +- Decompose attention into components (predicted episodes only): + - `attn_weight_self`: Self-attention weight + - `attn_weight_boid`: Sum of attention to other boid agents + - `attn_weight_food`: Attention to food agent (if present) +- Compute spatial metrics: + - **Actual episodes**: `distance_to_food` - distance to actual food position + - **Predicted episodes**: + - `distance_to_food_actual` - distance to TRUE food position (from actual episode) + - `distance_to_food_predicted` - distance to GNN-predicted food position +- Store extended properties: + - **Actual episodes**: acceleration_x, acceleration_y, distance_to_food (if food present) + - **Predicted episodes**: acceleration_x, acceleration_y, distance_to_food_actual, distance_to_food_predicted (if food present), attn_weight_self, attn_weight_boid, attn_weight_food +- Handle CUDA tensors safely (automatic CPU mapping for CPU-only machines) +- Scale coordinates from normalized [0,1] to scene coordinates [0, scene_size] + +**Episode ID Format**: `{session_id}-{trajectory_number:04d}-{actual|predicted}` + +Example episode IDs: +- `file260_foodbasic_n0_h1_vr0.5_s2_30-0000-actual` +- `file260_foodbasic_n0_h1_vr0.5_s2_30-0000-predicted` +- `file260_foodbasic_n0_h1_vr0.5_s2_30-0001-actual` +- `file260_foodbasic_n0_h1_vr0.5_s2_30-0001-predicted` + +**Pickle File Format Requirements**: +- Dictionary with keys: `x_actual`, `x_predicted`, `attn_weights` (optional) +- Position tensors: shape `(num_trajectories, num_timesteps, num_agents, 2)` +- Attention weights: shape `(num_trajectories, num_timesteps, num_agents, num_agents)` or `(num_trajectories, num_timesteps, num_heads, num_agents, num_agents)` +- Food agent detection: Last agent is food if 'food' in filename + +**Performance**: ~1,850 observations/second (~25K observations per episode in ~68 seconds for 4 episodes) + +**Use Cases**: +- **Model Evaluation**: Compare GNN predictions to ground truth in database +- **Error Analysis**: Query spatial/temporal patterns in prediction errors +- **Attention Analysis**: Visualize attention weight evolution over time +- **Ablation Studies**: Compare multiple model configurations via SQL queries + +### Limiting Episodes Per Session + +For testing, development, or working with large datasets, you can limit the number of episodes loaded per session using the `--max_episodes_per_session` option: + +```bash +# Load only first 5 episodes from each session +python -m collab_env.data.db.db_loader \ + --source boids3d \ + --path simulated_data/hackathon/ \ + --max_episodes_per_session 5 +``` + +**Use Cases:** +- **Quick Testing**: Verify database setup and loader functionality without waiting for full dataset +- **Development**: Iterate faster when developing queries or visualizations +- **Large Datasets**: Explore data structure before committing to full load +- **Sampling**: Create representative subset for analysis or demonstrations + +**Behavior:** +- Applies independently to each session (not globally across all sessions) +- Episodes are loaded in order (0, 1, 2, ..., N-1) +- Progress logs show actual episodes loaded vs total available +- Works with all data sources: `boids3d`, `boids2d`, and `tracking` + +**Example Output:** +``` +Loading up to 5 out of 50 episodes in single transaction... +[1/50] Loading episode 0 from: episode-0.parquet +[2/50] Loading episode 1 from: episode-1.parquet +... +[5/50] Loading episode 4 from: episode-4.parquet +Reached maximum number of episodes (5) for session session-xyz, stopping... +Completed loading simulation: session-xyz (5 out of 50 episodes) +``` + +## Database Schema + +The unified schema supports four data sources: +- **3D Boids**: Parquet files from simulations +- **2D Boids**: PyTorch .pt files +- **2D Boids GNN Rollout**: Pickle files with GNN model predictions +- **Tracking CSV**: Video tracking data + +### Tables Created + +1. **sessions** - Top-level grouping (simulation runs, fieldwork sessions) +2. **episodes** - Individual runs within a session +3. **agent_types** - Type definitions (agent, env, target, food, bird, rat, gerbil) +4. **observations** - Core time-series data (positions, velocities) +5. **categories** - Session and property categories (boids_3d, boids_2d, boids_2d_rollout, tracking_csv) +6. **property_definitions** - Extended property definitions (distances, accelerations, attention weights, etc.) +7. **property_category_mapping** - M2M relationship between properties and categories +8. **extended_properties** - EAV storage for flexible properties + +### Key Design Features + +- **Composite Primary Keys**: Natural keys on observations `(episode_id, time_index, agent_id, agent_type_id)` - allows same agent_id for different entity types +- **EAV Pattern**: Flexible extended properties without hardcoded columns +- **Unified Categories**: Single categories table for both sessions and extended properties +- **Unified Interface**: Same schema works for PostgreSQL and DuckDB + +For complete schema documentation, see [schema/README.md](schema.md). + +## Environment Entities Support + +✅ **Fully Supported**: The database stores both agent entities and environment entities using a composite primary key. + +### Schema Design + +The observations table uses `agent_type_id` in the primary key to distinguish between different entity types with the same ID: + +```sql +PRIMARY KEY (episode_id, time_index, agent_id, agent_type_id) +``` + +This allows the same `agent_id` to be used for different entity types: +- **Agent**: `episode='e1', time=0, agent_id=0, type='agent', x=10.0, y=20.0` +- **Environment**: `episode='e1', time=0, agent_id=0, type='env', x=100.0, y=200.0` ✅ No conflict + +### Agent Types + +The database supports multiple agent types through the `agent_types` table: + +| Type ID | Type Name | Description | +|---------|-----------|-------------| +| `agent` | agent | Generic simulated agent (boid) | +| `env` | environment | Environment entity (walls, obstacles, boundaries) | +| `target` | target | Target object in simulation | +| `food` | food | Stationary food target in 2D boids simulation | +| `bird` | bird | Bird detected in video tracking | +| `rat` | rat | Rat detected in video tracking | +| `gerbil` | gerbil | Gerbil detected in video tracking | + +### Querying Different Entity Types + +```sql +-- Get only agents +SELECT * FROM observations WHERE agent_type_id = 'agent'; + +-- Get only environment entities +SELECT * FROM observations WHERE agent_type_id = 'env'; + +-- Get entities with same agent_id but different types +SELECT agent_id, agent_type_id, x, y, z +FROM observations +WHERE agent_id = 0 AND episode_id = 'episode-1' +ORDER BY time_index, agent_type_id; + +-- Count entities by type +SELECT agent_type_id, COUNT(*) +FROM observations +GROUP BY agent_type_id; +``` + +### Benefits + +✅ **Complete data representation** - all simulation entities are stored +✅ **Agent-environment interactions** - analyze spatial relationships +✅ **Scene boundaries** - available for visualizations +✅ **Natural schema** - uses existing agent_types mechanism +✅ **Flexible** - easily add new entity types + +## Backend Comparison + +| Feature | PostgreSQL | DuckDB | +|---------|-----------|--------| +| **Setup** | Requires server | Zero-config file | +| **Use Case** | Production, Grafana | Local development, analytics | +| **Concurrency** | High | Single-writer | +| **Performance** | Good for OLTP | Excellent for OLAP | +| **SQL Compatibility** | Full SQL | Most SQL features | +| **Foreign Keys** | Full CASCADE support | Limited CASCADE | + +## Usage Examples + +### Python API + +```python +from collab_env.data.db.config import get_db_config +from collab_env.data.db.db_loader import DatabaseConnection + +# Connect to database +config = get_db_config() # Reads from environment +db = DatabaseConnection(config) +db.connect() + +# Execute queries +result = db.fetch_all( + "SELECT * FROM observations WHERE episode_id = :ep_id LIMIT 10", + {'ep_id': 'episode-0-...'} +) + +# Bulk insert DataFrame +import pandas as pd +df = pd.DataFrame({'col1': [1, 2, 3], 'col2': ['a', 'b', 'c']}) +db.insert_dataframe(df, 'my_table') + +db.close() +``` + +### Direct Database Access + +**DuckDB:** +```python +import duckdb + +conn = duckdb.connect('tracking.duckdb') + +# Query categories +df = conn.execute(""" + SELECT * FROM categories +""").df() + +# Query observations with extended properties +df = conn.execute(""" + SELECT + o.episode_id, + o.time_index, + o.agent_id, + o.x, o.y, o.z, + pd.property_name, + ep.value_float + FROM observations o + JOIN extended_properties ep ON o.observation_id = ep.observation_id + JOIN property_definitions pd ON ep.property_id = pd.property_id + WHERE o.episode_id = ? +""", ['episode-0-...']).df() + +conn.close() +``` + +**PostgreSQL:** +```python +import psycopg2 + +conn = psycopg2.connect( + dbname='tracking_analytics', + user='dima', + host='localhost' +) + +cur = conn.cursor() +cur.execute("SELECT * FROM categories") +rows = cur.fetchall() + +conn.close() +``` + +## Grafana Integration ✅ + +**Status**: Prototype complete - ready to use! + +Visualize your boid simulation data with ready-to-use Grafana dashboards and query templates. + +### Grafana Quick Start + +1. **Install Grafana**: + + ```bash + # macOS + brew install grafana + brew services start grafana + + # Access at http://localhost:3000 (admin/admin) + ``` + +2. **Configure Data Source**: + - Type: PostgreSQL + - Host: `localhost:5432` + - Database: `tracking_analytics` + - User: `postgres` + - Password: `password` + - SSL Mode: `disable` (for local) + +3. **Import Dashboard**: + - Go to **Dashboards** → **Import** + - Upload: `docs/data/db/grafana_dashboard_template.json` + - Select data source: `tracking_analytics` + +### Available Dashboards + +#### 1. Time Series Overview + +- Agent speed over time (individual and average) +- Distance to target tracking +- Current statistics (stat panels) +- Episode selector variable + +#### 2. Spatial Analysis + +- Position density heatmaps +- Speed distribution histograms +- Agent state tables with color coding + +#### 3. Time-Windowed Statistics + +- 100-frame window aggregations +- Before/after t=500 comparisons +- Distance convergence analysis + +### Documentation + +- **[📖 Complete Integration Guide](../../dashboard/grafana/grafana_integration.md)** - Setup, dashboard creation, troubleshooting +- **[📝 Query Library](../../dashboard/grafana/grafana_queries.md)** - 30+ tested SQL queries for all visualizations +- **[📊 Dashboard Template](../../dashboard/grafana/grafana_dashboard_template.json)** - Importable Grafana dashboard JSON + +### Example Queries + +#### Time-Series Speed + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0)) as speed, + o.agent_id::text as metric +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +WHERE o.episode_id = $episode_id + AND o.agent_type_id = 'agent' + AND o.v_x IS NOT NULL +ORDER BY o.time_index +``` + +#### Spatial Heatmap + +```sql +SELECT + floor(x / 10) * 10 as x_bin, + floor(y / 10) * 10 as y_bin, + count(*) as value +FROM observations +WHERE episode_id = $episode_id + AND agent_type_id = 'agent' + AND time_index BETWEEN $start_frame AND $end_frame +GROUP BY x_bin, y_bin +``` + +#### Distance to Target + +```sql +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + avg(ep.value_float) as avg_distance +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = $episode_id + AND pd.property_name = 'Distance to Target Center' +GROUP BY o.time_index, e.frame_rate +ORDER BY o.time_index +``` + +See [grafana_queries.md](../../dashboard/grafana/grafana_queries.md) for the complete query library. + +## Performance + +### Loading Performance + +| Operation | Time | Notes | +|-----------|------|-------| +| Database init | ~2 seconds | 8 tables, seed data | +| Load 90K observations (3D) | ~18 seconds | Single episode, bulk insert via pandas | +| Load 10 episodes (3D) | ~3 minutes | 900K observations total | +| Load 2,000 episodes (2D) | ~52 seconds | 420K observations, single transaction bulk loading | +| Bulk loading rate (2D) | 8,000+ obs/sec | Multiple datasets in single transaction | +| Load 4 rollout episodes (GNN) | ~68 seconds | 100K observations + extended properties | +| Bulk loading rate (GNN rollout) | ~1,850 obs/sec | Includes attention weights and accelerations | + +### Optimization + +- Uses pandas `to_sql()` for bulk inserts (2x faster than executemany) +- Single transaction for multi-session loading (commit only once at the end) +- SQLAlchemy connection pooling +- Minimal indexes for fast writes +- Future: COPY command could be 10-100x faster (not yet implemented) + +### Performance Tips + +1. **Use categories** to filter only relevant extended properties and sessions +2. **Filter by episode_id** early in queries (indexed) +3. **Batch inserts** when loading data (10K+ rows at once) +4. **Consider materialized views** for frequently-accessed aggregations +5. **Use DuckDB for local analysis**, PostgreSQL for production serving + +## Code Structure + +``` +collab_env/data/db/ +├── __init__.py +├── config.py # Environment variable configuration +├── init_database.py # Database initialization +└── db_loader.py # Data loading (3D boids complete) + +schema/ +├── 01_core_tables.sql # Core dimension and fact tables +├── 02_extended_properties.sql # EAV pattern for properties +├── 03_seed_data.sql # Default agent types and properties +├── 04_views_examples.sql # Example query templates +└── README.md # Schema documentation + +docs/data/db/ +├── README.md # This file +└── data_formats.md # Source data documentation +``` + +## Implementation Status + +### Complete ✅ + +- [x] Database schema (EAV pattern with property categories) +- [x] PostgreSQL and DuckDB support +- [x] SQLAlchemy-based unified interface +- [x] Environment variable configuration +- [x] Database initialization with verification +- [x] 3D boids data loader (parquet files) +- [x] 2D boids data loader (PyTorch .pt files) +- [x] GNN rollout loader (pickle files with actual vs predicted trajectories) +- [x] Multi-session bulk loading (single transaction) +- [x] Batch loading with pandas to_sql +- [x] Environment entity support with composite primary keys +- [x] Extended properties loading (distances, mesh coordinates, accelerations, attention weights, distance to food) +- [x] Cascading deletes (PostgreSQL only, DuckDB limitation documented) +- [x] Grafana dashboards (prototype with query library and templates) + +### TODO ⏳ + +**Data Loading:** + +- [ ] PostgreSQL COPY optimization for 10-100x faster loading (see [data_loader_plan.md](data_loader_plan.md)) + +**Query & Visualization:** +- See **[Dashboard System](../dashboard/README.md)** for: + - ✅ QueryBackend API (production ready) + - ✅ Spatial analysis GUI (production ready) + - ⏳ Unified widget architecture (planned - Phase 7) + - ⏳ Property computation framework (planned - Phase 8) + +**Advanced Features:** +- [ ] Advanced Grafana features (correlations, pairwise statistics, alerts) + +## Troubleshooting + +### PostgreSQL Connection Error + +**Error**: `psycopg2.OperationalError: could not connect to server` + +**Solution**: Ensure PostgreSQL is running: +```bash +brew services start postgresql@14 +# or +pg_ctl -D /usr/local/var/postgres start +``` + +### DuckDB File Locked + +**Error**: `IO Error: Could not set lock on file` + +**Solution**: Close all DuckDB connections and retry + +### Schema File Not Found + +**Error**: `Schema file not found: schema/01_core_tables.sql` + +**Solution**: Run from project root: +```bash +cd /Users/dima/git/collab-environment +python -m collab_env.data.db.init_database +``` + +## Configuration + +Configure via environment variables (`.env` file) or command-line arguments. + +### Environment Variables + +```bash +# Database backend +DB_BACKEND=duckdb # or postgres (default: duckdb) + +# PostgreSQL settings +POSTGRES_DB=tracking_analytics # Database name (default: tracking_analytics) +POSTGRES_USER=your_user # Database user (default: $USER) +POSTGRES_PASSWORD=your_password # Database password (default: none) +POSTGRES_HOST=localhost # Database host (default: localhost) +POSTGRES_PORT=5432 # Database port (default: 5432) + +# DuckDB settings +DUCKDB_PATH=tracking.duckdb # Database file path (default: tracking.duckdb) +DUCKDB_READ_ONLY=false # Read-only mode (default: false) +``` + +**Important**: By default, `init_database.py` will **drop and recreate** the database. Use `--no-drop` to preserve existing database and only create tables. + +See [.env.example](../../../.env.example) for complete template. + +## Architecture Improvements + +### SQLAlchemy Unification (2025-11-05) + +Refactored entire database layer to use SQLAlchemy: + +**Benefits**: +- 62% code reduction in database logic +- 2x faster data loading (18s vs 40s per episode) +- Unified interface across all database code +- Named parameters instead of positional +- Standard patterns for connection management + +**Changes**: +- `init_database.py`: Merged 2 backend classes → 1 unified class +- `db_loader.py`: Replaced manual connections with SQLAlchemy +- Both use `create_engine()` and `text()` queries +- Both use `config.sqlalchemy_url()` for connections + +## References + +- [SQLAlchemy Documentation](https://docs.sqlalchemy.org/) +- [DuckDB Documentation](https://duckdb.org/) +- [PostgreSQL Documentation](https://www.postgresql.org/docs/) +- [Grafana Documentation](https://grafana.com/docs/) diff --git a/docs/data/db/archive/README.md b/docs/data/db/archive/README.md new file mode 100644 index 00000000..8fb59c3e --- /dev/null +++ b/docs/data/db/archive/README.md @@ -0,0 +1,23 @@ +# Archive - Historical Database Documentation + +This directory contains historical documentation that has been completed or superseded. + +## Contents + +- **[schema_refactoring.md](schema_refactoring.md)** - ✅ COMPLETE (2025-11-08) + - Category system simplification design document + - Migration of tracking metadata to extended_properties + - Contains design rationale, migration scripts, and implementation summary + - Valuable reference for understanding why schema decisions were made + +## Purpose + +These documents are archived rather than deleted because they provide: +- Historical context for design decisions +- Migration scripts if needed for production databases +- Design rationale and problem statements +- Reference material for future refactoring efforts + +--- + +**Last Updated**: 2025-11-08 diff --git a/docs/data/db/archive/schema_refactoring.md b/docs/data/db/archive/schema_refactoring.md new file mode 100644 index 00000000..fba34ce7 --- /dev/null +++ b/docs/data/db/archive/schema_refactoring.md @@ -0,0 +1,512 @@ +# Database Schema Refactoring - Category System Simplification + +**Created:** 2025-11-07 +**Completed:** 2025-11-08 +**Status:** ✅ COMPLETE - ALL CHANGES IMPLEMENTED AND TESTED + +--- + +## Overview + +This document outlines the completed database category system simplification and migration of tracking metadata from observations to extended_properties. + +**Summary of Changes:** +- ✅ Removed 'computed' category from database +- ✅ Dropped property_category_mapping table entirely +- ✅ Moved confidence and detection_class from observations to extended_properties +- ✅ Only 3 categories remain: boids_3d, boids_2d, tracking_csv +- ✅ All tests passing (33 tests: 21 init_database, 12 db_loader) + +**Key Changes:** +1. Remove `computed` category (procedural, doesn't belong) +2. Remove `property_category_mapping` table (unnecessary M2M) +3. Move `confidence` and `detection_class` from observations to extended_properties +4. Keep only 3 session-type categories: boids_3d, boids_2d, tracking_csv + +--- + +## Current State Analysis + +**Current Category Structure:** +``` +categories table: +- boids_3d: 3D Boids Simulations +- boids_2d: 2D Boids Simulations +- tracking_csv: Real-World Tracking +- computed: Computed Properties ← TO BE REMOVED +``` + +**Current Usage:** +- Sessions reference category_id: `boids_3d`, `boids_2d`, `tracking_csv` (NOT `computed`) +- Extended properties map to categories via M2M relationship +- Computed properties (speed, acceleration) map to BOTH: + - `computed` category (procedural classification) ← PROBLEM + - Specific session categories: `boids_3d`, `boids_2d`, `tracking_csv` (applicability) + +**Problem Identified:** +- `computed` category is **procedural** (describes HOW property is created) +- Other categories are **data source** types (describes WHERE data comes from) +- This creates confusion and unnecessary complexity +- Properties don't need separate categorization - they're just properties! + +**Current observations table:** +- Contains `confidence` and `detection_class` columns +- These are tracking-specific metadata, not universal data +- Violates principle: observations = universal data only + +--- + +## Proposed New Design: Maximally Flat Structure + +**Extremely Simple Design:** +- **Categories** = Data source types ONLY (boids_3d, boids_2d, tracking_csv) + - Only used for `sessions.category_id` to identify data source +- **Properties** = Flat list in `property_definitions` + - No categorization, no mapping tables +- **Discovery** = Query what actually exists in `extended_properties` + - Source of truth is always the data + +**Rationale:** +- This is an **analytics/research database** - discover what's in the data, don't enforce schemas +- A property is a property, regardless of whether it's "computed" or "raw" +- If a property exists in `extended_properties`, it's available. Period. +- No need for M2M mapping - can always query to discover: + - "What properties exist for this session?" → Query extended_properties + - "What sessions use this property?" → Query extended_properties +- Simpler schema = easier to maintain, no sync issues + +**Result:** +- **Remove** `computed` category entirely +- **Remove** `property_category_mapping` table entirely +- **Keep** session categories (boids_3d, boids_2d, tracking_csv) for sessions only + +**Tables After Refactoring:** +``` +categories: Just 3 rows (boids_3d, boids_2d, tracking_csv) +sessions: References category_id for data source type +observations: ONLY universal data (position x/y/z, velocity v_x/v_y/v_z, metadata) +property_definitions: All available properties (flat list, includes tracking-specific) +extended_properties: All non-universal data (distances, accelerations, bbox, confidence, etc.) +``` + +**Key Principle:** +- `observations` table = **Universal data present in all session types** (position, velocity, time, agent) +- `extended_properties` table = **Everything else** (session-specific, computed, metadata) + +--- + +## Database Changes Required + +### 1. schema/02_extended_properties.sql + +**Changes:** +- **DROP TABLE** `property_category_mapping` entirely +- Update comments to clarify property_definitions is a flat list + +**Updated Comments:** +```sql +COMMENT ON TABLE property_definitions IS 'Flat list of all available extended properties (computed and raw)'; +``` + +### 2. schema/01_core_tables.sql + +**Changes:** +- Update COMMENT on categories table +- **Remove columns** from observations table: + - `confidence DOUBLE PRECISION` → Move to extended_properties + - `detection_class VARCHAR` → Move to extended_properties +- Update comments to reflect observations table only contains universal data + +**Updated Comments:** +```sql +COMMENT ON TABLE categories IS 'Categories for data source types (sessions only): boids_3d, boids_2d, tracking_csv'; + +COMMENT ON TABLE observations IS 'Core time-series data: positions and velocities (universal data only). Session-specific data in extended_properties.'; +``` + +**Removed Columns:** +```sql +-- REMOVE these lines: +confidence DOUBLE PRECISION, -- Detection confidence [0-1] +detection_class VARCHAR, -- Detected object class +``` + +### 3. schema/03_seed_data.sql + +**Changes:** +- **Remove** 'computed' category from categories INSERT (only keep boids_3d, boids_2d, tracking_csv) +- **Remove** all property_category_mapping INSERTs (table no longer exists) +- **Add** new property_definitions for tracking metadata: + - `confidence`: 'Detection confidence score' (float, tracking-specific) + - `detection_class`: 'Detected object class label' (string, tracking-specific) +- Keep other property_definitions INSERTs (unchanged) + +**Categories INSERT (updated):** +```sql +INSERT INTO categories (category_id, category_name, description) VALUES + ('boids_3d', '3D Boids Simulations', 'Sessions from 3D boid simulations'), + ('boids_2d', '2D Boids Simulations', 'Sessions from 2D boid simulations'), + ('tracking_csv', 'Real-World Tracking', 'Sessions from video tracking (CSV data)') +ON CONFLICT (category_id) DO NOTHING; +-- REMOVED: ('computed', 'Computed Properties', ...) +``` + +**New Property Definitions (add):** +```sql +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) VALUES + ('confidence', 'Detection Confidence', 'float', 'Detection confidence score from tracking', 'probability'), + ('detection_class', 'Detection Class', 'string', 'Detected object class label', 'label') +ON CONFLICT (property_id) DO NOTHING; +``` + +**Remove Entire Section:** +```sql +-- DELETE THIS ENTIRE SECTION: +-- ============================================================================= +-- PROPERTY CATEGORY MAPPING - Assign properties to categories +-- ============================================================================= + +-- (all INSERT INTO property_category_mapping statements) +``` + +### 4. collab_env/data/db/init_database.py + +**Changes:** +- No changes needed (generic schema loader) + +### 5. collab_env/data/db/db_loader.py + +**Changes:** +- **Update tracking CSV loader** to store confidence and detection_class in extended_properties instead of observations +- Verify session loading uses correct category_id (boids_3d, boids_2d, tracking_csv) +- Ensure no references to 'computed' category anywhere +- Remove confidence/detection_class from observations DataFrame construction + +**Updated load_observations_batch() method:** +```python +# BEFORE: +df = pd.DataFrame({ + # ... other columns ... + 'confidence': observations['confidence'].astype(float) if 'confidence' in observations else None, + 'detection_class': observations.get('detection_class', None) +}) + +# AFTER: +df = pd.DataFrame({ + # ... other columns ... + # REMOVED: confidence and detection_class +}) +``` + +**Add to load_extended_properties_batch() for tracking CSV:** +```python +# Extract confidence and detection_class if present +if 'confidence' in observations: + property_data['confidence'] = observations['confidence'] +if 'detection_class' in observations: + property_data['detection_class'] = observations['detection_class'] +``` + +--- + +## Property Discovery Pattern + +**Query Available Properties for a Session:** +```python +def get_session_properties(session_id): + """Get all properties that exist for a session (query actual data).""" + return db.query(""" + SELECT DISTINCT pd.property_id, pd.property_name, pd.description + FROM property_definitions pd + WHERE pd.property_id IN ( + SELECT DISTINCT ep.property_id + FROM extended_properties ep + JOIN observations o ON ep.observation_id = o.observation_id + JOIN episodes e ON o.episode_id = e.episode_id + WHERE e.session_id = :session_id + ) + ORDER BY pd.property_id + """, session_id=session_id) +``` + +**Query Episodes Using a Property:** +```python +def get_episodes_with_property(property_id): + """Get all episodes that have data for a property.""" + return db.query(""" + SELECT DISTINCT e.episode_id, e.episode_number, s.session_name + FROM episodes e + JOIN sessions s ON e.session_id = s.session_id + WHERE e.episode_id IN ( + SELECT DISTINCT o.episode_id + FROM extended_properties ep + JOIN observations o ON ep.observation_id = o.observation_id + WHERE ep.property_id = :property_id + ) + ORDER BY s.session_name, e.episode_number + """, property_id=property_id) +``` + +--- + +## Migration Strategy + +### Option A: Fresh Database Initialization (Recommended for Dev) +- Update schema files +- Drop and recreate database +- Re-import data with new schema + +**Commands:** +```bash +# 1. Update schema files (as described above) +# 2. Drop and recreate database +python -m collab_env.data.db.init_database --backend duckdb --dbpath ./data/tracking.duckdb + +# 3. Re-import data +python -m collab_env.data.db.db_loader \ + --source boids3d \ + --path simulated_data/hackathon/... +``` + +### Option B: Migration Script (For Production Data) + +**Create migration SQL script:** +```sql +-- migration_simplify_categories.sql + +BEGIN; + +-- 1. Add confidence and detection_class to property_definitions +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) VALUES + ('confidence', 'Detection Confidence', 'float', 'Detection confidence score', 'probability'), + ('detection_class', 'Detection Class', 'string', 'Detected object class label', 'label') +ON CONFLICT (property_id) DO NOTHING; + +-- 2. Migrate confidence/detection_class from observations to extended_properties +INSERT INTO extended_properties (observation_id, property_id, value_float, value_text) +SELECT + observation_id, + 'confidence' as property_id, + confidence as value_float, + NULL as value_text +FROM observations +WHERE confidence IS NOT NULL; + +INSERT INTO extended_properties (observation_id, property_id, value_float, value_text) +SELECT + observation_id, + 'detection_class' as property_id, + NULL as value_float, + detection_class as value_text +FROM observations +WHERE detection_class IS NOT NULL; + +-- 3. Remove confidence/detection_class columns from observations +ALTER TABLE observations DROP COLUMN confidence; +ALTER TABLE observations DROP COLUMN detection_class; + +-- 4. Drop property_category_mapping table +DROP TABLE IF EXISTS property_category_mapping CASCADE; + +-- 5. Remove computed category +DELETE FROM categories WHERE category_id = 'computed'; + +COMMIT; +``` + +**Test Migration:** +```bash +# 1. Backup database +cp tracking.duckdb tracking.duckdb.backup + +# 2. Run migration +duckdb tracking.duckdb < migration_simplify_categories.sql + +# 3. Verify +duckdb tracking.duckdb -c "SELECT * FROM categories;" +duckdb tracking.duckdb -c "SHOW TABLES;" | grep -i property_category_mapping # Should be empty +``` + +**Decision:** Start with Option A for development, create Option B script if needed later + +--- + +## Implementation Plan + +### Phase 1: Schema Updates +**Estimated Effort:** 1-2 hours + +**Tasks:** +1. Update schema/01_core_tables.sql: + - Remove confidence and detection_class columns from observations table + - Update comments (categories = session types, observations = universal data only) +2. Update schema/02_extended_properties.sql: + - DROP TABLE property_category_mapping + - Update comments +3. Update schema/03_seed_data.sql: + - Remove 'computed' category (keep only boids_3d, boids_2d, tracking_csv) + - Remove ALL property_category_mapping INSERTs + - Add property_definitions for confidence and detection_class + +### Phase 2: Code Updates +**Estimated Effort:** 30 minutes + +**Tasks:** +1. Update collab_env/data/db/db_loader.py: + - Modify tracking CSV loader to store confidence/detection_class in extended_properties + - Remove confidence/detection_class from observations DataFrame construction +2. Grep codebase for any references to: + - 'computed' category + - property_category_mapping table + - observations.confidence or observations.detection_class + - Update any found references + +**Search Commands:** +```bash +grep -r "computed" collab_env/data/db/ collab_env/dashboard/ +grep -r "property_category_mapping" collab_env/ tests/ +grep -r "observations.confidence\|observations.detection_class" collab_env/ tests/ +``` + +### Phase 3: Testing +**Estimated Effort:** 30 minutes + +**Tests:** +- Manual: Initialize fresh database +- Verify exactly 3 categories exist (boids_3d, boids_2d, tracking_csv) +- Verify property_category_mapping table does NOT exist +- Verify observations table only has: position (x,y,z), velocity (v_x,v_y,v_z), no tracking metadata +- Verify property_definitions includes confidence and detection_class +- Test tracking CSV loader: confidence/detection_class stored in extended_properties +- Verify existing boid simulation data loaders still work + +**Test Commands:** +```bash +# Initialize database +python -m collab_env.data.db.init_database --backend duckdb --dbpath /tmp/test_schema.duckdb + +# Verify schema +duckdb /tmp/test_schema.duckdb -c "SELECT * FROM categories;" +duckdb /tmp/test_schema.duckdb -c "SHOW TABLES;" | grep property_category_mapping # Should be empty +duckdb /tmp/test_schema.duckdb -c "PRAGMA table_info(observations);" # Should NOT have confidence/detection_class +duckdb /tmp/test_schema.duckdb -c "SELECT * FROM property_definitions WHERE property_id IN ('confidence', 'detection_class');" + +# Test data loading +python -m collab_env.data.db.db_loader \ + --source boids3d \ + --path simulated_data/hackathon/... \ + --backend duckdb \ + --dbpath /tmp/test_schema.duckdb +``` + +### Phase 4: Documentation +**Estimated Effort:** 30 minutes + +**Files to Update:** +- docs/data/db/README.md - Update schema description, remove property_category_mapping references +- schema/README.md - Update table descriptions +- docs/dashboard/simple_analysis_gui.md - Update any references to categories/properties + +--- + +## Success Criteria ✅ ALL COMPLETE + +- [x] 'computed' category removed from database +- [x] property_category_mapping table dropped entirely +- [x] Only 3 categories remain: boids_3d, boids_2d, tracking_csv (for sessions only) +- [x] observations table cleaned: confidence and detection_class moved to extended_properties +- [x] property_definitions updated: includes confidence and detection_class as properties +- [x] property_definitions remains as flat list of all properties (20 total) +- [x] Tracking CSV loader updated to store confidence/detection_class in extended_properties +- [x] Sessions still correctly reference category_id +- [x] Existing data loading works with simplified schema +- [x] Documentation updated with property discovery pattern +- [x] All tests passing (33 tests total) +- [x] No references to 'computed' category or property_category_mapping in codebase + +--- + +## Implementation Summary (2025-11-08) + +### Files Modified + +**Schema Files:** +- `schema/01_core_tables.sql` - Removed confidence/detection_class columns, updated comments +- `schema/02_extended_properties.sql` - Dropped property_category_mapping table +- `schema/03_seed_data.sql` - Removed 'computed' category, added confidence/detection_class properties + +**Python Code:** +- `collab_env/data/db/db_loader.py` - Updated to use category_id, removed confidence/detection_class from observations +- `collab_env/data/db/init_database.py` - Updated table counts (7 tables, 3 categories) + +**Tests:** +- `tests/db/test_init_database.py` - Updated assertions for new schema +- `tests/db/test_db_loader.py` - Updated SessionMetadata usage +- `tests/db/conftest.py` - Updated DROP TABLE statements + +**Documentation:** +- `schema/README.md` - Updated schema description +- `docs/data/db/implementation_progress.md` - Added schema refactoring completion +- This file - Updated to reflect completion + +### Test Results + +All 33 tests passing: +- `test_init_database.py`: 21 passed, 1 skipped +- `test_db_loader.py`: 12 passed + +### Performance Impact + +No performance regression - extended properties loading optimized with smart collision detection: +- 90% of episodes use fast 2-tuple mapping (no agent_type_id collisions) +- 10% of episodes with mixed types use 3-tuple mapping +- Smart detection avoids overhead in common case + +--- + +## Risks & Mitigations + +### Risk: Breaking Existing Data +**Mitigation:** +- Test schema changes on copy of database first +- Create rollback migration script +- Document migration steps clearly +- Test with existing boid simulation data + +### Risk: Code References to Removed Tables +**Mitigation:** +- Comprehensive grep search before changes +- Update all references found +- Test data loaders thoroughly + +### Risk: Query Backend Assumptions +**Mitigation:** +- Review QueryBackend methods for category assumptions +- Update query documentation +- Test all analysis widgets still work + +--- + +## Open Questions + +1. **Migration Timing:** When to apply these changes? After current dashboard work? Before new property computation? + - **Recommendation:** After current dashboard refactoring is complete, before adding new widgets + +2. **Backward Compatibility:** Do we need to support old database format? + - **Recommendation:** No, this is development phase. Fresh initialization is acceptable. + +3. **Property Computation:** Should computed properties (speed, acceleration) be stored in extended_properties? + - **Answer:** Yes, all non-universal data goes to extended_properties + +--- + +## Related Work + +This schema refactoring is a prerequisite for: +- Property computation (speed, acceleration) - see docs/dashboard/todo.md Phase 2 +- Distribution widgets - see docs/dashboard/todo.md Phase 3 +- Pairwise analysis - see docs/dashboard/todo.md Phase 4 + +--- + +**End of Schema Refactoring Document** diff --git a/docs/data/db/cascading_deletes.md b/docs/data/db/cascading_deletes.md new file mode 100644 index 00000000..cc3d8ca7 --- /dev/null +++ b/docs/data/db/cascading_deletes.md @@ -0,0 +1,168 @@ +# Cascading Deletes + +## Overview + +The database schema supports cascading deletes with the following hierarchy: + +``` +category + └─> session (CASCADE) + └─> episode (CASCADE) + ├─> observation (CASCADE) + └─> extended_property → observation (CASCADE) +``` + +When you delete a parent record, all child records are automatically deleted. + +## Cascade Chain + +### 1. Delete Category +Deletes: +- All sessions in that category +- All episodes in those sessions +- All observations in those episodes +- All extended properties for those observations + +### 2. Delete Session +Deletes: +- All episodes in that session +- All observations in those episodes +- All extended properties for those observations + +### 3. Delete Episode +Deletes: +- All observations in that episode +- All extended properties for those observations + +## Usage Examples + +### Delete a Session (and all its data) + +```sql +-- This will automatically delete all episodes, observations, and extended properties +DELETE FROM sessions WHERE session_id = 'session-2d-boid_food_basic'; +``` + +### Delete a Category (and all its data) + +```sql +-- This will automatically delete all sessions, episodes, observations, and extended properties +DELETE FROM categories WHERE category_id = 'boids_2d'; +``` + +### Delete an Episode (and all its data) + +```sql +-- This will automatically delete all observations and extended properties +DELETE FROM episodes WHERE episode_id = 'episode-0001-session-2d-boid_food_basic'; +``` + +## Database Support + +### PostgreSQL ✅ +**Full support for cascading deletes.** + +The schema includes `ON DELETE CASCADE` constraints on all foreign keys: +- `sessions.category_id` → `categories(category_id)` ON DELETE CASCADE +- `episodes.session_id` → `sessions(session_id)` ON DELETE CASCADE +- `observations.episode_id` → `episodes(episode_id)` ON DELETE CASCADE +- `extended_properties.observation_id` → `observations(observation_id)` ON DELETE CASCADE + +### DuckDB ❌ +**No support for cascading deletes.** + +DuckDB does not support `ON DELETE CASCADE` as of version 1.4.1. The error message is: +``` +Parser Error: FOREIGN KEY constraints cannot use CASCADE, SET NULL or SET DEFAULT +``` + +For DuckDB, you must manually delete child records before deleting parent records: + +```sql +-- Manual cascade delete for DuckDB +-- Delete in reverse order of dependencies + +-- 1. Delete extended properties first +DELETE FROM extended_properties +WHERE observation_id IN ( + SELECT o.observation_id + FROM observations o + JOIN episodes e ON o.episode_id = e.episode_id + WHERE e.session_id = 'session-2d-boid_food_basic' +); + +-- 2. Delete observations +DELETE FROM observations +WHERE episode_id IN ( + SELECT episode_id + FROM episodes + WHERE session_id = 'session-2d-boid_food_basic' +); + +-- 3. Delete episodes +DELETE FROM episodes WHERE session_id = 'session-2d-boid_food_basic'; + +-- 4. Finally delete the session +DELETE FROM sessions WHERE session_id = 'session-2d-boid_food_basic'; +``` + +## Testing + +### Manual Test (PostgreSQL) + +Run the manual cascade delete test to verify everything works: + +```bash +python test_manual_cascade_delete.py +``` + +This creates a test category with session, episode, observations, and extended properties, then deletes the category and verifies all child data was cascade deleted. + +Expected output: +``` +✅ CASCADE DELETE SUCCESSFUL! + All related data was automatically deleted: + - Category deleted + - Session cascade deleted + - Episode cascade deleted + - Observations cascade deleted + - Extended properties cascade deleted +``` + +## Best Practices + +1. **Be Careful**: Cascade deletes are permanent and affect all child records +2. **Use Transactions**: Wrap deletes in transactions so you can rollback if needed +3. **Backup First**: Always backup before bulk deletions +4. **Verify Counts**: Check row counts before and after to ensure expected behavior + +### Example with Transaction + +```sql +BEGIN; + +-- Check what will be deleted +SELECT COUNT(*) FROM sessions WHERE category_id = 'boids_2d'; +SELECT COUNT(*) FROM episodes e + JOIN sessions s ON e.session_id = s.session_id + WHERE s.category_id = 'boids_2d'; + +-- If counts look correct, proceed +DELETE FROM categories WHERE category_id = 'boids_2d'; + +-- Verify deletion +SELECT COUNT(*) FROM sessions WHERE category_id = 'boids_2d'; + +-- If everything looks good, commit +COMMIT; + +-- Or rollback if something went wrong +-- ROLLBACK; +``` + +## Future Work + +- Add API endpoints for safe deletion with confirmation +- Add soft deletes (mark as deleted instead of physical delete) +- Add deletion audit log +- Add restore from backup functionality diff --git a/docs/data/db/data_formats.md b/docs/data/db/data_formats.md new file mode 100644 index 00000000..1cbc29ed --- /dev/null +++ b/docs/data/db/data_formats.md @@ -0,0 +1,763 @@ +# Data Formats Documentation + +This document describes the three primary data formats used in the collab-environment project for storing and processing timeseries tracking data. + +## Table of Contents + +1. [3D Boids Simulations](#1-3d-boids-simulations) +2. [2D Boids Simulations](#2-2d-boids-simulations) +3. [Real-World Tracked Data](#3-real-world-tracked-data) +4. [Summary Comparison](#4-summary-comparison) + +--- + +## 1. 3D Boids Simulations + +### Overview +3D boid simulations generated by `collab_env.sim.boids` and stored in the `simulated_data/hackathon/` directory. Each simulation run contains multiple episodes stored as parquet files, with a YAML configuration file describing the simulation parameters. + +### Location +- **Data Directory**: `simulated_data/hackathon/` +- **Naming Pattern**: `hackathon-{variant}-{size}-{agents}-{behavior}_sim_run-started-{timestamp}/` +- **Visualization**: `collab_env.dashboard.persistent_video_server --mode simulation` + +### Data Structure + +#### Session/Run Organization +``` +hackathon-boid-small-200-align-cohesion_sim_run-started-20250926-214330/ +├── config.yaml # Simulation configuration +├── episode-0-completed-20250926-214410.parquet +├── episode-1-completed-20250926-214449.parquet +├── ... +└── episode-9-completed-20250926-215048.parquet +``` + +#### Parquet File Schema + +**File Format**: Apache Parquet (columnar storage) + +**Columns** (14 total): + +| Column Name | Data Type | Description | Example | +|------------|-----------|-------------|---------| +| `id` | int64 | Unique agent identifier within episode | 1, 2, 3, ... | +| `type` | object (string) | Agent type category | "agent", "target" | +| `time` | int64 | Frame number / timestep | 0, 1, 2, ..., 2999 | +| `x` | float64 | X position in 3D space | 750.5, 848.8, ... | +| `y` | float64 | Y position in 3D space (height) | 20.0, 176.6, ... | +| `z` | float64 | Z position in 3D space | 750.0, 639.1, ... | +| `v_x` | float64 | X velocity component | 0.123, -0.456, ... | +| `v_y` | float64 | Y velocity component | 0.012, 0.034, ... | +| `v_z` | float64 | Z velocity component | -0.234, 0.567, ... | +| `distance_target_center_1` | float64 | Distance to target 1 center | 125.34, 234.56, ... | +| `distance_to_target_mesh_closest_point_1` | float64 | Distance to nearest point on target mesh 1 | 45.67, 89.12, ... | +| `target_mesh_closest_point_1` | object (list) | Closest point coordinates on target mesh | "[848.8, 176.6, 639.1]" | +| `mesh_scene_distance` | float64 | Distance to scene mesh (environment boundary) | 89.83, 58.21, ... | +| `mesh_scene_closest_point` | object (list) | Closest point on scene mesh | "[848.8, 176.6, 639.1]" | + +**Data Characteristics**: +- Typical episode: 3000 frames × 30-400 agents = 90,000-1,200,000 rows +- Frame rate: 30 fps (configurable) +- Coordinate system: Right-handed 3D, units typically in scene units (configurable scale) +- Time is discrete (integer frame numbers), not datetime + +#### Configuration File Schema (config.yaml) + +**File Format**: YAML + +**Top-level Sections**: + +1. **simulator**: Core simulation parameters + ```yaml + simulator: + seed: [1250, 439, ...] # Random seeds per episode + walking: false # Ground-based vs flying + num_agents: 30 # Number of agents + num_targets: 1 # Number of target objects + num_episodes: 10 # Episodes to generate + num_frames: 3000 # Frames per episode + target_creation_time: [500] # When targets appear + run_sub_folder_prefix: "hackathon-boid-small-200-align-cohesion_sim_run" + ``` + +2. **agent**: Agent behavior parameters + ```yaml + agent: + min_separation: 20.0 # Minimum distance between agents + neighborhood_dist: 80.0 # Vision range + separation_weight: 0.0 # Avoidance strength + alignment_weight: 1.0 # Flocking alignment + cohesion_weight: 0.0 # Attraction to neighbors + target_weight: [0.002, -1.0, 0.0, 0.0] # Attraction to targets + max_speed: 1.0 # Speed limits + min_speed: 0.1 + max_force: 0.1 # Steering force limit + agent_variants: # Multiple agent types + - type: boid + num_agents_of_type: 30 + alignment_weight: 1.0 + cohesion_weight: 0.5 + ``` + +3. **environment**: Scene configuration + ```yaml + environment: + box_size: 1500 # Bounding box size + scene_scale: 300.0 # Coordinate scale + scene_position: [750, 20, 750] # Scene origin + init_range_low: 0.4 # Initial position range (normalized) + init_range_high: 0.6 + height_init_max: 450 # Initial height range + ``` + +4. **meshes**: 3D mesh references + ```yaml + meshes: + mesh_scene: 'meshes/Open3dTSDFfusion_mesh.ply' + scene_angle: [-90.0, 0.0, 0.0] # Rotation (degrees) + sub_mesh_target: ['meshes/labeled_meshes/query-tree_top-cluster.ply'] + ``` + +5. **visuals**: Rendering configuration + ```yaml + visuals: + store_video: false + width: 1920 + height: 1280 + agent_scale: 2.0 + target_scale: 10.0 + ``` + +6. **tracks**: Trajectory visualization + ```yaml + tracks: + color_by_time: true + number_of_color_groups: 1000 + ``` + +**Path Resolution**: Mesh paths are relative to project root and resolved via `collab_env.data.file_utils.expand_path()` + +### Usage in Codebase + +**Loading Data**: +```python +# Via pandas +import pandas as pd +df = pd.read_parquet('simulated_data/hackathon/.../episode-0-....parquet') + +# Via dashboard loader +from collab_env.dashboard.utils.simulation_loader import SimulationDataLoader +loader = SimulationDataLoader() +sim_info = loader.register_simulation('sim_1', folder_path, config_path) +episode_data = loader.load_episode('sim_1', episode_id=0) +``` + +**Dashboard Integration**: [collab_env/dashboard/utils/simulation_loader.py:245-271](collab_env/dashboard/utils/simulation_loader.py#L245-L271) +- Converts parquet to track format with `{track_id, x, y, z, type, v_x, v_y, v_z}` per frame +- Resolves mesh paths and loads config parameters +- Provides episode browsing and playback UI + +### Data Grouping + +**Hierarchy**: +- **Session**: Simulation run folder (multiple episodes with same config) +- **Episode**: Single parquet file (one complete simulation trajectory) +- **Tracklet**: Time series for one agent_id across all frames +- **Properties**: Position, velocity, distances at each timestep + +**Unique Identifiers**: +- Session: Folder name with timestamp +- Episode: `episode-{N}-completed-{timestamp}` filename +- Agent: `id` column (unique within episode) +- Timestep: `time` column (frame number) + +--- + +## 2. 2D Boids Simulations + +### Overview +2D boid simulations generated by `collab_env.sim.boids_gnn_temp.animal_simulation` for training Graph Neural Networks. Data stored as PyTorch datasets in `.pt` format with separate config files. + +### Location +- **Data Directory**: `simulated_data/` +- **Naming Pattern**: `boid_{variant}_{config}.pt` and `boid_{variant}_{config}_config.pt` +- **Usage**: GNN training in `collab_env.gnn.interaction_particles` + +### Data Structure + +#### File Organization +``` +simulated_data/ +├── boid_single_species_basic.pt # Trajectory data +├── boid_single_species_basic_config.pt # Configuration +├── boid_food_basic.pt +├── boid_food_basic_config.pt +└── ... +``` + +#### PyTorch Dataset Structure (.pt files) + +**File Format**: PyTorch serialized object (pickle-based) + +**Class**: `collab_env.sim.boids_gnn_temp.animal_simulation.AnimalTrajectoryDataset` + +**Dataset Structure**: +```python +dataset = torch.load('boid_single_species_basic.pt') +# Returns: AnimalTrajectoryDataset instance + +len(dataset) # Number of trajectory samples (typically 50-1000) + +# Each sample is a tuple: +(positions, species) = dataset[0] + +# positions: torch.Tensor, shape [timesteps, num_agents, 2] +# species: torch.Tensor, shape [num_agents], dtype int (species labels) +``` + +**Example Data**: +```python +# Sample from boid_single_species_basic.pt: +positions.shape # torch.Size([10, 20, 2]) +# - 10 timesteps +# - 20 agents +# - 2D coordinates (x, y) + +species.shape # torch.Size([20]) +# Species labels for each agent (e.g., all 0 for single species) + +# Position values are normalized to [0, 1] range +positions[0, 0, :] # tensor([0.6626, 0.3490]) # Agent 0 at t=0 +``` + +**Data Characteristics**: +- Positions normalized to [0, 1] coordinate space +- Velocities computed via finite differences: `v[t] = p[t+1] - p[t]` +- Accelerations: `a[t] = v[t+1] - v[t]` +- Natural timestep: dt = 1.0 +- Typical sizes: 10-100 timesteps, 10-50 agents, 50-1000 samples + +#### Configuration File Schema (_config.pt files) + +**File Format**: PyTorch serialized dictionary + +**Structure**: +```python +config = torch.load('boid_single_species_basic_config.pt') +# Returns: Dict[str, Dict[str, Any]] + +# Example structure: +{ + 'A': { # Species identifier + 'visual_range': 50, # Vision radius (pixels) + 'centering_factor': 0.005, # Cohesion strength + 'min_distance': 15, # Avoidance distance + 'avoid_factor': 0.05, # Avoidance strength + 'matching_factor': 0.5, # Alignment strength + 'margin': 5, # Boundary margin + 'turn_factor': 10, # Boundary avoidance + 'speed_limit': 20, # Max speed (pixels/frame) + 'counts': 20 # Number of agents + }, + 'scene_size': 480.0 # Optional scene size in pixels +} +``` + +**Parameters by Species**: +- Each species key (e.g., 'A', 'B') contains identical parameter structure +- Multi-species configs have multiple species keys with different values +- `counts` field specifies agent population per species + +### Usage in Codebase + +**Loading Data**: +```python +import torch + +# Load dataset +dataset = torch.load('simulated_data/boid_single_species_basic.pt', + weights_only=False) + +# Load config +config = torch.load('simulated_data/boid_single_species_basic_config.pt', + weights_only=False) + +# Iterate samples +for positions, species in dataset: + # positions: [T, N, 2] + # species: [N] + # ... process trajectory ... +``` + +**GNN Training**: [collab_env/gnn/interaction_particles/run_training.py](collab_env/gnn/interaction_particles/run_training.py) +- Used as input to InteractionParticleGNN models +- Computes pairwise features (relative positions, velocities, distances) +- Predicts accelerations for learning force fields + +**Analysis**: [collab_env/sim/boids_gnn_temp/analyze_dataset.py](collab_env/sim/boids_gnn_temp/analyze_dataset.py) +- Computes statistics over all samples +- Generates EDA visualizations (distributions, force fields) +- Validates data quality + +### Data Grouping + +**Hierarchy**: +- **Dataset**: Complete .pt file (collection of trajectories) +- **Sample**: Single trajectory (one simulation run) +- **Timestep**: Frame within trajectory +- **Agent**: Individual particle with species label + +**Unique Identifiers**: +- Dataset: Filename (e.g., `boid_single_species_basic.pt`) +- Sample: Index in dataset (0 to len(dataset)-1) +- Agent: Index in positions tensor (0 to N-1) +- Timestep: Index in time dimension (0 to T-1) + +**Note**: No explicit track IDs; agents identified by index position only + +--- + +## 2B. GNN Rollout Predictions + +### Overview +GNN model rollout predictions on 2D boids test data, generated during model evaluation. Rollouts compare ground truth trajectories (from 2D boids datasets) with GNN-predicted trajectories to assess model performance. Data stored as pickle files containing both actual and predicted trajectories along with accelerations and attention weights. + +### Location +- **Data Directory**: `trained_models/runpod/{dataset_name}/rollouts/` +- **Naming Pattern**: `{dataset}_{model}_{params}_rollout_{start_frame}.pkl` +- **Example**: `boid_food_strong_vpluspplus_a_n0_h1_vr0.5_s0_rollout_5.pkl` +- **Usage**: Model evaluation, rollout visualization, performance analysis + +### Data Structure + +#### File Organization +``` +trained_models/runpod/boid_food_strong/rollouts/ +├── boid_food_strong_vpluspplus_a_n0_h1_vr0.5_s0_rollout_5.pkl # Main rollout data +├── boid_food_strong_vpluspplus_a_n0_h1_vr0.5_s0_rollout_5_model_spec.pkl # Model specification +└── boid_food_strong_vpluspplus_a_n0_h1_vr0.5_s0_rollout_5_train_spec.pkl # Training specification +``` + +#### Filename Components + +**Pattern**: `{dataset}_{model}_n{noise}_h{heads}_vr{visual_range}_s{seed}_rollout_{start_frame}.pkl` + +**Extracted Metadata**: +- `dataset`: Source dataset name (e.g., `boid_food_strong`) +- `model`: Model architecture (e.g., `vpluspplus_a`) +- `noise`: Noise level during training (e.g., `0`, `0.005`) +- `heads`: Number of attention heads (e.g., `1`, `2`, `3`) +- `visual_range`: Vision radius parameter (e.g., `0.5`) +- `seed`: Random seed for reproducibility (e.g., `0`, `1`, `2`) +- `start_frame`: Frame at which rollout begins (e.g., `5`) + +#### Pickle File Structure (.pkl files) + +**File Format**: Python pickle (CPU-mapped PyTorch tensors) + +**Top-Level Structure**: +```python +rollout_result = { + epoch_id: { # Usually 0 (single evaluation epoch) + batch_id: { # 0, 1, 2, ..., num_batches-1 + 'actual': [...], # Ground truth trajectories + 'predicted': [...], # GNN predicted trajectories + 'actual_acc': [...], # Ground truth accelerations + 'predicted_acc': [...], # GNN predicted accelerations + 'loss': [...], # Per-frame loss values + 'W': [...] # Attention weights (multi-head) + } + } +} +``` + +**Batch Structure**: +```python +batch = rollout_result[0][0] # First epoch, first batch + +# Actual and predicted trajectories +actual = batch['actual'] # List of frames +predicted = batch['predicted'] # List of frames + +# Each is a list of numpy arrays: [frame_0, frame_1, ..., frame_N] +# where each frame has shape: [batch_size, num_agents, 2] + +len(actual) # e.g., 1196 frames +actual[0].shape # e.g., (50, 21, 2) = [batch_size, agents, features] + +# Accelerations (same structure as positions) +actual_acc = batch['actual_acc'] # [frames] × [batch, agents, 2] +predicted_acc = batch['predicted_acc'] # [frames] × [batch, agents, 2] +actual_acc[0].shape # e.g., (50, 21, 2) + +# Loss (per-frame MSE) +loss = batch['loss'] # List of scalar loss values per frame + +# Attention weights (complex edge-level structure - not stored initially) +W = batch['W'] # List of tuples: [(head_weights, edge_indices), ...] +# W[frame_idx] is tuple of 2 tensors +# W[frame_idx][0].shape # e.g., (2, 9690) = [num_heads, num_edges] +# W[frame_idx][1].shape # e.g., (9690, 1) = [num_edges, 1] +``` + +**Data Characteristics**: +- **Batched**: Each rollout contains multiple trajectories (batch_size typically 50) +- **Frames**: Long rollouts (typically 1000-1200 frames) +- **Agents**: Fixed number per trajectory (e.g., 20 boids + 1 food = 21 total) +- **Coordinates**: Normalized [0, 1] space (same as input 2D boids data) +- **Agent Types**: + - **Boid agents**: Moving particles (indices 0 to N-2) + - **Food agent**: Stationary target (index N-1, zero velocity) +- **Accelerations**: Pre-computed from velocity differences +- **Attention Weights**: Multi-head edge-level attention (graph structure) + +#### Agent Type Detection + +**Food Agent Identification**: +```python +# Food agent detected by zero velocity across all frames +# Always the last agent (index 20 for 21-agent system) + +for agent_idx in range(num_agents): + velocities = [actual[t+1][batch, agent_idx] - actual[t][batch, agent_idx] + for t in range(10)] + vel_norms = [np.linalg.norm(v) for v in velocities] + is_food = np.mean(vel_norms) < 1e-6 + agent_type = 'food' if is_food else 'agent' +``` + +**Species Labels**: +- In datasets with food (e.g., `boid_food_*`), one agent has species='food' +- Food agents don't move: `dx = 0, dy = 0` (see `collab_env/sim/boids_gnn_temp/boid.py:43-44`) +- Regular boid agents follow standard boid rules (cohesion, separation, alignment) + +### Usage in Codebase + +**Loading Rollout Data**: +```python +from collab_env.gnn.plotting_utility import load_rollout + +rollout_result = load_rollout( + model_name='vpluspplus_a', + data_name='boid_food_basic', + noise=0, + head=1, + visual_range=0.5, + seed=2, + rollout_starting_frame=5 +) + +# Access specific batch +epoch_data = rollout_result[0] # Epoch 0 +batch_data = epoch_data[0] # Batch 0 + +# Extract trajectories +actual = np.array(batch_data['actual']) # [frames, batch, agents, 2] +predicted = np.array(batch_data['predicted']) # [frames, batch, agents, 2] +``` + +**Extracting Single Trajectory**: +```python +from collab_env.gnn.gnn import debug_result2prediction + +# Extract trajectory for specific file_id from batch +actual_pos, actual_vel, actual_acc, \ +gnn_pos, gnn_vel, gnn_acc, frame_sets = debug_result2prediction( + rollout_result, + file_id=260, # Trajectory index (batch_id * batch_size + traj_idx) + epoch_num=0 +) + +# Returns: actual_pos.shape = [num_agents, num_frames, 2] +# gnn_pos.shape = [num_agents, num_frames, 2] +``` + +**Visualization**: `figures/gnn/A-rollout.ipynb` +- Overlay actual vs predicted trajectories +- Compute prediction errors over time +- Identify best/worst performing trajectories + +### Data Grouping + +**Hierarchy**: +- **Rollout File**: Complete pickle file (one model evaluation) +- **Epoch**: Evaluation epoch (usually single epoch: 0) +- **Batch**: Group of trajectories evaluated together +- **Trajectory**: Single simulation run (actual + predicted pair) +- **Frame**: Timestep within trajectory +- **Agent**: Individual particle (boid or food) + +**Unique Identifiers**: +- Rollout File: Filename with model parameters +- Epoch: Integer (typically 0) +- Batch: Integer (0 to num_batches-1) +- Trajectory: `batch_id * batch_size + trajectory_idx` (global file_id) +- Agent: Index (0 to N-1, where N-1 is food if present) +- Frame: Index (0 to T-1) + +**Unbatching for Database**: +When loading into database, each trajectory becomes TWO episodes: +- `episode-{epoch}-{batch}-{traj:04d}-actual`: Ground truth +- `episode-{epoch}-{batch}-{traj:04d}-predicted`: GNN predictions + +Example: Batch 0 with 50 trajectories creates 100 database episodes. + +### Database Storage Strategy + +**Session**: One rollout file = one session +- `session_id`: `rollout-{dataset}-{model_spec}` +- `category_id`: `boids_2d_rollout` +- Metadata: Model parameters, dataset name, rollout settings + +**Episodes**: Each trajectory creates TWO episodes (actual + predicted) +- Observations table: Stores positions and velocities +- Agent types: `'agent'` for boids, `'food'` for stationary food +- Extended properties: + - `actual_acc_x`, `actual_acc_y`: Ground truth accelerations (actual episodes) + - `predicted_acc_x`, `predicted_acc_y`: GNN predicted accelerations (predicted episodes) + - Attention weights: Future enhancement (complex structure) + +**Storage Notes**: +- Accelerations stored as extended properties (not universal data) +- Loss values: Not stored initially (can compute from position errors) +- Attention weights: Skipped in initial implementation (complex edge-level graph structure) +- Coordinate scaling: Multiply by `scene_size` (default 480) to get pixel coordinates + +--- + +## 3. Real-World Tracked Data + +### Overview +Animal tracking data from thermal/RGB video processing pipeline. Generated by `collab_env.tracking` module using YOLO/RF-DETR detection + ByteTracker tracking. Data stored as CSV files with bounding boxes or centroids. + +### Location +- **Data Sources**: Google Cloud Storage buckets (`fieldwork_curated`, `fieldwork_processed`) +- **Local Processing**: Various directories as specified in session metadata +- **Formats**: `*_bboxes.csv`, `*_centroids_3d.csv` +- **Visualization**: `collab_env.dashboard` video overlay viewer + +### Data Structure + +#### Session Organization +``` +YYYY_MM_DD-session_0001/ # Session folder +├── Metadata.yaml # Session info +├── thermal_1/ +│ ├── cameraInfoTime.csq # Raw thermal data +│ ├── cameraInfoTime_vmin-vmax.mp4 # Processed video +│ └── cameraInfoTime_vmin-vmax_bboxes.csv # Tracking output +├── thermal_2/ +│ └── ... +├── rgb_cam_1/ +│ ├── cameraSerial.mp4 # RGB video +│ └── cameraSerial_bboxes.csv # Tracking output +└── rgb_cam_2/ + └── ... +``` + +#### CSV File Schema - Bounding Boxes + +**File Format**: CSV (comma-separated values) + +**Naming Pattern**: `*_bboxes.csv` + +**Columns**: + +| Column Name | Data Type | Required | Description | Example | +|------------|-----------|----------|-------------|---------| +| `track_id` | int | Yes | Unique track identifier | 0, 1, 2, ... | +| `frame` | int | Yes | Frame number (0-indexed) | 0, 1, 2, ... | +| `x1` | int/float | Yes | Top-left X coordinate (pixels) | 245 | +| `y1` | int/float | Yes | Top-left Y coordinate (pixels) | 180 | +| `x2` | int/float | Yes | Bottom-right X coordinate (pixels) | 278 | +| `y2` | int/float | Yes | Bottom-right Y coordinate (pixels) | 215 | +| `confidence` | float | Optional | Detection confidence score [0-1] | 0.87 | +| `class` | string | Optional | Object class label | "bird" | + +**Alternative: Centroid Format**: + +| Column Name | Data Type | Required | Description | +|------------|-----------|----------|-------------| +| `track_id` | int | Yes | Unique track identifier | +| `frame` | int | Yes | Frame number | +| `x` | int/float | Yes | Centroid X coordinate (pixels) | +| `y` | int/float | Yes | Centroid Y coordinate (pixels) | +| `confidence` | float | Optional | Detection confidence | +| `class` | string | Optional | Object class | + +**Data Characteristics**: +- Coordinates in pixel space (video resolution dependent, typically 640×480 or 1920×1080) +- Frame rate: 30 fps (typical) +- Track IDs assigned by ByteTracker (may have gaps/reassignments) +- Confidence scores from YOLO/RF-DETR detector + +#### CSV File Schema - 3D Centroids + +**File Format**: CSV + +**Naming Pattern**: `*_centroids_3d.csv` + +**Columns** (inferred from usage): + +| Column Name | Data Type | Description | +|------------|-----------|-------------| +| `track_id` | int | Track identifier | +| `frame` | int | Frame number | +| `x` | float | X coordinate in 3D space | +| `y` | float | Y coordinate in 3D space | +| `z` | float | Z coordinate in 3D space | +| Additional tracking-specific columns | | | + +**Note**: Exact schema may vary based on tracking pipeline; typically includes reprojected 3D coordinates from multi-camera calibration. + +#### Metadata File Schema (Metadata.yaml) + +**File Format**: YAML + +**Structure**: +```yaml +notes: "Freeform observation notes from fieldwork" + +data_sources: + - description: "thermal_1 (FLIR camera left)" + original_path: "/local/drive/path/to/source.csq" + path: "thermal_1/cameraInfoTime.csq" + + - description: "rgb_1 (RGB camera left)" + original_path: "/local/drive/path/to/source.MP4" + path: "rgb_cam_1/cameraSerial.mp4" + + - description: "thermal_2 (FLIR camera right)" + original_path: "/local/drive/path/to/source.csq" + path: "thermal_2/cameraInfoTime.csq" + + # ... additional sources +``` + +**Fields**: +- `notes`: Optional freeform text for session observations +- `data_sources`: List of source files with: + - `description`: Camera/sensor description + - `original_path`: Source location (provenance) + - `path`: Relative path within session folder + +### Usage in Codebase + +**Tracking Pipeline**: [docs/tracking/README.md](docs/tracking/README.md) + +1. **Detection**: [collab_env/tracking/model/local_model_tracking.py](collab_env/tracking/model/local_model_tracking.py) + ```python + from collab_env.tracking.model.local_model_tracking import ( + get_detections_from_video, + track_objects, + output_tracked_bboxes_csv + ) + + # Run detection + get_detections_from_video(csv_path, video_path, output_video_path) + + # Track objects + track_history = track_objects(detect_csv) + + # Combine detection + tracking + output_tracked_bboxes_csv(track_csv, detect_csv, output_csv) + ``` + +2. **Visualization**: Dashboard video overlay viewer + - Auto-detects `*_bboxes.csv` files alongside videos + - Interactive playback with track ID labels and trails + - Handles both bbox and centroid formats + +**Loading Data**: +```python +import pandas as pd + +# Load tracking results +df = pd.read_csv('path/to/video_bboxes.csv') + +# Access by frame +frame_data = df[df['frame'] == 42] + +# Access by track +track_data = df[df['track_id'] == 5] +``` + +### Data Grouping + +**Hierarchy**: +- **Session**: Fieldwork session folder (date + session number) +- **Video**: Individual camera recording +- **Track**: Continuous trajectory of one object (track_id) +- **Detection**: Single bounding box/centroid at one frame + +**Unique Identifiers**: +- Session: Folder name `YYYY_MM_DD-session_NNNN` +- Video: Camera path (e.g., `thermal_1/cameraInfoTime.mp4`) +- Track: `track_id` (unique within video) +- Detection: `(track_id, frame)` tuple + +**Temporal Information**: +- Frame-based indexing (not datetime) +- Frame rate stored in video metadata (typically 30 fps) +- Conversion to datetime requires session start time from metadata + +**Coordinate Systems**: +- 2D bboxes/centroids: Pixel coordinates in video frame +- 3D centroids: World coordinates from camera calibration/triangulation + +--- + +## 4. Summary Comparison + +| Aspect | 3D Boids | 2D Boids | Real-World Tracking | +|--------|----------|----------|---------------------| +| **Format** | Parquet + YAML | PyTorch .pt | CSV + YAML | +| **Dimensions** | 3D (x, y, z) | 2D (x, y) | 2D pixels or 3D world | +| **Temporal** | Frame numbers | Frame numbers | Frame numbers | +| **Agent ID** | `id` column | Tensor index | `track_id` column | +| **Velocity** | Stored (v_x, v_y, v_z) | Computed from positions | Not stored | +| **Config** | YAML (rich) | PyTorch dict (minimal) | YAML (metadata) | +| **Sessions** | Folder = session | File = dataset | Folder = session | +| **Episodes** | Multiple per session | Multiple per dataset | One per video | +| **Typical Size** | 90K-1.2M rows/episode | 10K-50K positions/sample | Varies by video length | +| **Coordinates** | Scene units (scaled) | Normalized [0, 1] | Pixels or calibrated | +| **Use Case** | 3D simulation viz | GNN training | Real animal tracking | +| **Mesh Data** | Referenced in config | None | None (environment separate) | +| **Species/Type** | String in `type` column | Integer species labels | String in `class` column | + +### Common Patterns + +**All formats share**: +1. Time-series structure (frame-based indexing) +2. Multiple agents/tracks per episode/video +3. Position data as primary observable +4. Configuration/metadata in separate files +5. Grouping into sessions/datasets +6. Visualization support in dashboard + +**Key Differences**: +1. **Storage**: Columnar (parquet) vs serialized (PyTorch) vs tabular (CSV) +2. **Coordinate systems**: 3D scene vs normalized 2D vs pixel space +3. **Velocity**: Explicit vs derived vs absent +4. **IDs**: Stable integer vs index vs tracker-assigned +5. **Metadata richness**: Very rich (3D boids) vs minimal (2D boids) vs moderate (tracking) + +### Database Design Implications + +**Unified schema should accommodate**: +- Multiple coordinate systems and dimensionalities +- Both stored and computed velocities +- Flexible ID schemes (integer, tracker-assigned, indexed) +- Rich configuration storage (YAML-compatible) +- Session/episode/tracklet hierarchy +- Optional mesh/environment references +- Species/type/class categorization +- Frame-based time with optional datetime mapping + +**Storage considerations**: +- Columnar format for efficient queries (DuckDB/TimescaleDB) +- JSON/JSONB for flexible config storage +- Spatial indexing for position queries +- Time-series optimizations for temporal queries +- Efficient joins across sessions/episodes/tracklets diff --git a/docs/data/db/data_loader_plan.md b/docs/data/db/data_loader_plan.md new file mode 100644 index 00000000..1810226d --- /dev/null +++ b/docs/data/db/data_loader_plan.md @@ -0,0 +1,579 @@ +# Data Loader Improvements - Implementation Plan + +**Created:** 2025-11-07 +**Updated:** 2025-11-08 +**Status:** Partially Implemented - Phase 1 Complete, Major Optimizations Planned +**Prerequisites:** ✅ Schema refactoring complete (2025-11-08) + +## Implementation Status + +**Completed:** +- ✅ **Phase 1: Schema Refactoring** (2025-11-08) + - Removed confidence/detection_class from observations table + - Moved tracking metadata to extended_properties + - All tests passing (33 tests) +- ✅ **Smart Collision Detection Optimization** (2025-11-08) + - Implemented 2-tuple vs 3-tuple mapping for extended properties + - 90% of episodes use fast 2-tuple path + - 10% with mixed agent types use 3-tuple path + +**Not Yet Implemented (Planned):** +- ❌ **Phase 2: PostgreSQL COPY for Extended Properties** - 10-100x faster bulk loading +- ❌ **Phase 2: SQL JOIN-Based Approach** - Temp tables + database-side joins +- ❌ **Phase 3: aiosql Integration** - Move db_loader.py SQL to separate files +- ❌ **Phase 4: PostgreSQL COPY for Observations** - 10-100x faster bulk loading +- ❌ **Phase 5: Comprehensive Performance Benchmarks** + +--- + +## Overview + +This document outlines planned improvements to the data loading system in `collab_env/data/db/db_loader.py` to make it more efficient, maintainable, and scalable. + +--- + +## Current Issues + +### 1. Inefficient Extended Properties Loading + +**Current Implementation** ([db_loader.py](../../collab_env/data/db/db_loader.py) lines 178-228): + +```python +def load_extended_properties_batch(episode_id, property_data): + # 1. Fetch ALL observation IDs into Python memory + obs_rows = db.fetch_all("SELECT observation_id, time_index, agent_id FROM observations WHERE episode_id = ?") + + # 2. Build Python dictionary mapping (inefficient for large datasets) + obs_id_map = {(row[1], row[2]): row[0] for row in obs_rows} + + # 3. Iterate in Python to construct records + records = [] + for property_id, values in property_data.items(): + for (time_idx, agent_id), value in values.items(): + obs_id = obs_id_map.get((time_idx, agent_id)) + records.append({'observation_id': obs_id, ...}) + + # 4. Finally insert via pandas + df = pd.DataFrame(records) + db.insert_dataframe(df, 'extended_properties') +``` + +**Problems:** +- **Memory**: Loads all observation IDs into Python (can be millions for large datasets) +- **CPU**: Python dictionary construction and iteration +- **Network**: Two round-trips (fetch IDs, then insert) +- **Scalability**: O(n) memory where n = number of observations + +**Performance Impact:** +- Episode with 90K observations, 9 extended properties = 810K property values +- Python dict for 90K observations ≈ 7 MB +- Record list for 810K values ≈ 65 MB +- Total: ~72 MB Python memory + iteration overhead + +### 2. Inline SQL Instead of aiosql + +**Current State:** +- `query_backend.py` uses aiosql for all queries (good pattern) +- `db_loader.py` uses inline SQL strings (inconsistent) + +**Problems:** +- SQL mixed with Python code (harder to read/test/modify) +- No syntax highlighting for SQL +- Git diffs show SQL changes inline with Python +- Can't reuse queries across modules + +### 3. Schema Mismatch ✅ RESOLVED (2025-11-08) + +**Previous Issue:** +- Observations table had `confidence` and `detection_class` columns +- These are tracking-specific metadata, not universal data + +**Resolution:** +- Schema refactoring completed (2025-11-08) +- Removed `confidence` and `detection_class` from observations table +- Moved them to extended_properties as property definitions +- All tests passing (33 tests) + +--- + +## Implemented Optimizations + +### ✅ Smart Collision Detection for Extended Properties (2025-11-08) + +**Implementation:** + +The current `load_extended_properties_batch()` method uses an intelligent 2-tuple vs 3-tuple mapping strategy: + +```python +# Try simple 2-tuple mapping first (fastest path for 90% of episodes) +query = """ +SELECT observation_id, time_index, agent_id +FROM observations +WHERE episode_id = :episode_id +""" +obs_rows = self.db.fetch_all(query, {'episode_id': episode_id}) + +# Build simple 2-tuple mapping - works for most cases +obs_id_map = {} +has_collision = False +for row in obs_rows: + key = (row[1], row[2]) # (time_index, agent_id) + if key in obs_id_map: + # Collision detected - need to use 3-tuple mapping + has_collision = True + break + obs_id_map[key] = row[0] + +# If collision detected, rebuild with 3-tuple mapping +if has_collision: + logger.info(f"Multiple agent types detected, using 3-tuple mapping") + query_3tuple = """ + SELECT observation_id, time_index, agent_id, agent_type_id + FROM observations + WHERE episode_id = :episode_id + """ + obs_rows = self.db.fetch_all(query_3tuple, {'episode_id': episode_id}) + obs_id_map = {(row[1], row[2], row[3]): row[0] for row in obs_rows} +``` + +**Benefits:** +- **Fast path optimization**: 90% of episodes use simple 2-tuple mapping (no agent_type_id needed) +- **Automatic detection**: Detects collisions and switches to 3-tuple mapping when needed +- **Backward compatible**: Works with both single-type and mixed-type episodes +- **Memory efficient**: Only stores necessary key components + +**Performance:** +- Single agent type episodes: Uses 2-tuple keys (minimal overhead) +- Mixed agent type episodes: Automatically uses 3-tuple keys (correct behavior) + +**Current Implementation Location:** [collab_env/data/db/db_loader.py:185-272](../../collab_env/data/db/db_loader.py) + +--- + +## Proposed Solutions (Not Yet Implemented) + +### Solution 1: SQL JOIN-Based Extended Properties with PostgreSQL COPY + +**Instead of:** Fetch → Map in Python → Insert + +**Use:** Temp table + SQL JOIN + Direct INSERT (with COPY for PostgreSQL) + +**Implementation:** + +```python +def load_extended_properties_batch(episode_id, property_data, agent_type_map=None): + """Load extended properties using SQL JOIN (efficient for large datasets). + + Uses PostgreSQL COPY for 10-100x speedup when available, falls back to + INSERT for DuckDB. + """ + # 1. Prepare flat records for temp table + temp_records = [] + for property_id, values in property_data.items(): + for (time_idx, agent_id), value in values.items(): + if pd.notna(value): + agent_type = agent_type_map.get((time_idx, agent_id), 'agent') if agent_type_map else 'agent' + temp_records.append({ + 'episode_id': episode_id, + 'time_index': time_idx, + 'agent_id': agent_id, + 'agent_type_id': agent_type, + 'property_id': property_id, + 'value_float': float(value) if isinstance(value, (int, float)) else None, + 'value_text': str(value) if not isinstance(value, (int, float)) else None + }) + + # 2. Create temp table and load data efficiently + with db.engine.connect() as conn: + # Create temp table + create_temp = """ + CREATE TEMP TABLE temp_extended_props ( + episode_id VARCHAR, + time_index INTEGER, + agent_id INTEGER, + agent_type_id VARCHAR, + property_id VARCHAR, + value_float DOUBLE PRECISION, + value_text TEXT + ) + """ + conn.execute(text(create_temp)) + + temp_df = pd.DataFrame(temp_records) + + # PostgreSQL: Use COPY for 10-100x faster loading + if self.db.config.backend == 'postgres': + from io import StringIO + + # Convert DataFrame to CSV in memory + buffer = StringIO() + temp_df.to_csv(buffer, index=False, header=False, sep='\t', na_rep='\\N') + buffer.seek(0) + + # Get raw psycopg2 connection for COPY + raw_conn = conn.connection.dbapi_connection + cursor = raw_conn.cursor() + try: + cursor.copy_from( + buffer, + 'temp_extended_props', + columns=temp_df.columns.tolist(), + sep='\t', + null='\\N' + ) + raw_conn.commit() + finally: + cursor.close() + else: + # DuckDB: Use pandas to_sql (still fast, just not as fast as COPY) + temp_df.to_sql('temp_extended_props', conn, if_exists='append', index=False, method='multi') + + # 3. Use SQL JOIN to get observation_ids and insert directly + insert_query = """ + INSERT INTO extended_properties (observation_id, property_id, value_float, value_text) + SELECT o.observation_id, t.property_id, t.value_float, t.value_text + FROM temp_extended_props t + JOIN observations o + ON o.episode_id = t.episode_id + AND o.time_index = t.time_index + AND o.agent_id = t.agent_id + AND o.agent_type_id = t.agent_type_id + WHERE t.value_float IS NOT NULL OR t.value_text IS NOT NULL + """ + result = conn.execute(text(insert_query)) + conn.commit() + + return result.rowcount +``` + +**Benefits:** +- **PostgreSQL COPY**: 10-100x faster than INSERT for bulk loads (primary optimization) +- **No Python mapping**: Database handles JOIN efficiently +- **Single round-trip**: One compound operation +- **Backend-optimized**: Uses best method for each database +- **Scalable**: Database optimized for JOINs +- **Less memory**: No need to store all obs_ids in Python + +**Estimated Performance:** +- PostgreSQL (with COPY): **10-50x faster** for large datasets +- DuckDB (with INSERT): **3-5x faster** for large datasets +- 50% less Python memory usage +- More efficient database operations + +### Solution 2: Use aiosql for All Data Loading Queries + +**Create:** `collab_env/data/db/queries/data_loading.sql` + +```sql +-- name: get_observation_count +-- Get observation count for verification +SELECT COUNT(*) as count +FROM observations +WHERE episode_id = :episode_id; + +-- name: get_extended_property_count +-- Get extended property count for verification +SELECT COUNT(*) as count +FROM extended_properties ep +JOIN observations o ON ep.observation_id = o.observation_id +WHERE o.episode_id = :episode_id; +``` + +**Benefits:** +- Consistent with query_backend.py +- SQL in separate files (easier to read, test, modify) +- Git diffs show SQL changes clearly +- Can reuse queries + +### Solution 3: Update for Schema Refactoring + +**Changes Required:** + +1. **Remove confidence/detection_class from observations loading**: + +```python +# BEFORE (current): +df = pd.DataFrame({ + 'episode_id': episode_id, + 'x': observations['x'], + 'y': observations['y'], + # ... + 'confidence': observations['confidence'] if 'confidence' in observations else None, + 'detection_class': observations.get('detection_class', None) +}) + +# AFTER (schema refactored): +df = pd.DataFrame({ + 'episode_id': episode_id, + 'x': observations['x'], + 'y': observations['y'], + # ... (no confidence/detection_class) +}) +``` + +2. **Add confidence/detection_class to extended_properties loading**: + +```python +# In load_episode_file or tracking CSV loader: +extended_props = {} + +# Extract from observations dataframe +if 'confidence' in observations: + extended_props['confidence'] = observations.set_index(['time', 'id'])['confidence'] +if 'detection_class' in observations: + extended_props['detection_class'] = observations.set_index(['time', 'id'])['detection_class'] + +# Load as extended properties +self.load_extended_properties_batch(episode_id, extended_props, agent_type_map) +``` + +--- + +## Alternative: Consider dlt (data load tool) + +**What is dlt?** +- Modern data loading library (https://dlthub.com/) +- Automatic schema evolution +- Built-in validation and testing +- Incremental loading support + +**Evaluation Questions:** +1. Does dlt support EAV (Entity-Attribute-Value) patterns? +2. How does it handle composite primary keys? +3. Performance comparison with current approach? +4. Learning curve and maintenance burden? + +**Recommendation:** Evaluate dlt in a separate spike/POC before committing + +--- + +## Implementation Order + +### Phase 1: Schema Refactoring ✅ COMPLETE (2025-11-08) +**Status:** ✅ COMPLETE (see [archive/schema_refactoring.md](archive/schema_refactoring.md)) +**Actual Effort:** 2 hours + +**Completed:** +1. ✅ Removed `confidence` and `detection_class` from observations table schema +2. ✅ Updated seed data to add these as property_definitions +3. ✅ All tests passing (33 tests) +4. ✅ Smart collision detection optimization implemented + +### Phase 2: SQL JOIN-Based Extended Properties with COPY +**Status:** Planned (this document) +**Estimated Effort:** 3-4 hours + +1. Implement new `load_extended_properties_batch()` method with SQL JOIN +2. Add PostgreSQL COPY support for bulk loading (primary optimization) +3. Add fallback to INSERT for DuckDB +4. Add `agent_type_map` parameter +5. Update Boids3DLoader to pass agent_type_map +6. Update tracking CSV loader (when implemented) +7. Write comprehensive tests including performance benchmarks + +**Files to Modify:** +- `collab_env/data/db/db_loader.py` (lines 178-228) + +**Tests to Add:** +- Test with mixed agent types (agent + env) +- Test with null values (should be filtered) +- Test PostgreSQL COPY vs DuckDB INSERT (verify both work) +- Benchmark large datasets (90K+ observations) +- Verify performance improvements (PostgreSQL: 10-50x, DuckDB: 3-5x) + +### Phase 3: aiosql Integration +**Status:** Planned (this document) +**Estimated Effort:** 1 hour + +1. Add aiosql import to db_loader.py +2. Create `queries/data_loading.sql` file +3. Update DatabaseConnection to load queries +4. Replace inline SQL with aiosql calls where appropriate + +**Files to Create:** +- `collab_env/data/db/queries/data_loading.sql` + +**Files to Modify:** +- `collab_env/data/db/db_loader.py` (import, connect method) + +### Phase 4: Optimize Observations Loading with COPY +**Status:** Planned (this document) +**Estimated Effort:** 2 hours + +1. Remove confidence/detection_class from observations DataFrame +2. Add them to extended_properties in tracking CSV loader +3. **Implement COPY for observations bulk loading (PostgreSQL)** +4. **Add fallback to pandas.to_sql for DuckDB** +5. Update tests to verify correct storage and performance + +**Files to Modify:** +- `collab_env/data/db/db_loader.py` (load_observations_batch) +- Tracking CSV loader (when implemented) + +**Implementation:** +```python +def load_observations_batch(self, observations: pd.DataFrame, episode_id: str): + """Load observations using PostgreSQL COPY when available.""" + + # Prepare DataFrame (ONLY universal data) + df = pd.DataFrame({...}) # Position, velocity only + + if self.db.config.backend == 'postgres': + # Use COPY for 10-100x faster loading + from io import StringIO + buffer = StringIO() + df.to_csv(buffer, index=False, header=False, sep='\t', na_rep='\\N') + buffer.seek(0) + + raw_conn = self.db.engine.raw_connection() + cursor = raw_conn.cursor() + try: + cursor.copy_from(buffer, 'observations', columns=df.columns.tolist(), sep='\t', null='\\N') + raw_conn.commit() + finally: + cursor.close() + raw_conn.close() + else: + # DuckDB: Use pandas.to_sql (still fast) + self.db.insert_dataframe(df, 'observations', if_exists='append') +``` + +### Phase 5: Testing & Documentation +**Status:** Planned +**Estimated Effort:** 1-2 hours + +1. Fix existing tests to match new SessionMetadata/schema +2. Add integration tests for full load pipeline +3. Add performance benchmarks +4. Update documentation + +**Files to Modify:** +- `tests/db/test_db_loader.py` +- `tests/db/conftest.py` +- `docs/data/db/README.md` + +--- + +## Success Criteria + +**Completed (2025-11-08):** +- [x] Schema refactoring complete (observations table clean) +- [x] Confidence/detection_class stored in extended_properties +- [x] All existing tests passing (33 tests) +- [x] Smart collision detection optimization implemented +- [x] Documentation updated + +**Not Yet Implemented (Planned):** +- [ ] **PostgreSQL COPY implemented for observations loading (10-100x faster)** +- [ ] **PostgreSQL COPY implemented for extended properties loading (10-100x faster)** +- [ ] DuckDB fallback to INSERT working correctly +- [ ] Extended properties loading uses SQL JOIN (no Python mapping) +- [ ] aiosql integration complete (consistent with query_backend) +- [ ] New tests for SQL JOIN approach +- [ ] Backend-specific tests (PostgreSQL COPY vs DuckDB INSERT) +- [ ] Performance benchmarks documented: + - PostgreSQL observations: **10-50x faster** than current + - PostgreSQL extended properties: **10-50x faster** than current + - DuckDB observations: **Similar** to current (already uses bulk insert) + - DuckDB extended properties: **3-5x faster** than current +- [ ] Memory improvement: 50% reduction in Python memory usage (beyond current optimization) + +--- + +## Future Enhancements + +### 1. Parallel Episode Loading +Use multiprocessing to load multiple episodes in parallel: + +```python +from multiprocessing import Pool + +with Pool(processes=4) as pool: + pool.starmap(self.load_episode_file, episode_args) +``` + +**Note:** DuckDB has single-writer limitation; this would only work for PostgreSQL + +### 2. Binary COPY Format +For even faster PostgreSQL loading, use binary COPY format: + +```python +# Binary format can be 2-3x faster than text COPY +cursor.copy_expert( + f"COPY observations FROM STDIN WITH (FORMAT BINARY)", + binary_buffer +) +``` + +**Consideration:** Requires more complex buffer preparation, evaluate if text COPY is insufficient + +### 3. DuckDB Appender API +For DuckDB, use the Appender API for faster bulk inserts: + +```python +import duckdb + +appender = conn.appender('observations') +for row in df.itertuples(index=False): + appender.append_row(row) +appender.close() +``` + +**Note:** Requires direct duckdb connection, not through SQLAlchemy + +### 4. dlt Evaluation +- Prototype with dlt for one data source +- Compare performance, ease of use, features +- Decide whether to migrate + +--- + +## Risks & Mitigations + +### Risk: Breaking Changes +**Mitigation:** +- Implement changes in order (schema first, then code) +- Test each phase independently +- Create rollback plan + +### Risk: Performance Regression +**Mitigation:** +- Benchmark before/after +- Test with large datasets +- Monitor production performance + +### Risk: Test Fragility +**Mitigation:** +- Fix test fixtures to match schema +- Add comprehensive integration tests +- Use parametrized tests for both backends + +--- + +## Timeline + +**Total Original Estimate:** 9-13 hours +**Completed So Far:** 2 hours +**Remaining Estimate:** 7-11 hours + +**Completed:** +1. ✅ Schema Refactoring: 2 hours (2025-11-08) + +**Remaining Planned Work:** +2. SQL JOIN + PostgreSQL COPY for Extended Properties: 3-4 hours +3. aiosql Integration: 1 hour +4. PostgreSQL COPY for Observations + Tracking Metadata: 2 hours +5. Testing & Docs: 2-3 hours (including performance benchmarks) + +**Recommendation:** Implement remaining phases in 3-4 focused sessions + +**Priority Order:** +1. ✅ **Phase 1** (Schema) - Foundation for everything else **COMPLETE** +2. **Phase 2** (Extended Properties + COPY) - Biggest performance win **PLANNED** +3. **Phase 4** (Observations + COPY) - Second biggest performance win **PLANNED** +4. **Phase 3** (aiosql) - Code quality improvement **PLANNED** +5. **Phase 5** (Testing) - Verification and documentation **PLANNED** + +--- + +**End of Data Loader Planning Document** diff --git a/docs/data/db/query_cloud_db.ipynb b/docs/data/db/query_cloud_db.ipynb new file mode 100644 index 00000000..98b04c20 --- /dev/null +++ b/docs/data/db/query_cloud_db.ipynb @@ -0,0 +1,73068 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Query Cloud SQL Database\n", + "\n", + "Connect to the remote tracking analytics database via Cloud SQL Proxy and explore the data.\n", + "\n", + "## Prerequisites\n", + "\n", + "### 1. Install gcloud CLI\n", + "```bash\n", + "# macOS\n", + "brew install google-cloud-sdk\n", + "\n", + "# Or download from: https://cloud.google.com/sdk/docs/install\n", + "```\n", + "\n", + "### 2. Install Cloud SQL Auth Proxy\n", + "```bash\n", + "# macOS (Apple Silicon)\n", + "curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.14.3/cloud-sql-proxy.darwin.arm64\n", + "chmod +x cloud-sql-proxy\n", + "sudo mv cloud-sql-proxy /usr/local/bin/\n", + "\n", + "# macOS (Intel)\n", + "curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.14.3/cloud-sql-proxy.darwin.amd64\n", + "chmod +x cloud-sql-proxy\n", + "sudo mv cloud-sql-proxy /usr/local/bin/\n", + "```\n", + "\n", + "### 3. Authenticate with Google Cloud\n", + "```bash\n", + "# Login\n", + "gcloud auth login\n", + "gcloud auth application-default login\n", + "\n", + "# Set project\n", + "gcloud config set project collab-data-463313\n", + "```\n", + "\n", + "### 4. Install the package (from current branch)\n", + "```bash\n", + "# Install from GitHub with the db-eda-dashboard branch\n", + "pip install \"collab-env[db] @ git+https://github.com/BasisResearch/collab-environment.git@db-eda-dashboard\"\n", + "```\n", + "\n", + "**Note**: The SQL query files are included in the package distribution via `package-data` configuration in `pyproject.toml`. If you encounter \"queries directory not found\" errors, ensure you're installing from a commit that includes the `[tool.setuptools.package-data]` section.\n", + "\n", + "### 5. Start the Cloud SQL Proxy (in a separate terminal)\n", + "```bash\n", + "# From the repo root:\n", + "source scripts/deploy/config.sh\n", + "./scripts/deploy/start_proxy.sh\n", + "\n", + "# Or manually:\n", + "cloud-sql-proxy collab-data-463313:us-central1:spatial-analysis-db --port 5433\n", + "```\n", + "\n", + "Keep the proxy running while using this notebook." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Setup Environment Variables" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Verify Installation\n", + "\n", + "Run this cell first to verify that SQL query files are accessible:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "✓ SQL queries directory found: /Users/dima/git/collab-environment.worktrees/db-eda-dashboard/collab_env/data/db/queries\n", + "✓ Found 4 SQL files:\n", + " - basic_data_viewer.sql\n", + " - correlations.sql\n", + " - session_metadata.sql\n", + " - spatial_analysis.sql\n" + ] + } + ], + "source": [ + "from pathlib import Path\n", + "import collab_env.data.db.query_backend\n", + "\n", + "# Check if queries directory exists\n", + "queries_dir = Path(collab_env.data.db.query_backend.__file__).parent / \"queries\"\n", + "if queries_dir.exists():\n", + " sql_files = list(queries_dir.glob(\"*.sql\"))\n", + " print(f\"✓ SQL queries directory found: {queries_dir}\")\n", + " print(f\"✓ Found {len(sql_files)} SQL files:\")\n", + " for f in sorted(sql_files):\n", + " print(f\" - {f.name}\")\n", + "else:\n", + " print(f\"✗ ERROR: Queries directory not found at {queries_dir}\")\n", + " print(\"\\nThis means the package was not installed with the SQL files included.\")\n", + " print(\n", + " \"Please ensure you're installing from a commit that includes the package-data configuration.\"\n", + " )\n", + " raise FileNotFoundError(f\"Queries directory not found: {queries_dir}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Environment configured for Cloud SQL via proxy on localhost:5433\n" + ] + } + ], + "source": [ + "import os\n", + "import subprocess\n", + "\n", + "# Get password from Secret Manager\n", + "result = subprocess.run(\n", + " [\"gcloud\", \"secrets\", \"versions\", \"access\", \"latest\", \"--secret=postgres-password\"],\n", + " capture_output=True,\n", + " text=True,\n", + ")\n", + "if result.returncode != 0:\n", + " raise RuntimeError(f\"Failed to get password: {result.stderr}\")\n", + "\n", + "# Set environment variables for database connection\n", + "os.environ[\"DB_BACKEND\"] = \"postgres\"\n", + "os.environ[\"POSTGRES_HOST\"] = \"localhost\"\n", + "os.environ[\"POSTGRES_PORT\"] = \"5433\"\n", + "os.environ[\"POSTGRES_DB\"] = \"tracking_analytics\"\n", + "os.environ[\"POSTGRES_USER\"] = \"postgres\"\n", + "os.environ[\"POSTGRES_PASSWORD\"] = result.stdout.strip()\n", + "\n", + "print(\"Environment configured for Cloud SQL via proxy on localhost:5433\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Connect to Database" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:27:28 | INFO | collab_env.data.db.db_loader:connect:223 - Connected to PostgreSQL: tracking_analytics\n", + "2026-02-23 15:27:28 | INFO | collab_env.data.db.query_backend:__init__:87 - Loaded queries from /Users/dima/git/collab-environment.worktrees/db-eda-dashboard/collab_env/data/db/queries using psycopg2 adapter\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Connected to Cloud SQL database\n" + ] + } + ], + "source": [ + "from collab_env.data.db.query_backend import QueryBackend\n", + "\n", + "# Initialize query backend (reads config from environment)\n", + "query = QueryBackend()\n", + "print(\"Connected to Cloud SQL database\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Explore Sessions and Episodes" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:27:28 | INFO | collab_env.data.db.query_backend:_execute_query:112 - Executing query 'get_categories' with params: {}\n", + "2026-02-23 15:27:28 | INFO | collab_env.data.db.query_backend:_execute_query:145 - Query 'get_categories' completed in 0.074s: 5 rows returned\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Available categories:\n" + ] + }, + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "category_id", + "rawType": "object", + "type": "string" + }, + { + "name": "category_name", + "rawType": "object", + "type": "string" + }, + { + "name": "description", + "rawType": "object", + "type": "string" + } + ], + "ref": "374d6fe3-16b4-40c1-af4d-6d6bc8f4361f", + "rows": [ + [ + "0", + "boids_2d_rollout", + "2D Boids GNN Rollout", + "GNN model predictions on 2D boids test data" + ], + [ + "1", + "boids_2d", + "2D Boids Simulations", + "Sessions from 2D boid simulations" + ], + [ + "2", + "boids_3d", + "3D Boids Simulations", + "Sessions from 3D boid simulations" + ], + [ + "3", + "particle-sim", + "Particle Simulations", + "McKean-Vlasov particle system simulations" + ], + [ + "4", + "tracking_csv", + "Real-World Tracking", + "Sessions from video tracking (CSV data)" + ] + ], + "shape": { + "columns": 3, + "rows": 5 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
category_idcategory_namedescription
0boids_2d_rollout2D Boids GNN RolloutGNN model predictions on 2D boids test data
1boids_2d2D Boids SimulationsSessions from 2D boid simulations
2boids_3d3D Boids SimulationsSessions from 3D boid simulations
3particle-simParticle SimulationsMcKean-Vlasov particle system simulations
4tracking_csvReal-World TrackingSessions from video tracking (CSV data)
\n", + "
" + ], + "text/plain": [ + " category_id category_name \\\n", + "0 boids_2d_rollout 2D Boids GNN Rollout \n", + "1 boids_2d 2D Boids Simulations \n", + "2 boids_3d 3D Boids Simulations \n", + "3 particle-sim Particle Simulations \n", + "4 tracking_csv Real-World Tracking \n", + "\n", + " description \n", + "0 GNN model predictions on 2D boids test data \n", + "1 Sessions from 2D boid simulations \n", + "2 Sessions from 3D boid simulations \n", + "3 McKean-Vlasov particle system simulations \n", + "4 Sessions from video tracking (CSV data) " + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Get all categories\n", + "categories = query.get_categories()\n", + "print(\"Available categories:\")\n", + "categories" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:29:34 | INFO | collab_env.data.db.query_backend:_execute_query:112 - Executing query 'get_sessions' with params: {'category_id': 'boids_2d'}\n", + "2026-02-23 15:29:34 | INFO | collab_env.data.db.query_backend:_execute_query:145 - Query 'get_sessions' completed in 0.072s: 1 rows returned\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Found 1 sessions:\n" + ] + }, + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "session_id", + "rawType": "object", + "type": "string" + }, + { + "name": "session_name", + "rawType": "object", + "type": "string" + }, + { + "name": "category_id", + "rawType": "object", + "type": "string" + } + ], + "ref": "9cce44b7-c92b-45a3-9e60-c8d596a21499", + "rows": [ + [ + "0", + "session-2d-boid_food_basic", + "boid_food_basic", + "boids_2d" + ] + ], + "shape": { + "columns": 3, + "rows": 1 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
session_idsession_namecategory_id
0session-2d-boid_food_basicboid_food_basicboids_2d
\n", + "
" + ], + "text/plain": [ + " session_id session_name category_id\n", + "0 session-2d-boid_food_basic boid_food_basic boids_2d" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Get sessions (optionally filter by category)\n", + "sessions = query.get_sessions(category_id=\"boids_2d\")\n", + "print(f\"Found {len(sessions)} sessions:\")\n", + "sessions[[\"session_id\", \"session_name\", \"category_id\"]]" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:29:39 | INFO | collab_env.data.db.query_backend:_execute_query:112 - Executing query 'get_episodes' with params: {'session_id': 'session-2d-boid_food_basic'}\n", + "2026-02-23 15:29:39 | INFO | collab_env.data.db.query_backend:_execute_query:145 - Query 'get_episodes' completed in 0.090s: 20 rows returned\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Selected session: session-2d-boid_food_basic\n", + "\n", + "Found 20 episodes:\n" + ] + }, + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "episode_id", + "rawType": "object", + "type": "string" + }, + { + "name": "episode_number", + "rawType": "int64", + "type": "integer" + }, + { + "name": "num_frames", + "rawType": "int64", + "type": "integer" + }, + { + "name": "num_agents", + "rawType": "int64", + "type": "integer" + }, + { + "name": "frame_rate", + "rawType": "float64", + "type": "float" + } + ], + "ref": "92e5af37-81c9-4024-9a3b-53ab1d94aab6", + "rows": [ + [ + "0", + "episode-0000-session-2d-boid_food_basic", + "0", + "1200", + "21", + "1.0" + ], + [ + "1", + "episode-0001-session-2d-boid_food_basic", + "1", + "1200", + "21", + "1.0" + ], + [ + "2", + "episode-0002-session-2d-boid_food_basic", + "2", + "1200", + "21", + "1.0" + ], + [ + "3", + "episode-0003-session-2d-boid_food_basic", + "3", + "1200", + "21", + "1.0" + ], + [ + "4", + "episode-0004-session-2d-boid_food_basic", + "4", + "1200", + "21", + "1.0" + ], + [ + "5", + "episode-0005-session-2d-boid_food_basic", + "5", + "1200", + "21", + "1.0" + ], + [ + "6", + "episode-0006-session-2d-boid_food_basic", + "6", + "1200", + "21", + "1.0" + ], + [ + "7", + "episode-0007-session-2d-boid_food_basic", + "7", + "1200", + "21", + "1.0" + ], + [ + "8", + "episode-0008-session-2d-boid_food_basic", + "8", + "1200", + "21", + "1.0" + ], + [ + "9", + "episode-0009-session-2d-boid_food_basic", + "9", + "1200", + "21", + "1.0" + ], + [ + "10", + "episode-0010-session-2d-boid_food_basic", + "10", + "1200", + "21", + "1.0" + ], + [ + "11", + "episode-0011-session-2d-boid_food_basic", + "11", + "1200", + "21", + "1.0" + ], + [ + "12", + "episode-0012-session-2d-boid_food_basic", + "12", + "1200", + "21", + "1.0" + ], + [ + "13", + "episode-0013-session-2d-boid_food_basic", + "13", + "1200", + "21", + "1.0" + ], + [ + "14", + "episode-0014-session-2d-boid_food_basic", + "14", + "1200", + "21", + "1.0" + ], + [ + "15", + "episode-0015-session-2d-boid_food_basic", + "15", + "1200", + "21", + "1.0" + ], + [ + "16", + "episode-0016-session-2d-boid_food_basic", + "16", + "1200", + "21", + "1.0" + ], + [ + "17", + "episode-0017-session-2d-boid_food_basic", + "17", + "1200", + "21", + "1.0" + ], + [ + "18", + "episode-0018-session-2d-boid_food_basic", + "18", + "1200", + "21", + "1.0" + ], + [ + "19", + "episode-0019-session-2d-boid_food_basic", + "19", + "1200", + "21", + "1.0" + ] + ], + "shape": { + "columns": 5, + "rows": 20 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
episode_idepisode_numbernum_framesnum_agentsframe_rate
0episode-0000-session-2d-boid_food_basic01200211.0
1episode-0001-session-2d-boid_food_basic11200211.0
2episode-0002-session-2d-boid_food_basic21200211.0
3episode-0003-session-2d-boid_food_basic31200211.0
4episode-0004-session-2d-boid_food_basic41200211.0
5episode-0005-session-2d-boid_food_basic51200211.0
6episode-0006-session-2d-boid_food_basic61200211.0
7episode-0007-session-2d-boid_food_basic71200211.0
8episode-0008-session-2d-boid_food_basic81200211.0
9episode-0009-session-2d-boid_food_basic91200211.0
10episode-0010-session-2d-boid_food_basic101200211.0
11episode-0011-session-2d-boid_food_basic111200211.0
12episode-0012-session-2d-boid_food_basic121200211.0
13episode-0013-session-2d-boid_food_basic131200211.0
14episode-0014-session-2d-boid_food_basic141200211.0
15episode-0015-session-2d-boid_food_basic151200211.0
16episode-0016-session-2d-boid_food_basic161200211.0
17episode-0017-session-2d-boid_food_basic171200211.0
18episode-0018-session-2d-boid_food_basic181200211.0
19episode-0019-session-2d-boid_food_basic191200211.0
\n", + "
" + ], + "text/plain": [ + " episode_id episode_number num_frames \\\n", + "0 episode-0000-session-2d-boid_food_basic 0 1200 \n", + "1 episode-0001-session-2d-boid_food_basic 1 1200 \n", + "2 episode-0002-session-2d-boid_food_basic 2 1200 \n", + "3 episode-0003-session-2d-boid_food_basic 3 1200 \n", + "4 episode-0004-session-2d-boid_food_basic 4 1200 \n", + "5 episode-0005-session-2d-boid_food_basic 5 1200 \n", + "6 episode-0006-session-2d-boid_food_basic 6 1200 \n", + "7 episode-0007-session-2d-boid_food_basic 7 1200 \n", + "8 episode-0008-session-2d-boid_food_basic 8 1200 \n", + "9 episode-0009-session-2d-boid_food_basic 9 1200 \n", + "10 episode-0010-session-2d-boid_food_basic 10 1200 \n", + "11 episode-0011-session-2d-boid_food_basic 11 1200 \n", + "12 episode-0012-session-2d-boid_food_basic 12 1200 \n", + "13 episode-0013-session-2d-boid_food_basic 13 1200 \n", + "14 episode-0014-session-2d-boid_food_basic 14 1200 \n", + "15 episode-0015-session-2d-boid_food_basic 15 1200 \n", + "16 episode-0016-session-2d-boid_food_basic 16 1200 \n", + "17 episode-0017-session-2d-boid_food_basic 17 1200 \n", + "18 episode-0018-session-2d-boid_food_basic 18 1200 \n", + "19 episode-0019-session-2d-boid_food_basic 19 1200 \n", + "\n", + " num_agents frame_rate \n", + "0 21 1.0 \n", + "1 21 1.0 \n", + "2 21 1.0 \n", + "3 21 1.0 \n", + "4 21 1.0 \n", + "5 21 1.0 \n", + "6 21 1.0 \n", + "7 21 1.0 \n", + "8 21 1.0 \n", + "9 21 1.0 \n", + "10 21 1.0 \n", + "11 21 1.0 \n", + "12 21 1.0 \n", + "13 21 1.0 \n", + "14 21 1.0 \n", + "15 21 1.0 \n", + "16 21 1.0 \n", + "17 21 1.0 \n", + "18 21 1.0 \n", + "19 21 1.0 " + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Select a session and get its episodes\n", + "session_id = sessions.iloc[0][\"session_id\"]\n", + "print(f\"Selected session: {session_id}\")\n", + "\n", + "episodes = query.get_episodes(session_id)\n", + "print(f\"\\nFound {len(episodes)} episodes:\")\n", + "episodes[[\"episode_id\", \"episode_number\", \"num_frames\", \"num_agents\", \"frame_rate\"]]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Query Tracks" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:29:42 | INFO | collab_env.data.db.query_backend:_execute_query:112 - Executing query 'get_episode_tracks' with params: {'episode_id': 'episode-0000-session-2d-boid_food_basic', 'start_time': 0, 'end_time': 100, 'agent_type': 'agent'}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Getting tracks for episode: episode-0000-session-2d-boid_food_basic\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:29:42 | INFO | collab_env.data.db.query_backend:_execute_query:145 - Query 'get_episode_tracks' completed in 0.406s: 2121 rows returned\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Loaded 2121 track points\n" + ] + }, + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "agent_id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "time_index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "x", + "rawType": "float64", + "type": "float" + }, + { + "name": "y", + "rawType": "float64", + "type": "float" + }, + { + "name": "z", + "rawType": "object", + "type": "unknown" + }, + { + "name": "v_x", + "rawType": "float64", + "type": "float" + }, + { + "name": "v_y", + "rawType": "float64", + "type": "float" + }, + { + "name": "v_z", + "rawType": "object", + "type": "unknown" + }, + { + "name": "speed", + "rawType": "float64", + "type": "float" + } + ], + "ref": "db94d625-7aac-4b6f-a959-dc1723ccbab7", + "rows": [ + [ + "0", + "0", + "0", + "222.88165283203125", + "455.8440856933594", + null, + "-4.772372245788574", + "1.9295597076416016", + null, + "5.147692445914676" + ], + [ + "1", + "1", + "0", + "252.075439453125", + "164.40884399414062", + null, + "-4.380598068237305", + "-5.459861755371094", + null, + "6.999980701631135" + ], + [ + "2", + "2", + "0", + "270.88385009765625", + "290.224609375", + null, + "-2.007265090942383", + "-3.296384811401367", + null, + "3.8594385563386755" + ], + [ + "3", + "3", + "0", + "18.592906951904297", + "209.72984313964844", + null, + "1.2158775329589844", + "1.4576196670532227", + null, + "1.898160496094778" + ], + [ + "4", + "4", + "0", + "439.8846740722656", + "70.36539459228516", + null, + "0.2531719207763672", + "-1.517622470855713", + null, + "1.538594808751087" + ], + [ + "5", + "5", + "0", + "381.0645446777344", + "430.051025390625", + null, + "0.10439872741699219", + "-1.2126445770263672", + null, + "1.2171302167302167" + ], + [ + "6", + "6", + "0", + "259.02520751953125", + "110.97212982177734", + null, + "-5.000553131103516", + "-4.898421764373779", + null, + "7.000004814189766" + ], + [ + "7", + "7", + "0", + "3.3791420459747314", + "202.8035125732422", + null, + "3.1006484031677246", + "2.4242162704467773", + null, + "3.935841084948101" + ], + [ + "8", + "8", + "0", + "425.3021240234375", + "242.026611328125", + null, + "-2.1710586547851562", + "-1.5851783752441406", + null, + "2.6881752479812744" + ], + [ + "9", + "9", + "0", + "444.316650390625", + "46.9159049987793", + null, + "-0.3606891632080078", + "-1.7109453678131104", + null, + "1.748551035599714" + ] + ], + "shape": { + "columns": 9, + "rows": 10 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
agent_idtime_indexxyzv_xv_yv_zspeed
000222.881653455.844086None-4.7723721.929560None5.147692
110252.075439164.408844None-4.380598-5.459862None6.999981
220270.883850290.224609None-2.007265-3.296385None3.859439
33018.592907209.729843None1.2158781.457620None1.898160
440439.88467470.365395None0.253172-1.517622None1.538595
550381.064545430.051025None0.104399-1.212645None1.217130
660259.025208110.972130None-5.000553-4.898422None7.000005
7703.379142202.803513None3.1006482.424216None3.935841
880425.302124242.026611None-2.171059-1.585178None2.688175
990444.31665046.915905None-0.360689-1.710945None1.748551
\n", + "
" + ], + "text/plain": [ + " agent_id time_index x y z v_x v_y \\\n", + "0 0 0 222.881653 455.844086 None -4.772372 1.929560 \n", + "1 1 0 252.075439 164.408844 None -4.380598 -5.459862 \n", + "2 2 0 270.883850 290.224609 None -2.007265 -3.296385 \n", + "3 3 0 18.592907 209.729843 None 1.215878 1.457620 \n", + "4 4 0 439.884674 70.365395 None 0.253172 -1.517622 \n", + "5 5 0 381.064545 430.051025 None 0.104399 -1.212645 \n", + "6 6 0 259.025208 110.972130 None -5.000553 -4.898422 \n", + "7 7 0 3.379142 202.803513 None 3.100648 2.424216 \n", + "8 8 0 425.302124 242.026611 None -2.171059 -1.585178 \n", + "9 9 0 444.316650 46.915905 None -0.360689 -1.710945 \n", + "\n", + " v_z speed \n", + "0 None 5.147692 \n", + "1 None 6.999981 \n", + "2 None 3.859439 \n", + "3 None 1.898160 \n", + "4 None 1.538595 \n", + "5 None 1.217130 \n", + "6 None 7.000005 \n", + "7 None 3.935841 \n", + "8 None 2.688175 \n", + "9 None 1.748551 " + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Get tracks for an episode (first 100 frames)\n", + "episode_id = episodes.iloc[0][\"episode_id\"]\n", + "print(f\"Getting tracks for episode: {episode_id}\")\n", + "\n", + "tracks = query.get_episode_tracks(episode_id=episode_id, start_time=0, end_time=100)\n", + "print(f\"\\nLoaded {len(tracks)} track points\")\n", + "tracks.head(10)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Time range: 0 - 100\n", + "Unique agents: 21\n", + "\n", + "Speed statistics:\n" + ] + }, + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "object", + "type": "string" + }, + { + "name": "speed", + "rawType": "float64", + "type": "float" + } + ], + "ref": "162bc0c8-652e-4dba-95dd-bf2f10a87bb3", + "rows": [ + [ + "count", + "2121.0" + ], + [ + "mean", + "2.473924842976928" + ], + [ + "std", + "2.4894603379974316" + ], + [ + "min", + "0.0" + ], + [ + "25%", + "0.5118493614721025" + ], + [ + "50%", + "1.1415604460645077" + ], + [ + "75%", + "4.218964909361041" + ], + [ + "max", + "7.0000419923140615" + ] + ], + "shape": { + "columns": 1, + "rows": 8 + } + }, + "text/plain": [ + "count 2121.000000\n", + "mean 2.473925\n", + "std 2.489460\n", + "min 0.000000\n", + "25% 0.511849\n", + "50% 1.141560\n", + "75% 4.218965\n", + "max 7.000042\n", + "Name: speed, dtype: float64" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Basic track statistics\n", + "print(f\"Time range: {tracks['time_index'].min()} - {tracks['time_index'].max()}\")\n", + "print(f\"Unique agents: {tracks['agent_id'].nunique()}\")\n", + "print(\"\\nSpeed statistics:\")\n", + "tracks[\"speed\"].describe()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Visualize Tracks" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAA3IAAAPdCAYAAADPnVraAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjgsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvwVt1zgAAAAlwSFlzAAAPYQAAD2EBqD+naQAA525JREFUeJzs3Qd8W9X5//GvLe8Z7yxnDzuLMEITVgKEPZICLS27QMsus6UUGnbpH9rS9kdZLbNQZplhJiSEFRogEDKdvROPxCPeS//Xcxy5tuMkzrAl2Z/366VIubqWjq6upPvcc87zhHi9Xq8AAAAAAEEj1N8NAAAAAADsGQI5AAAAAAgyBHIAAAAAEGQI5AAAAAAgyBDIAQAAAECQIZADAAAAgCBDIAcAAAAAQYZADgAAAACCDIEcAAAAAAQZAjkAAeXjjz9WSEiIuw5GEyZMcJ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KRx99tAuerPfMauf5fPbZZzryyCMVHR2tzMxM/fKXv1RZWVnj/f369dPvf/97XXzxxYqPj3fFuR9//PHG+/v37++uDzzwQPfYEyZMaLW9H374oRYtWqTnnntOo0eP1kknnaS7775bf//7311w154oCA4AAAB0YlW19brq+bl+ee6/n3uQosI9bV7/5ZdfVlZWloYOHarzzjtP1113nW655ZbGlP2rVq3SWWedpWuvvVaXXnqpvv32W910003NHmPFihU68cQTdc899+jJJ59Ufn6+rr76and56qmnGtf705/+5IKu3/72t3r11Vdd8Dh+/Hj33HPmzNGhhx6q6dOna/jw4Y2131obBjpy5EhlZGQ0LjvhhBPcYy1cuNAFgu2FHjkAAAAAATOs0gI4Y8FYcXGxZs2a1Xj/Y4895gKtBx54wF3/5Cc/0UUXXdTsMe677z6de+65Lgi0nrvDDjtMf/vb3/Tss8+qsrKycb2TTz5ZV155pQYNGqSbb75ZqampmjlzprsvLS3NXaekpKh79+5KTk5utb2bN29uFsQZ3//tvvZEjxwAAADQiUWGhbqeMX89d1vl5OS4nrDXX3/d/T8sLExnn322C+58QxttnTFjxjT7O+s5a2revHn6/vvv9fzzzzcusyGe9fX1rkcvOzvbLRs1alTj/dbjZwFbXl6eggWBHAAAANCJWZCyJ8Mb/cUCNsv22LNnz2YBWGRkpB566CElJia2eZ7dZZdd5ubFtWRz4XzCw8N32E4W7O0JC/4s+GwqNze38b72xNBKAAAAAH5lAZwNfbR5a5by33ex3jUL7F544QW3ng2n/Prrr5v97VdffdXs/wcddJBLQGJDJltedjbXrSXfepaVclfGjRun+fPnN+vJmzZtmhISEjRs2DC1JwI5AAAAAH41depUFRYW6pJLLtGIESOaXc4880zXW2esp23JkiVuTtvSpUtdchRfZktfQhS7z0oBWHITCwaXLVumN9980/2/rawenGW8fP/9910Pm83Va83xxx/vArbzzz/fBZ0ffPCBbrvtNl111VWuJ7E9EcgBAAAA8CsL1CZOnNjq8EkL5KwXzua9WVkAyzD52muvuTlujzzyiG699Va3ni9wsuWWIMUCPStBYJkjra5b0yGbu2Pz8yxBiiVXsb+bNGlSq+tZ4XILQu3aeucsUcsFF1ygu+66S+0txLunxR06oZKSErfTWKRt3aAAAABAsLLMjJbUw4Ieq7XW2d1777169NFHtW7dOgX7+7MncQnJTgAAAAAEjYcffthlrrTSAJ9//rkrRbAnwyY7CwI5AAAAAEHD5rzdc8892rp1q8tCeeONN7qi4V0NgRwAAACAoPHggw+6S1dHshMAAAAACDIEcgAAAAAQZAjkAAAAACDIEMgBAAAAQJAhkAMAAACAIEMgBwAAAABBhkAOAAAAAIIMgRwAAACAgDF79mx5PB6dcsopfmvD6tWrFRISou+++2636/7yl7/UwQcfrMjISI0ePVodhUAOAAAAQMB44okndM011+iTTz7Rxo0bFQwuvvhinX322R36nARyAAAAQGfm9Uo1lf652HPvgdLSUr300ku64oorXI/c008/vcM6b731lgYPHqyoqCgdffTReuaZZ1zvWVFRUeM6n332mY488khFR0crMzPT9ZqVlZU13t+vXz/9/ve/dwFYfHy8+vTpo8cff7zx/v79+7vrAw880D32hAkTdtrmv/3tb7rqqqs0YMAAdaSwDn02AAAAAB2rtkp65UL/bPUfPSOFR7V59ZdffllZWVkaOnSozjvvPF133XW65ZZbXDBlVq1apbPOOkvXXnutLr30Un377be66aabmj3GihUrdOKJJ+qee+7Rk08+qfz8fF199dXu8tRTTzWu96c//Ul33323fvvb3+rVV191weP48ePdc8+ZM0eHHnqopk+fruHDhysiIkKBhh45AEBQqq/3au7aQr02d72W5W6Tdw/P+gIAAnNYpQVwxoKx4uJizZo1q/H+xx57zAVaDzzwgLv+yU9+oosuuqjZY9x3330699xzXRBoPXeHHXaY6zV79tlnVVlZ2bjeySefrCuvvFKDBg3SzTffrNTUVM2cOdPdl5aW5q5TUlLUvXt3JScnK9DQIwcACCrl1bX6dFmBPlqcqy2l1W7ZO99vUs9u0Ro/JE2HDUpRTAQ/bwDQKCyyoWfMX8/dRjk5Oa4n7PXXX2/407AwN+/Mgjvf0EZbZ8yYMc3+znrOmpo3b56+//57Pf/8843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G1H8Morr6TmJwOc59lnn7UB7vzTgw8+ONGC4G/+5m/itbW19g8Qd9xxR3zfvn3n3EdnZ6cNbsXFxbaE+wc+8AEbEIFEm+y1ak7/8i//MnEb80eGP/mTP7Hl3YPBYPztb3+7DXtnO3r0aPyee+6JFxYWxqurq+N/9md/Fh8dHeUHhqT44Ac/GJ89e7b9nW/+aGDeR8dDHK9ZuDXI8V6bvTzmP+meFQQAAAAATB175AAAAADAZQhyAAAAAOAyBDkAAAAAcBmCHAAAAAC4DEEOAAAAAFyGIAcAAAAALkOQAwAAAACXIcgBAAAAgMsQ5AAAAADAZQhyAABcpWg0qptvvlnveMc7zrm+t7dXs2bN0l//9V/z3AIAksITj8fjyblrAACy3/79+7Vq1Sr90z/9kx544AF73fve9z699tpr2rRpkwKBQLqHCADIQgQ5AACu0de//nX97d/+rXbt2qVXX31V73znO22IW7lyJc8tACApCHIAAFwjs7jl9ttvl8/n044dO/SJT3xCn/3sZ3leAQBJQ5ADACAB9u7dq8WLF2v58uVqamqS3+/neQUAJA3FTgAASIDvfve7CgaDOnLkiE6cOMFzCgBIKmbkAAC4Ri+//LJuvfVW/e53v9MXvvAFe91TTz0lj8fDcwsASApm5AAAuAZDQ0N6//vfr49+9KO67bbb9J3vfMcWPHnooYd4XgEAScOMHAAA1+CTn/ykHnvsMdtuwCytNL797W/rz//8z23hkzlz5vD8AgASjiAHAMBVev7553XHHXfoueee0+te97pzvnbXXXcpEomwxBIAkBQEOQAAAABwGfbIAQAAAIDLEOQAAAAAwGUIcgAAAADgMgQ5AAAAAHAZghwAAAAAuAxBDgAAAABchiAHAAAAAC5DkAMAAAAAlyHIAQAAAIDLEOQAAAAAwGUIcgAAAAAgd/n/AcNLaItCMiQLAAAAAElFTkSuQmCC", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import matplotlib.pyplot as plt\n", + "\n", + "# Plot XY trajectories for first 5 agents\n", + "fig, ax = plt.subplots(figsize=(10, 10))\n", + "\n", + "agent_ids = tracks[\"agent_id\"].unique()[:5]\n", + "for agent_id in agent_ids:\n", + " agent_tracks = tracks[tracks[\"agent_id\"] == agent_id]\n", + " ax.plot(\n", + " agent_tracks[\"x\"], agent_tracks[\"y\"], \"-\", alpha=0.7, label=f\"Agent {agent_id}\"\n", + " )\n", + " # Mark start position\n", + " ax.scatter(agent_tracks[\"x\"].iloc[0], agent_tracks[\"y\"].iloc[0], s=50, marker=\"o\")\n", + "\n", + "ax.set_xlabel(\"X\")\n", + "ax.set_ylabel(\"Y\")\n", + "ax.set_title(f\"Agent Trajectories - {episode_id}\")\n", + "ax.legend()\n", + "ax.set_aspect(\"equal\")\n", + "plt.tight_layout()\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAGGCAYAAACqvTJ0AAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjgsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvwVt1zgAAAAlwSFlzAAAPYQAAD2EBqD+naQAAmQdJREFUeJzt3QV823X6B/BP3JqmunXS+cYUHWxDNmS4c7gOOOBwOTjsjwwbeofekDvcDrdDDh06GIPBnLl1XT3uyf/1fLN07dZubdc29nnz+hFpmv6SNkvyyfM8X008Ho+DiIiIiIiIiIioG2m784cREREREREREREJhlJERERERERERNTtGEoREREREREREVG3YyhFRERERERERETdjqEUERERERERERF1O4ZSRERERERERETU7RhKERERERERERFRt2MoRURERERERERE3Y6hFBERERERERERdTuGUkREREQZZsqUKRgwYABy2b777qs2IiIiylwMpYiIiKhN/vnPf0Kj0WDcuHFpu3/PPvtsmy/v8Xhwyy23YPTo0bDZbCguLsbOO++Myy+/HBUVFcgW8XgcL7zwAiZOnIiCggJYrVaMGTMGt912G7xeL9LFypUr1d9XWza5LBEREWU+TVxeqRARERFtw1577aXCGgkElixZgiFDhqTVfSbhUkl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V61apYIrCWiS5Pcr3z906FD8/e9/V4HP559/roKnhoaGLcLKQw89VLVJyu9qv/32Q1eR++mTTz5Rf1fnnHOOqu77y1/+oo7/8ccfuPXWW9XfsgSect831Z7bRERERJ1AZkoRERERtebnn3+W1Cb+6aefqtOxWCzet2/f+OWXX97scm+++aa63IMPPth4XjQaje+///7q/Geeeabx/AMOOCA+ZsyYeCAQaDxPrnfPPfeMDx06tPE8+R753smTJ6uvJ1155ZVxnU4Xb2hoaDxv1KhR8UmTJrXpF+nz+eI77LCDuu7+/fvHp0yZEv/3v/8d37BhwxaXPeuss9TlLr300mb7evjhh8eNRmO8urpanffNN9+oy7300kvNvv/jjz9udr7b7Y4XFBTEzzvvvGaXq6ysjDscjmbn77zzzvFevXo1u53/+9//Gvd7a+T3IJd7++23W71MXV2dusxxxx2nTjudzrjJZIr/9a9/bXa5e++9N67RaOKrVq1Sp1euXKnu/zvvvLPZ5ebOnRvX6/XNzpffifyMxx9/PN5ech+3djvlepv+vr/88kv1c0aPHh0PhUKN559yyilq3w899NBm3z9hwoRm192e20RERESdg5VSREREtFVS6SMVQsnqFqnakYoamfcjFURJ0gYmw6fPO++8xvO0Wi0uvvjiZtdXV1eHL774Qs00crvdqKmpUZtU00hFkVRhrVu3rtn3yAwk+blJ0vYmP1sqeDpCWrN+/PFHVdUkpGrm3HPPRa9evVRVVkttXU0rs2Rf5LTMnpJB4UKGozscDhx44IGNt0k2qaqSiqgvv/xSXe7TTz9VVTdScdb0cjqdTg1fT15OqszmzJmjKs3kepPk+mVA+bbIfSukha01ya+5XC51KG2LUtEkLXBNK8j+85//qMq2fv36qdNSfSSVcfI7bHobysrKVJVR8jYkmUwmVeHVHaTSKTkEXch9KrdFKqWakvOlLS8SiXToNhEREdH246BzIiIiapUEPxI+SSAlbV1N39BLy520Nh100EHqPAmIJNTZfID15qv0LV26VIUE0rImW0uqqqrUTKCkZBiSJPOtREuzmtpKgh5pxZNN9l1uy/33349HH31Ufe2OO+5oFq5tPmtJZjW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HnRMRERERERERUbdjKEVERERERERERN2OoRQREREREREREXW7nJopRUREREREREQdF41GEQ6HeRfmOIPBAJ1Ot93Xw1CKiIiIiIiIiLYqHo+jsrISDQ0NvKdIKSgoQFlZ2TaHmW8NQykiIiIiIiIi2qpkINWjRw9YrdbtCiIo8wNKn8+HqqoqdbpXr14dvi6GUkRERERERES01Za9ZCBVXFzMe4pgsVjUvSDBlPxddLSVj4POiYiIiIiIiKhVyRlSUiFFlJT8e9ieGWMMpYiIiIiIiIhom9iyR53998BQioiIiIiIiIiIuh1DKSIiIiIiIiIiaubWW2/FzjvvjK7EQedEREREGSYYiSIQisEfjsIXiqhDfyiKcDSuvt60ml7TQpm9VgNotRroNBrotBpoNRrodYlDOa2X87QaGLQamI06WA066HX8LJOIiDLLlClT8Nxzz+GCCy7A448/3uxrF198Mf75z3/irLPOwrPPPpuyfcx1DKWIiIiI0jyAWl3rgy8UTYRP4SiiG8On7mTUa2E16mCRkMqo33ScgRUREaWx8vJyvPrqq/jHP/7RuGJcIBDAyy+/jH79+qV693IeP/IiIiIiSmPr6v1YVetDtTsITyCSkkBKhCIxNPjCWN8QwLIqD+audeKn5XX4anE1vltagw2uQEr2i4iIaGt23XVXFUy99dZbjefJcQmkdtlll2aXjcVimDZtGgYOHKgCrJ122glvvPFG49ej0SjOPffcxq/vsMMOeOihh7aozjrmmGNw//33o1evXiguLlZVWVtboe63337DfvvtB7vdjvz8fOy22274+eef1dekiqugoADvvPMOhg4dCrPZjIMPPhhr1qxpdh3vvvuuuq3y9UGDBmHq1KmIRCKNX29oaMCf//xnlJaWqp+x//77q5/b1N13342ePXuq/ZDbKeFdV2OlFBEREVGaisfjqGhI/7BHWgclpFpvD2B4mR1mgy7Vu0RERF0oHgd8vtTcxVZr8zb1tjjnnHPwzDPP4LTTTlOnn376aZx99tn46quvml1OAqkXX3xRtfpJAPT111/j9NNPV0HOpEmTVGjVt29fvP766yps+v7773H++eer8OnEE09svJ4vv/xSnSeHS5cuxUknnaRmM5133n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Qza7fpFMhlFRlyaEEY7mIoRQRERERERERtahvoTVt7hlpB7SbDWor33ietPjJUPbAxrY/1Qa4sR1QvrZ5C56sENqnMLHiZ9PVQlti0GmxS3khFla6sL4hsB37DeRbJHySOX6JEIqt0AkMpYiIiIiIiIgoI6kWwLzWw6VoLN44q6ojK37KvL1RvR2wGfVqzlR7SJVZL4cFA4ptOVsJtS0MpYiIiIiIiIgoK8mMJlkd0Lado7AGlNjUkPf5FS4VdG0rjOpTYEX/Yus2q7FyHUMpIiIiIiIiIqJt6JFvhtmow29rGlR7YEsBWN9Ci5rFxcUh2oahFBERERERERFRG+SbDdh9QBHmrGlQs6yETqdBeaEV/YqsnBXVTgyliIiIiIiIiIjaSFryJJhauN6lZkVJGCVD0an9GEoREREREREREbWDtOqN7uPgfbadGOUREREREREREVG3YyhFRERERERERETdLmNCqTvvvBN77rknrFYrCgoKUr07RERERERERESUC6FUKBTCCSecgAsvvDDVu0JERERERERERLky6Hzq1Knq8Nlnn031rhARERERERERUa6EUh0RDAbVluRyuVK6P0RERERERERElGHtex0xbdo0OByOxq28vDzVu0RERERERERERKkOpa677jpoNJqtbosWLerw9V9//fVwOp2N25o1azp1/4mIiIiIiIiIKAPb9/76179iypQpW73MoEGDOnz9JpNJbURERERERERElF5SGkqVlpaqjYiIiIiIiIiIckvGDDpfvXo16urq1GE0GsWcOXPU+UOGDEFeXl6qd4+IiIiIiIiIiLIxlLr55pvx3HPPNZ7eZZdd1OGXX36JfffdN4V7RkRERERERERE7aWJx+Nx5AgZdl5QUKAGnufn56d6d4iIiIiIiIiIso7L5UJ5eTkaGhrgcDgyv1KqM7jdbnUodwwREREREREREXVtDrO1UCqnKqVisRgqKipgt9uh0WiQDakjq76I+Fgh4nMLEV+LEaUrvm8hys3HSzweV4FU7969odVqW71cTlVKyR3Rt29fZBP5Q830P1ai7sDHChEfL0R8fiFKHb4WI8q9x4tjKxVSSa3HVURERERERERERF2EoRQREREREREREXU7hlIZymQy4ZZbblGHRMTHChGfW4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6Tf85a2p555pnG+8bv98cvuuiieGFhYdxqtcaPPfbY+Pr163P+viOaNGlS/PLLL+djhagF77//fnz06NFqee7hw4fHn3zyyWZfl+W8b7rppnjPnj3VZQ444ID44sWLeV9SznG5XOq5RN6nmM3m+KBBg+I33nhjPBgMNl6GjxfKRV9++WWL71POOuusNj8uamtr46eccko8Ly8vnp+fHz/77LPjbrc7ng008r9UB2NERERERERERJRbOFOKiIiIiIiIiIi6HUMpIiIiIiIiIiLqdgyliIiIiIiIiIio2zGUIiIiIiIiIiKibsdQioiIiIiIiIiIuh1DKSIiIiIiIiIi6nYMpYiIiIiIiIiIqNsxlCIiIiIiIiIiom7HUIqIiIioHaZMmYJjjjkmY++zTN9/IiIiyh76VO8AERERUbrQaDRb/fott9yChx56CPF4HN3tq6++wn777Yf6+noUFBR0+88nIiIi6mwMpYiIiIg2Wr9+feN98Z///Ac333wzFi9e3HheXl6e2oiIiIho+7F9j4iIiGijsrKyxs3hcKjKqabnSSC1efvbvvvui0svvRRXXHEFCgsL0bNnTzz11FPwer04++yzYbfbMWTIEHz00UfN7ud58+bh0EMPVdcp33PGGWegpqamzb+LZ599VlVMffLJJxgxYoS6nkMOOaRZsBaNRnHVVVepyxUXF+Nvf/vbFlVesVgM06ZNw8CBA2GxWLDTTjvhjTfeUF+Ty06ePBkHH3xw4/fV1dWhb9++KrAjIiIi2h4MpYiIiIi203PPPYeSkhL89NNPKqC68MILccIJJ2DPPffEL7/8goMOOkiFTj6fT12+oaEB+++/P3bZZRf8/PPP+Pjjj7FhwwaceOKJ7fq5cn33338/XnjhBXz99ddYvXo1rr766savP/DAAyq8evrpp/Htt9+qQOntt99udh0SSD3//PN4/PHHMX/+fFx55ZU4/fTTMWPGDBXKyW2bNWsWHn74YXX5v/zlL+jTpw9DKSIiItpubN8jIiIi2k5SXfR///d/6vj111+Pu+++W4VU5513njpPqoqmT5+O33//HePHj8ejjz6qAqm77rqr8TokOCovL8cff/yBYcOGtennhsNhFSYNHjxYnb7kkktw2223NX79wQcfVPtz3HHHqdNyWamsSgoGg2ofPvvsM0yYMEGdN2jQIBVgPfHEE5g0aZIKoOT4mWeeicrKSnz44Yf49ddfodfzZSQRERFtH76aICIiItpOO+64Y+NxnU6nWuXGjBnTeJ6054mqqip1+Ntvv+HLL79scT7VsmXL2hxKWa3WxkBK9OrVq/FnOJ1O1co3bty4xq9LkDR27NjGVrylS5eqaqsDDzyw2fWGQiEVmiVJ1ZdUWEnYJuHa0KFD27R/RERERFvDUIqIiIhoOxkMhmanpe2t6XnJVf1kfpPweDw48sgjcc8992xxXRIsbc/Pbc/KgLIf4r///a+qiGrKZDI1Hpfgavbs2SpwW7JkSZuvn4iIiGhrGEoRERERdbNdd90Vb775JgYMGNBlbXAyqF0Crh9//BETJ05U50UiERUuyc8XI0eOVOGTzKKSVr3W/PWvf4VWq1XD2g877DAcfvjhaiYWERER0fbgoHMiIiKibnbxxReroeOnnHKKGiIuLXsy60lW65MV8zrL5Zdfrlru3nnnHSxatAgXXXSRGrKeJCsDymB0GW4uA81lP2Qw+yOPPKJOJ6uoZN7VSy+9pNr8rrnmGpx11lmor6/vtP0kIiKi3MRQioiIiKib9e7dG999950KoGRlPpk/dcUVV6CgoEBVJHUWqXCSVf8kRJJB5hJCHXvssc0uc/vtt+Omm25Sq/CNGDEChxxyiAqiBg4ciOrqapx77rm49dZbG6urpk6dqmZkySp8RERERNtDE2/P4AEiIiIiIiIiIqJOwEopIiIiIiIiIiLqdgyliIiIiIiIiIio2zGUIiIiIiIiIiKibsdQioiIiIiIiIiIuh1DKSIiIiIiIiIi6nYMpYiIiIiIiIiIqNsxlCIiIiIiIiIiom7HUIqIiIiIiIiIiLodQykiIiIiIiIiIup2DKWIiIiIiIiIiKjbMZQiIiIiIiIiIqJux1CKiIiIiIiIiIjQ3f4fIHnJjNVZB8UAAAAASUVORK5CYII=", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Speed over time for all agents\n", + "fig, ax = plt.subplots(figsize=(12, 4))\n", + "\n", + "# Compute mean speed per time step\n", + "speed_by_time = tracks.groupby(\"time_index\")[\"speed\"].agg([\"mean\", \"std\"])\n", + "ax.fill_between(\n", + " speed_by_time.index,\n", + " speed_by_time[\"mean\"] - speed_by_time[\"std\"],\n", + " speed_by_time[\"mean\"] + speed_by_time[\"std\"],\n", + " alpha=0.3,\n", + ")\n", + "ax.plot(speed_by_time.index, speed_by_time[\"mean\"], \"b-\", label=\"Mean speed\")\n", + "\n", + "ax.set_xlabel(\"Time Index\")\n", + "ax.set_ylabel(\"Speed\")\n", + "ax.set_title(\"Agent Speed Over Time\")\n", + "ax.legend()\n", + "plt.tight_layout()\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Spatial Heatmap" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:30:01 | INFO | collab_env.data.db.query_backend:_execute_query:112 - Executing query 'get_spatial_heatmap_episode' with params: {'episode_id': 'episode-0000-session-2d-boid_food_basic', 'bin_size': 20.0, 'start_time': None, 'end_time': None, 'agent_type': 'agent', 'min_count': 1}\n", + "2026-02-23 15:30:02 | INFO | collab_env.data.db.query_backend:_execute_query:145 - Query 'get_spatial_heatmap_episode' completed in 0.744s: 513 rows returned\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Heatmap has 513 bins\n" + ] + }, + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "x_bin", + "rawType": "float64", + "type": "float" + }, + { + "name": "y_bin", + "rawType": "float64", + "type": "float" + }, + { + "name": "z_bin", + "rawType": "object", + "type": "unknown" + }, + { + "name": "density", + "rawType": "int64", + "type": "integer" + }, + { + "name": "avg_vx", + "rawType": "float64", + "type": "float" + }, + { + "name": "avg_vy", + "rawType": "float64", + "type": "float" + }, + { + "name": "avg_vz", + "rawType": "object", + "type": "unknown" + } + ], + "ref": "a178d12a-60af-4f3f-8c91-e0bf87b334a5", + "rows": [ + [ + "0", + "0.0", + "200.0", + null, + "5", + "4.895407962799072", + "1.7533807754516602", + null + ], + [ + "1", + "0.0", + "240.0", + null, + "2", + "2.384337306022644", + "5.852751731872559", + null + ], + [ + "2", + "0.0", + "340.0", + null, + "5", + "3.0732285022735595", + "0.7338809967041016", + null + ], + [ + "3", + "0.0", + "360.0", + null, + "3", + "1.3511324326197307", + "0.8113956451416016", + null + ], + [ + "4", + "0.0", + "380.0", + null, + "3", + "2.226737101872762", + "-3.075685501098633", + null + ] + ], + "shape": { + "columns": 7, + "rows": 5 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
x_biny_binz_bindensityavg_vxavg_vyavg_vz
00.0200.0None54.8954081.753381None
10.0240.0None22.3843375.852752None
20.0340.0None53.0732290.733881None
30.0360.0None31.3511320.811396None
40.0380.0None32.226737-3.075686None
\n", + "
" + ], + "text/plain": [ + " x_bin y_bin z_bin density avg_vx avg_vy avg_vz\n", + "0 0.0 200.0 None 5 4.895408 1.753381 None\n", + "1 0.0 240.0 None 2 2.384337 5.852752 None\n", + "2 0.0 340.0 None 5 3.073229 0.733881 None\n", + "3 0.0 360.0 None 3 1.351132 0.811396 None\n", + "4 0.0 380.0 None 3 2.226737 -3.075686 None" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Get spatial heatmap (binned positions)\n", + "heatmap = query.get_spatial_heatmap(episode_id=episode_id, bin_size=20.0)\n", + "print(f\"Heatmap has {len(heatmap)} bins\")\n", + "heatmap.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAA8EAAAPdCAYAAACqXGrgAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjgsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvwVt1zgAAAAlwSFlzAAAPYQAAD2EBqD+naQAAY+9JREFUeJzt3Qu8VGW9P/5nNldvYHjhkoioqXhBy0rJS5gIocc0qZPZUUzTMvT3V0qNjqlpRVF5KU1Px5T8Hc2046WwUELFUsxbHm9l6qHAIxfTBPHCZc/6v57Fmf3bGwfcKLBmzfN+91rNnpm1Zz2zZhj3Z77PpZJlWRYAAAAgAS1FNwAAAADWFyEYAACAZAjBAAAAJEMIBgAAIBlCMAAAAMkQggEAAEiGEAwAAEAyhGAAAACSIQQDAACQDCEYoMENHz48396OSqUSzj333NAs3sm5AACIhGCAdh577LHwiU98IgwaNCj07NkzvPvd7w4HHXRQ+OEPf7hOz9OTTz6Zh9W//vWv6/31iMeMYbm2devWLWy++ebhQx/6UPjqV78aZs+eHRrV888/n5+3Rx55ZK0+bnzMeC7+/ve/171/m222Cf/0T/8U1qVrr702XHTRRev0GACQoq5FNwCgUdx7773hgAMOCFtvvXU44YQTQr9+/cKcOXPCfffdFy6++OJwyimnrNMQ/PWvfz2vcsaA1d7tt98e1odPf/rT4eCDDw7VajX84x//CA888EAewuJz/8lPfhKOPPLIULSVz0UMwfG8xXO2xx57hGYSQ/Djjz8eTj311KKbAgBNRQgG+F/f/OY3Q+/evfPwt+mmm3Y4LwsWLCjsPHXv3n29HOd973tf+Jd/+ZcOt/3tb38LI0eODGPHjg1DhgwJu+++eyjS+joXAEDz0h0a4H89++yzYZdddnlTAI623HLLDtdjV9mTTz45XHPNNWHHHXfMu07vueee4e67735TiPziF7+Y77PBBhuEzTbbLHzyk5/s0O158uTJ+W1RrETXuiXfdddddcfBLl26NJx99tn58WJo32ijjcJ+++0X7rzzzrX+WsZu4bF98ZiTJk3qcN/LL7+cVykHDhwYevToEbbffvvwne98J68kr9zV+nvf+1748Y9/HLbbbrt83w984AP5lw3tzZs3L3z2s58NW221Vb5P//79w2GHHdbhXLU/F/H8xMeJ4u/Vzlts7znnnJN3637hhRfe9JxOPPHE/DV+44031uq5is87Vs7jeyi+H/r27Rs+//nP51X19m655ZZwyCGHhAEDBuTPM56T888/P7S2tnZ4nrfeemv+/qk9r1oPgfi84/Xrr78+r4LHLvubbLJJ3o1/4cKFYcmSJfnrEt+zG2+8cX5u4m3tXXXVVeEjH/lIvk9sw8477xwuu+yyVXb7jhX4WGmPzyvue+ONN67VcwcA65NKMEC7wDdz5sy8C+quu+76ludlxowZ4ec//3n4P//n/+RB4kc/+lH46Ec/Gu6///62349BL3azjl2JY7iLgS6GjRhyYhfoDTfcMOy///75Y/zgBz/Ix+DGimtUu1zZokWLwhVXXJF3X47dtl955ZW8u/KoUaPyY6/tbsHDhg3Lg9q0adPabnvttdfChz/84fA///M/edCLXcjj85wwYUKYO3fum8ayxq69sZ1x3xjgYqA+4ogjwn//93/nYTUaM2ZMeOKJJ/Ju5zF8xep7PGYck7xyF/Ha+TnvvPPyLwRisI1fBERxLPO+++6b3xdfn/hlRU0M87/4xS/yY8VA91Zeeumlure3D/o18bnFAB5DZ3w9Z82aFS655JLwxz/+Mdxzzz1tzzPuE8Pp+PHj88s77rgjfw7xdf3ud7+b7/Ov//qveaB97rnnwoUXXpjfFvdtb+LEifkXK1/5ylfCM888k49bj8doaWnJg3cc1xy78sfjDR48OD9GTXwPxrD+sY99LHTt2jX86le/yr+sic9r3LhxHY7z9NNPh0996lPhC1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xvFIdx4rWG0u7KrGyGLvoxjAZn0dcticGr/nz5+ddx1clBuU4yVh8/jEwx+AYJ4KqjY2OE0fF349LFcXzG5eVWhdiF+e4RFLsvh3HjscvQuKxYzU7dqO/+OKL83Hlcfmm2E079g6I75vaua335Us8p/G9F5dSit3y4wRbsbv4OxXbFr/UiI8V2xzfM//+7/+ev9dW7u1Q69p+/PHH5++HOF77yiuvzF+XVYVmAGh4RU9PDdAofvOb3+RLDO20007ZxhtvnHXv3j3bfvvts1NOOSWbP39+h33jx+e4ceOy//iP/8je8573ZD169MiXjFl56Z249M9nP/vZbPPNN88fMy5D8+c//zlfembs2LEd9v33f//3fImauMRQ+2V8Vl4WqFqtZt/61rfyx6gdd8qUKfnjrbwUzposkVTbunbtmvXp0ydfXmjChAn50k/1vPLKK/n98RzFcxWf44c+9KHse9/7XtvSPatbfql92/7+97/n5zOe+7j0Uu/evfPjX3/99R1+Z+VzUVtuaeedd87bXW+5pPvvvz+/feTIkVln1ZZIeuGFF+reH89z+yWSan784x9ne+65Z7bBBhtkm2yySbbbbrvlS209//zzbfvcc8892d57753vM2DAgLaluFZeumnx4sXZUUcdlW266ab5fbXXtrZEUlxWq734vOPtcdmot3ouv/zlL7OhQ4fmS3pts8022Xe+853syiuvzPeLr9nKzzO2L+4f32/xNVr52ABQJpX4f0UHcYCyiRW8cePG5RVGGluc5TtW2mMX3qOPPrro5pRK7AERezzEWbUBoFkYEwxAU4tdfWNX4iOOOKLopgAADcCYYACaUpwF+cknnww//vGPw8knn9w2iRYAkDYhGICmnegsTuB08MEHd5isDABImzHBAAAAJMOYYAAAAJLR9N2h43qXzz//fL5+ZJzNFQAAWPfiIjSvvPJKGDBgQGhpKV/t7Y033ghLly4NZRLXge/Zs2fRzWh4TR+CYwAeOHBg0c0AAIAkzZkzJ2y11VahbAF48KCNw7wFraFM+vXrF2bNmiUIpx6CYwU42jccHLqGbuu/AUVWn4taAjrF5wxAqd2y8OrCjn1Y72MKOzbpKOI9vmjRorwYVft7v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xj2GWXXfJ9TjjhhHDeeee1/U4MuzWtra15AO7Xr1+49957w9y5c8MxxxwTunXrFr71rW/l+8yaNSvfJ4bna665JkyfPj187nOfC/379w+jRo0KRRGCAQAAmsSiRYs6XI8V2Lit7NBDD+1w/Zvf/GZeHb7vvvvaQnAMvTHk1nP77beHJ598Mvz2t78Nffv2DXvssUc4//zzw5lnnhnOPffc0L1793D55ZeHwYMHh+9///v57wwZMiT8/ve/DxdeeGGhIVh3aAAAgDqqoVKqLRo4cGDo3bt32zZx4sS3fG1bW1vDddddF1599dW8W3RNrN5uvvnmYddddw0TJkwIr732Wtt9M2fODLvttlsegGtisI0h/IknnmjbZ8SIER2OFfeJtxdJJRgAAKBJzJkzJx/jW1OvClzz2GOP5aH3jTfeCBtvvHG46aabws4775zfd9RRR4VBgwaFAQMGhEcffTSv8D711FPhxhtvzO+fN29ehwAc1a7H+1a3TwzKr7/+ethggw1CEYRgAACAJlGb6Kozdtxxx/DII4+EhQsXhl/84hdh7NixYcaMGXkQPvHEE9v2ixXfOI73wAMPDM8++2zYbrvtQpkJwQAAAHVUQ0toLckI0mpY8yWSunfvns/YHO25557hgQceCBdffHH4t3/7tzftu9dee+WXzzzzTB6C41jh+++/v8M+8+fPzy9r44jjZe229vvEkF5UFTgqxysKAADAOlWtVsOSJUvq3hcrxlGsCEexG3XsTr1gwYK2faZNm5YH3FqX6rhPnBG6vbhP+3HHRVAJBgAASMyECRPC6NGjw9Zbbx1eeeWVcO211+Zr+t522215l+d4/eCDDw6bbbZZPib4tNNOC/vvv3++tnA0cuTIPOweffTRYdKkSfn437POOiuMGzeubRxyXBrpkksuCWeccUY47rjjwh133BGuv/76cOuttxb63IVgAACAxCxYsCBf1zeu7xtnkY7hNgbggw46KJ9cKy59dNFFF+UzRscZp8eMGZOH3JouXbqEKVOmhJNOOimv7G600Ub5mOL26wrH5ZFi4I0BOnazjmsTX3HFFYUujxRVsrgychOLM4/FF3V4OCx0rXRb78dv6dkzFKWwl7ba1G+pVcuq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yCOPhFNPPTV87nOfC7fddluh7zdjggEAAJrEokWLOlyPFdi4tTd16tQO12N4jZXchx56KOy///5tt8cKb79+/eoe5/bbbw9PPvlk+O1vfxv69u0b9thjj3D++eeHM888M5x77rmhe/fu4fLLLw+DBw8O3//+9/PfGTJkSPj9738fLrzwwjBq1KhQFJVgAACAJjFw4MDQu3fvti12fX4rCxcuzC/79OnT4fZrrrkmbL755mHXXXcNEyZMCK+99lrbfTNnzgy77bZbHoBrYrCNIfyJJ55o22fEiBEdHjPuE28vkkowAABAk5gzZ07o1atX2/WVq8Arq1areTflffbZJw+7NUcddVQYNGhQGDBgQHj00UfzCm8cN3zjjTfm98+bN69DAI5q1+N9q9snBuXXX389bLDBBqEIQjAAAEAd1awSKiVZeii2NYoBuH0Ifivjxo0Ljz/+eN5Nub0TTzyx7edY8e3fv3848MADw7PPPhu22267UGa6QwMAACTo5JNPDlOmTAl33nln2GqrrVa771577ZVfPvPMM/llHCs8f/78DvvUrtfGEa9qnxjSi6oCR0IwAABAQrIsywPwTTfdFO6444588qq3Emd3jmJFOBo2bFh47LHHwoIFC9r2iTNNx4C78847t+0zffr0Do8T94m3F0l3aAAAgDqybMVWBmvSznHjxoVrr7023HLLLflawbUxvHEirVihjV2e4/0HH3xw2GyzzfIxwaeddlo+c/TQoUPzfeOSSjHsHn300fnSSfExzjrrrPyxa+OQ47rCl1xySTjjjDPCcccdlwfu66+/Ptx6662hSCrBAAAACbnsssvyGaGHDx+eV3Zr289//vP8/ri8UVz6KAbdnXbaKXzpS18KY8aMCb/61a/aHqNLly55V+p4GSu7//Iv/xKOOeaYcN5557XtEyvMMfDG6u/uu++eL5V0xRVXFLo8UqQSDAAAkFh36LdaZmnGjBnhrcTZo3/961+vdp8YtP/4xz+GRqISDAAAQDJUggEAAFY5JrgcSySVZexyI1AJBgAAIBlCMAAAAMnQHRoAAKCO2BW6PN2hy9HORqASDAAAQDKEYAAAAJIhBAMAAJAMY4IBAADqiKsOlWXlobK0sxGoBAMAAJA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Mnv6969exg7duy6GRP89NNPh/322y9ssMEGYdCgQXnpOW6x9BwvAQAAaFwTJ04MH/jAB8Imm2ySV1APP/zwvKtxe3E93nHjxoXNNtssbLzxxmHMmDFh/vz5HfaZPXt2OOSQQ8KGG26YP87pp58eli9f3mGfu+66K7zvfe8LPXr0yNf7jd2W19R2220X/v73v7/p9pdeeultZdA1rgTHEnSclWvKlCl5KbpSaf4B2AAAAM1ixowZecCNQTiG1q9+9ath5MiR4cknnwwbbbRRvs9pp50Wbr311nwm5t69e4eTTz45n5n5nnvuye9vbW3NA3Bct/fee+/NZ2aOMzR369YtfOtb38r3mTVrVr7PF77whXDNNdeE6dOnh8997nN5jhw1alSn2xsrvvUsXrw49OzZc42ffyVb1SOuQjwpDz30UNhpp51CGSxatCh/0RYuXBh69eq13o9/UMsnQ2oqXQ01X9+y1tb1fkwKsmYf2WtXS5dijpt1HHaTzPlO9Uvmos55kee7YrGOZD5XCnytpy2/Lrm/w9dG27ee9I3QssGah6wiVF9/I8w+46y3db5feOGFvJIbw/H++++fP8YWW2wRrr322vCJT3wi3+fPf/5zGDJkSJg5c2bYe++9w29+85vwT//0T/mszH379s33ufzyy8OZZ56ZP17snhx/jkH68ccfbzvWkUceGV5++eUwderUt2zX+PHj88u4RvAJJ5yQV5xrYgj/wx/+ELp06dIWzDtrjdPKzjvvXLcUDQAA0FTi93JlGWub/b8A317shhy31Vm4cGF+2adPn/wyFj2XLVsWRowY0bZPLILGsbe1EBwvd9ttt7YAHMXq7kknnRSeeOKJ8N73vjffp/1j1PY59dRTO/WU/vjHP654alkWHnvssTxY18Sfd99993yZpDW1xiE4Lkp8xhln5CXu+KRjubu9sn3LAwAA0CwGDhzY4fo555wTzj333FXuX61W81C6zz77hF133TW/bd68eXnI3HTTTTvsGwNvvK+2T/sAXLu/dt/q9olB/fXXX8/nmVqdO++8M7/87Gc/m1eD11bWXOMQXEvyBx54YIfbYzqP44NjWRoAAID1L86W3D4svlUVeNy4cXl35d///vehUcU1gtemNQ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8lkpqSSjAAAADJKDQE33333eHQQw8NAwYMCJVKJdx8880d7s+yLJx99tmhf//+YYMNNggjRowITz/9dGHtBQAAoNwKDcGvvvpq2H333cOll15a9/5JkyaFH/zgB+Hyyy8Pf/jDH8JGG20URo0aFd5444313lYAACDR7tBl2Wj8McGjR4/Ot3piFfiiiy4KZ511VjjssMPy266++urQt2/fvGJ85JFH1v29JUuW5FvNokWL1lHrAQAAKJuGHRM8a9asMG/evLwLdE3v3r3DXnvtFWbOnLnK35s4cWK+X20bOHDgemoxAAAAja5hQ3AMwFGs/LYXr9fuq2fChAlh4cKFbducOXPWeVsBAAAoh6ZbIqlHjx75BgAA8E5UshVbGZSlnY2gYSvB/fr1yy/nz5/f4fZ4vXYfAAAANEUIHjx4cB52p0+f3mGSqzhL9LBhwwptGwAAAOVUaHfoxYsXh2eeeabDZFiPPPJI6NOnT9h6663DqaeeGr7xjW+E97znPXko/trXvpavKXz44YcX2WwAACAFZVp6qCztTD0EP/jgg+GAAw5ouz5+/Pj8cuzYsWHy5MnhjDPOyNcSPvHEE8PLL78c9t133zB16tTQs2fPAlsNAABAWRUagocPH56vB7wqlUolnHfeefkGAAAATTsmGAAAANa2plsiCQAAYK0wJrgpqQQDAACQDCEYAACAZOgODQAAUEclW7GVQVna2QhUggEAAEiGEAwAAEAyhGAAAACSIQQDAACsbomksmxr4O677w6HHnpoGDBgQKhUKuHmm2/ucP+xxx6b395+++hHP9phn5deeil85jOfCb169QqbbrppOP7448PixYs77PPoo4+G/fbbL/Ts2TMMHDgwTJo0qfD3mhAMAACQmFdffTXsvvvu4dJLL13lPjH0zp07t2372c9+1uH+GICfeOKJMG3atDBlypQ8WJ944olt9y9atCiMHDkyDBo0KDz00EPhu9/9bjj33HPDj3/841Aks0M3sWnVGwo57kEtnyzkuMA6lpl2kvWg2uo0r0+VivMNTSYGz/Z69OiRbysbPXp0vq1O/L1+/frVve9Pf/pTmDp1anjggQfC+9///vy2H/7wh+Hggw8O3/ve9/IK8zXXXBOW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58d+vfvHzbYYIMwYsSI8PTTT3fY56WXXgqf+cxnQq9evcKmm24ajj/++LB48eIO+zz66KNhv/32Cz179gwDBw4MkyZNCkUTggEAAOrJsnJta+DVV18Nu+++e7j00kvr3h/D6g9+8INw+eWXhz/84Q9ho402CqNGjQpvvPFG2z4xAD/xxBNh2rRpYcqUKXmwPvHEE9vuX7RoURg5cmQYNGhQeOihh8J3v/vdcO6554Yf//jHhb7fTIwFAADQJGLwbK9Hjx75trLRo0fnWz2xCnzRRReFs846Kxx22GH5bVdffXXo27dvXjE+8sgjw5/+9KcwderU8MADD4T3v//9+T4//OEPw8EHHxy+973v5RXma665JixdujRceeWVoXv37mGXXXYJjzzySLjgggs6hOX1TSUYAACgScQux717927bJk6cuMaPMWvWrDBv3ry8C3RNfKy99torzJw5M78eL2MX6FoAjuL+LS0teeW4ts/++++fB+CaWE1+6qmnwj/+8Y9QFJVgAACAJlkiac6cOfkY3Zp6VeC3EgNwFCu/7cXrtfvi5ZZbbtnh/q5du4Y+ffp02Gfw4MFveozafe9617tCEYRgAACAJhEDcPsQzJvpDg0AAECbfv365Zfz58//fzf+7/XaffFywYIFHe5fvnx5PmN0+33qPUb7YxRBCAYAAKBN7MIcQ+r06dM7TLgVx/oOGzYsvx4vX3755XzW55o77rgjVKvVfOxwbZ84Y/SyZcva9okzSe+4446FdYWOhGAAAIB6spJta2Dx4sX5TM1xq02GFX+ePXt2vm7wqaeeGr7xjW+EX/7yl+Gxxx4LxxxzTD7j8+GHH57vP2TIkPDRj340nHDCCeH+++8P99xzTzj55JPzmaPjftFRRx2VT4oV1w+OSyn9/Oc/DxdffHEYP358oe83Y4IBAAAS8+CDD4YDDjig7XotmI4dOzZMnjw5nHHGGflawnEpo1jx3XffffMlkXr27Nn2O3EJpBh8DzzwwHxW6DFjxuRrC7efUfr2228P48aNC3vuuWfYfPPNw9lnn13o8kiREAwAAJCY4cOH5+sBr0qsBp933nn5tipxJuhrr712tccZOnRo+N3vfhcaiRAMAADQJEsk8da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vf/nL+W0LFy4Mffv2DZMnTw5HHnmkV4J3/D6rVYJffvnlN1WI4e164YUX8opwDLv7779//tm1xRZbhGuvvTZ84hOfyPf585//HIYMGRJmzpwZ9t57bycbWCWV4DqWLl0aHnroobybYNuJamnJr8cPVlhbYjfUGEq23Xbb8JnPfCbMnj3byWWdmTVrVpg3b16Hz7bevXvnX/r5bGNtu+uuu/LQsuOOO4aTTjopvPjii04yb1sMvVGfPn3yy/h3WqwOt/88i0OKtt56a59nwFsSguv4+9//HlpbW/PqSHvxevwDEtaGGDxi9W3q1KnhsssuywPKfvvtF1555RUnmHWi9vnls411LXaFvvrqq8P06dPDd77znbx6N3r06Py/rbCmYm+8U089Neyzzz5h1113bfs86969e9h000077OtvNaAzunZqL2Cti38Q1gwdOjQPxYMGDQrXX399OP74451xoLTad63fbbfd8s+47bbbLq8OH3jggYW2jfKJY4Mff/xx82YAa41KcB2bb7556NKly5tmGIzX+/Xrt/bOPrQTv83eYYcdwjPPPOO8sE7UPr98trG+xSEf8b+tPt9YUyeffHKYMmVKuPPOO8NWW23V4fMsDl+LY8/b87ca0BlCcB2xe82ee+6Zd+Nq3xUnXh82bFinTiysqcWLF4dnn302X7oG1oXBgwfnfzi2/2xbtGhRPku0zzbWpeeeey4fE+zzjc6KE/nFABwnXbvjjjvyz6/24t9p3bp16/B5FpdQinNr+DwD3oru0KsQl0caO3ZseP/73x8++MEPhosuuiiflv+zn/3sW55U6Iw4O29cZzN2gY7LOsTluGIPhE9/+tNOIO/oy5T21bY41jzOQB4nk4kTxsRxdd/4xjfCe97znvyPyq997Wv55GztZ/aFd/I+i9vXv/71fM3W+KVL/HLvjDPOCNtvv32+HBd0tgt0nPn5lltuydcKrs1pECfzi2ucx8s4dCj+vRbfc7169cpX8IgB2MzQwFvKWKUf/vCH2dZbb5117949++AHP5jdd999zhZrzac+9amsf//++fvr3e9+d379mWeecYZ5R+68884sfrSvvI0dOza/v1qtZl/72teyvn37Zj169MgOPPDA7KmnnnLWWWvvs9deey0bOXJktsUWW2TdunXLBg0alJ1wwgnZvHnznGU6rd77K25XXXVV2z6vv/569sUvfjF717velW244YbZxz/+8Wzu3LnOMvCWrBMMAABAMowJBgAAIBlCMAAAAMkQggEAAEiGEAwAAEAyhGAAAACSIQQDAACQDCEYAACAZAjBAAAAJEMIBqDhbLPNNuGiiy5a7T6VSiXcfPPN661NAEBzEIIBWCdaW1vDhz70oXDEEUd0uH3hwoVh4MCB4V//9V/f0ePPnTs3jB49+h22EgBIjRAMwDrRpUuXMHny5DB16tRwzTXXtN1+yimnhD59+oRzzjnnHT1+v379Qo8ePdZCSwGAlAjBAKwzO+ywQ/j2t7+dB99Yub3lllvCddddF66++urQvXv31f7uK6+8Ej796U+HjTbaKLz73e8Ol1566Sq7Q//1r3/Nr994443hgAMOCBtuuGHYfffdw8yZM726AEAHQjAA61QMwDGQHn300eHEE08MZ599dn79rXz3u9/N9/vjH/8YvvKVr4T/7//7/8K0adNW+zuxi/WXv/zl8Mgjj+QBPIbo5cuXr8VnAwCUXSXLsqzoRgDQ3P785z+HIUOGhN122y08/PDDoWvXrm85MVbc/ze/+U3bbUceeWRYtGhR+PWvf51fj5Xfm266KRx++OF5JXjw4MHhiiuuCMcff3x+/5NPPhl22WWX8Kc//SnstNNO6/gZAgBloRIMwDp35ZVX5l2UZ82aFZ577rlO/c6wYcPedD0G2tUZOnRo28/9+/fPLxcsWPC22gwANCchGIB16t577w0XXnhhmDJlSvjgBz+YV2rXVSekbt26tf0cK8VRtVpdJ8cCAMpJCAZgnXnttdfCscceG0466aR8wqqf/OQn4f777w+XX375W/7ufffd96brsYs0AMA7IQQDsM5MmDAhr/rGGaJrY32/973vhTPOOCMfx7s699xzT5g0aVL4y1/+ks8MfcMNN+STYwEAvBNCMADrxIwZM/LwetVVV+XjgWs+//nPhw996ENv2S36S1/6UnjwwQfDe9/73vCNb3wjXHDBBWHUqFFeLQDgHTE7NAAAAMlQCQYAACAZQjAAAADJEIIBAABIhhAMAABAMoRgAAAAkiEEAwAAkAwhGAAAgGQIwQAAACRDCAYAACAZQjAAAADJEIIBAAAIqfj/AaHpM15ZIQqPAAAAAElFTkSuQmCC", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Plot 2D heatmap (XY)\n", + "import numpy as np\n", + "\n", + "# Aggregate z dimension\n", + "heatmap_2d = heatmap.groupby([\"x_bin\", \"y_bin\"])[\"density\"].sum().reset_index()\n", + "\n", + "# Create 2D grid\n", + "pivot = heatmap_2d.pivot(index=\"y_bin\", columns=\"x_bin\", values=\"density\")\n", + "\n", + "fig, ax = plt.subplots(figsize=(10, 10))\n", + "im = ax.imshow(pivot.values, origin=\"lower\", cmap=\"viridis\", aspect=\"auto\")\n", + "ax.set_xlabel(\"X bin\")\n", + "ax.set_ylabel(\"Y bin\")\n", + "ax.set_title(\"Spatial Density Heatmap\")\n", + "plt.colorbar(im, ax=ax, label=\"Density\")\n", + "plt.tight_layout()\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Animated Track Visualization\n", + "\n", + "Interactive animation with timeline slider and play controls using Plotly." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
\n", + " \n", + "
\n", + " \n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
\n", + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
\n", + "
\n", + "
\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from matplotlib.animation import FuncAnimation\n", + "from IPython.display import HTML\n", + "\n", + "# Select subset of agents for clarity\n", + "num_agents_to_plot = 10\n", + "selected_agents = tracks[\"agent_id\"].unique()[:num_agents_to_plot]\n", + "tracks_anim = tracks[tracks[\"agent_id\"].isin(selected_agents)].copy()\n", + "\n", + "# Setup figure\n", + "fig, ax = plt.subplots(figsize=(10, 10))\n", + "ax.set_xlim(tracks[\"x\"].min() - 20, tracks[\"x\"].max() + 20)\n", + "ax.set_ylim(tracks[\"y\"].min() - 20, tracks[\"y\"].max() + 20)\n", + "ax.set_xlabel(\"X\")\n", + "ax.set_ylabel(\"Y\")\n", + "ax.set_aspect(\"equal\")\n", + "ax.set_title(\"Agent Tracks Animation\")\n", + "\n", + "# Create scatter and trail objects for each agent\n", + "scatters = {}\n", + "trails = {}\n", + "colors = plt.get_cmap(\"tab10\")(np.linspace(0, 1, num_agents_to_plot))\n", + "\n", + "for i, agent_id in enumerate(selected_agents):\n", + " scatters[agent_id] = ax.scatter(\n", + " [], [], s=100, c=[colors[i]], label=f\"Agent {agent_id}\", zorder=3\n", + " )\n", + " (trails[agent_id],) = ax.plot([], [], \"-\", c=colors[i], alpha=0.4, linewidth=2)\n", + "\n", + "ax.legend(loc=\"upper right\", fontsize=8)\n", + "time_text = ax.text(\n", + " 0.02,\n", + " 0.98,\n", + " \"\",\n", + " transform=ax.transAxes,\n", + " va=\"top\",\n", + " fontsize=12,\n", + " bbox=dict(boxstyle=\"round\", facecolor=\"wheat\", alpha=0.8),\n", + ")\n", + "\n", + "# Animation parameters\n", + "trail_length = 20 # Number of frames to show in trail\n", + "\n", + "\n", + "def animate(frame_idx):\n", + " \"\"\"Update function for each frame.\"\"\"\n", + " time_indices = sorted(tracks_anim[\"time_index\"].unique())\n", + " time_index = time_indices[frame_idx]\n", + "\n", + " for agent_id in selected_agents:\n", + " # Get trail data (last trail_length frames)\n", + " trail_data = tracks_anim[\n", + " (tracks_anim[\"agent_id\"] == agent_id)\n", + " & (tracks_anim[\"time_index\"] <= time_index)\n", + " & (tracks_anim[\"time_index\"] > time_index - trail_length)\n", + " ].sort_values(\"time_index\")\n", + "\n", + " if len(trail_data) > 0:\n", + " # Update trail\n", + " trails[agent_id].set_data(trail_data[\"x\"], trail_data[\"y\"])\n", + "\n", + " # Update current position\n", + " current = trail_data[trail_data[\"time_index\"] == time_index]\n", + " if len(current) > 0:\n", + " scatters[agent_id].set_offsets(\n", + " [[current.iloc[0][\"x\"], current.iloc[0][\"y\"]]]\n", + " )\n", + "\n", + " time_text.set_text(f\"Time: {time_index}\")\n", + " return list(scatters.values()) + list(trails.values()) + [time_text]\n", + "\n", + "\n", + "# Create animation\n", + "n_frames = len(tracks_anim[\"time_index\"].unique())\n", + "anim = FuncAnimation(\n", + " fig, animate, frames=n_frames, interval=100, blit=True, repeat=True\n", + ")\n", + "\n", + "# Display in notebook\n", + "plt.close() # Prevent static plot from showing\n", + "HTML(anim.to_jshtml())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Extended Properties" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:30:09 | INFO | collab_env.data.db.query_backend:_execute_query:112 - Executing query 'get_available_properties_episode' with params: {'episode_id': 'episode-0000-session-2d-boid_food_basic', 'agent_type': 'agent'}\n", + "2026-02-23 15:30:10 | INFO | collab_env.data.db.query_backend:_execute_query:145 - Query 'get_available_properties_episode' completed in 0.236s: 1 rows returned\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Available extended properties:\n" + ] + }, + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "property_id", + "rawType": "object", + "type": "string" + }, + { + "name": "property_name", + "rawType": "object", + "type": "string" + }, + { + "name": "data_type", + "rawType": "object", + "type": "string" + }, + { + "name": "unit", + "rawType": "object", + "type": "string" + } + ], + "ref": "817ab327-2cf7-4555-a1e6-0b55b0360c07", + "rows": [ + [ + "0", + "distance_to_food", + "Distance to Food", + "float", + "scene_units" + ] + ], + "shape": { + "columns": 4, + "rows": 1 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
property_idproperty_namedata_typeunit
0distance_to_foodDistance to Foodfloatscene_units
\n", + "
" + ], + "text/plain": [ + " property_id property_name data_type unit\n", + "0 distance_to_food Distance to Food float scene_units" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Get available extended properties for this episode\n", + "props = query.get_available_properties(episode_id)\n", + "print(\"Available extended properties:\")\n", + "props[[\"property_id\", \"property_name\", \"data_type\", \"unit\"]]" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:30:10 | INFO | collab_env.data.db.query_backend:_execute_query:112 - Executing query 'get_property_distributions_episode' with params: {'episode_id': 'episode-0000-session-2d-boid_food_basic', 'start_time': None, 'end_time': None, 'agent_type': 'agent'}\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Getting distribution for: distance_to_food\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:30:10 | INFO | collab_env.data.db.query_backend:_execute_query:145 - Query 'get_property_distributions_episode' completed in 0.250s: 25200 rows returned\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Distribution statistics:\n", + " Count: 25200\n", + " Mean: 184.072\n", + " Std: 173.006\n", + " Min: 0.000\n", + " Max: 545.740\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAA90AAAGGCAYAAABmGOKbAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjgsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvwVt1zgAAAAlwSFlzAAAPYQAAD2EBqD+naQAAQMBJREFUeJzt3Qd4FOXe//9vQgg9oYceokhvUgSOojRBRB4Q9FgQkXpAUIoCcg4iwjkHHzw0EUVFynksFBWVIkWaIEWqVBE0QAQSEIQAQur+ru/9v2b/u2kkuztp+35d17jZmXtnZ2bHkM/eLcDhcDgEAAAAAAD4XKDvdwkAAAAAAAjdAAAAAADYiJpuAAAAAABsQugGAAAAAMAmhG4AAAAAAGxC6AYAAAAAwCaEbgAAAAAAbELoBgAAAADAJoRuAAAAAABsQugGANhm4sSJEhAQkC1XuE2bNmaxbN682bz3Z599li3v/9xzz0n16tUlN7t+/boMGDBAKlSoYK7NiBEjsrwPfZ1+rpaFCxeadadOnfLx0SIjMTEx8thjj0mZMmXM9Z85c2a2XTD9rPU99bMHANweoRsAkClWuLKWwoULS6VKlaRTp07y1ltvybVr13xyJc+dO2dC3YEDB3LdJ5Objy0z/v3vf5vPcciQIfJ///d/0rt37xw5jj///NNcR/1iJL/Jrntk5MiRsnbtWhk3bpz5LB966CFb3w8A4LkgL14LAPBDkyZNkoiICElISJDo6GgTnLTGdPr06fL1119Lw4YNnWXHjx8vr7zySpZDy+uvv25qjRs3bpzp161bt07sltGxffDBB5KcnCy52caNG6Vly5by2muv+WyfGtyffPJJKVSoUJZCt15H5do6IT/w9P715LPs1q2bvPzyy7a9BwDANwjdAIAs6dy5szRr1sz5XGvaNAA88sgj8j//8z9y7NgxKVKkyP/3j0xQkFnspAGuaNGiEhwcLDmpYMGCkttduHBB6tat69N9FihQwCzI/s+yZMmSXHYAyANoXg4A8Fq7du3k1VdfldOnT8tHH32UYZ/u9evXy3333WcCQ/HixaVWrVry97//3WzTWvPmzZubn/v27etsym71HdVa0fr168vevXvl/vvvN2Hbem3KPt2WpKQkU0b7MRcrVsx8MRAVFeVWRmsltU92Sq77vN2xpdWn+8aNG/LSSy9J1apVTU2wnut//vMfcTgcbuV0P8OGDZMvv/zSnJ+WrVevnqxZsybTAax///4SFhZmmv03atRIFi1alKp/e2RkpKxatcp57Bn1w46LizNNmMuVKyclSpQw1+23335LVS6tPt179uwx3Q7Kli1rvoDRlhH9+vUz27Sc7lNpjbB1LFY/8YMHD5preccdd5hz0c9NX3vp0iW397XurZMnT5ryej+Fhoaaz0a/iElJ78t77rnH3DOlSpUy90/K1hHffPONtG7d2twnes5dunSRI0eOZOozyMw9opYtWyZNmzY110WvzzPPPCNnz57N9HtY11vvoTlz5jjfw/Lrr7/K448/LqVLlzbnqi0b9DPP6j1juXLlirm+em31Gvfp08esAwBkHjXdAACfNTPWcKtBZuDAgWmW0QCjNeLaBF2bqWu41ND0/fffm+116tQx6ydMmCCDBg0yAUj95S9/ce5Dw5fWtmuTZg0sGhoy8q9//cuEkrFjx5qgoQNOdejQwfS5tWrkMyMzx+ZKQ5EG1U2bNplwo02NtQ/u6NGjTciaMWOGW/lt27bJF198Ic8//7wJfNpPvmfPnnLmzBkzWFZ6bt68ab4Y0OuowV0DrgY7DUoajoYPH26OXfv9aoiuUqWK+SJAWeE3LTrgmgbVp59+2pyjtmbQEHo7eo07duxo9q1dCzSoadDWc7Pe89133zX9yh999FHp0aOHWW91S9AvZTQ4amjVwK33zPvvv28ed+7cmepLnL/+9a/mnKdMmSL79u2TefPmSfny5eV///d/nWU03GtI1/PQz1BbRezatcuckx6r0uujgVK/LNDXanDX49QviPbv35+pQfJud49oYNbz0mCux6uDoc2aNcvc//oemam51i8LrP74Dz74oDz77LPObbo/fS899hdffNHcNxqk9T7UAQX1emf2nrHuYW3Crvfm4MGDzfktX77cXCcAQBY4AADIhAULFmj1rGP37t3plgkNDXXcfffdzuevvfaaeY1lxowZ5vnFixfT3YfuX8vo+6X0wAMPmG1z585Nc5sulk2bNpmylStXdsTGxjrXL1261KyfNWuWc114eLijT58+t91nRsemr9f9WL788ktT9p///Kdbuccee8wREBDgOHnypHOdlgsODnZb9+OPP5r1s2fPdmRk5syZptxHH33kXBcfH+9o1aqVo3jx4m7nrsfXpUsXx+0cOHDA7PP55593W//000+b9fq5prwvIiMjzfPly5ff9j7Rzz/lfix//vlnqnWffvqpKf/dd9+lurf69evnVvbRRx91lClTxvn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ApI2B1AAAyCHaV/r48ePy7bffmqbfzz//vLz55pumeXrBggXTfI1unzVrlukXrsFbm5DrdGQa9l2lfL32hdbQrLT/ckauX79u+ntb/ctdaf9zAACQedR0AwDgI3feeacJu9qP2qKDff3888/pvkYDsA7k9dZbb5n+39o3Wfsfq+Dg4FS1wNoPu1u3bvLMM89Io0aNTC15RvtPi9aC//bbb+m+rkmTJqafd40aNVIteky3k9Zx68jjeuwpz0Vr262+5Fmh+9NWAa7XWgeZ0y8x6tatm6n31Fpt3Yf2/bbo6+2cAxwA4H8I3QAA+Ig2w+7fv78ZTG3jxo1moDMdqCswMO1/brUJ94cffmjK/frrr2ZQMw3h4eHhZruOtq0jdp89e1Z+//13s+6uu+4yteI6X7U2j9Ya6ZiYmCwd5wMPPCD333+/GShN96VNxr/55htZs2aN2T527Fizfx04TZuia3NsHRguMwOppXfcL730kmzYsME0jdewrwO9vf322/Lyyy+LJ/Q66JcP2ixfB3nTJvH6RYSO6q7rM/Oe2hRdB4zTa6jhXcP3gAEDbtsSAACArCB0AwDgQ9r8W6fa0trrDh06yH333efWZ9iV9h3+4IMPTD9jrX3WZuYrVqwwfZOVjgB+6tQpU4Nuze89fvx4UxOtfax16iydDqx79+5ZPk4dOb158+Zm+jGtGdbpxazaaT0WbeKuQVXP5e6775YJEyaYKc0yI63j1mNeunSpLF682ExPpvvTcvqlhKcWLFhgru0jjzxiRjbX0ctXr17tbFqfmffUfeh56RcRPXr0MKPBly9f3uNjAgAgpQAdTS3VWgAAAAAA4DVqugEAAAAAsAmhGwAAZNrWrVvdphJLueSWfQIAkFvQvBwAAGSaziuuA6SlR0c4zw37BAAgtyB0AwAAAABgE5qXAwAAAABgE0I3AAAAAAA2IXQDAAAAAGATQjcAAAAAADYhdAMAAAAAYBNCNwAAAAAANiF0AwAAAABgE0I3AAAAAABij/8H2dBPQ3AbeNUAAAAASUVORK5CYII=", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Get distribution of a property (if any exist)\n", + "if len(props) > 0:\n", + " property_id = props.iloc[0][\"property_id\"]\n", + " print(f\"Getting distribution for: {property_id}\")\n", + "\n", + " dist = query.get_property_distributions(\n", + " episode_id=episode_id, property_ids=[property_id]\n", + " )\n", + "\n", + " if len(dist) > 0:\n", + " print(\"\\nDistribution statistics:\")\n", + " print(f\" Count: {len(dist)}\")\n", + " print(f\" Mean: {dist['value_float'].mean():.3f}\")\n", + " print(f\" Std: {dist['value_float'].std():.3f}\")\n", + " print(f\" Min: {dist['value_float'].min():.3f}\")\n", + " print(f\" Max: {dist['value_float'].max():.3f}\")\n", + "\n", + " # Plot histogram\n", + " fig, ax = plt.subplots(figsize=(10, 4))\n", + " ax.hist(dist[\"value_float\"], bins=50, edgecolor=\"black\", alpha=0.7)\n", + " ax.set_xlabel(property_id)\n", + " ax.set_ylabel(\"Count\")\n", + " ax.set_title(f\"Distribution of {property_id}\")\n", + " plt.tight_layout()\n", + " plt.show()\n", + "else:\n", + " print(\"No extended properties available for this episode\")" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:30:10 | INFO | collab_env.data.db.query_backend:_execute_query:112 - Executing query 'get_extended_properties_timeseries' with params: {'episode_id': 'episode-0000-session-2d-boid_food_basic', 'window_size': 10, 'start_time': None, 'end_time': None, 'agent_type': 'agent', 'lower_quantile': 0.1, 'upper_quantile': 0.9}\n", + "2026-02-23 15:30:10 | INFO | collab_env.data.db.query_backend:_execute_query:145 - Query 'get_extended_properties_timeseries' completed in 0.176s: 120 rows returned\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAGGCAYAAACqvTJ0AAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjgsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvwVt1zgAAAAlwSFlzAAAPYQAAD2EBqD+naQAAwgpJREFUeJzs3Qd4U2XbB/B/m6RJk+6y95btAFw4XhX3Fv3cOHC8CrgXbpwIihtxb9zi6164ARcCsmRDy+huVtPsfNf9xJaW2ZF1kv/PK7ZNQ3symnPO/dwjLRQKhUBERERERERERBRD6bH8ZURERERERERERIJBKSIiIiIiIiIiijkGpYiIiIiIiIiIKOYYlCIiIiIiIiIiophjUIqIiIiIiIiIiGKOQSkiIiIiIiIiIoo5BqWIiIiIiIiIiCjmGJQiIiIiIiIiIqKYY1CKiIiIiIiIiIhijkEpIiKiFHb33XcjLS2t0XU9evTAhRdeGLdtSlWvv/46+vfvD4PBgLy8vJj+bnm+5XlPZf/5z3/UhYiIiGKHQSkiIiJqtc8//1wFuJLRzJkz8dhjj0X1d/zzzz8qMNS7d288//zzeO6555CoQqGQCqAdcsghKnhmNpsxZMgQ3HPPPaipqUGiWL9+vQq4NuUityUiIqLY08fhdxIREVECW7FiBdLT05sdlHr66aeTMjAlQaklS5bgmmuuidrv+OGHHxAMBvH444+jT58+SFSBQADnnHMO3n33XRx88MHq+Zag1M8//4xJkybhvffew7fffov27dvHe1PRtm1bFTxr6JFHHsHGjRvx6KOPbnfbr7/+OsZbSERERAxKERERUSNGo5GPSIyVlZWpj7Eu22uuKVOmqIDUDTfcgKlTp9Zff9lll+H//u//cMopp6iMry+++CKm2+VyuVRwrCGLxYLzzjuv0XVvv/02qqurt7ueiIiI4oPle0RERCnil19+wYgRI2AymVSZ2LPPPrvD223bU8rn86ksmL59+6p/W1hYiIMOOgjffPON+r7cVrKkRMOSqDoPP/wwDjzwQPXvMjMzMWzYMLz//vvb/V75N+PHj8dHH32EwYMHq+DYoEGD8OWXX253202bNmHs2LHo1KmTul3Pnj1xxRVXwOv11t/GarWq7KauXbuq20gG0kMPPaQykppKegx99tln2LBhQ/39ath7SYJJsh2SGSSPzZ577olXX30VzSE/76677qrP2JHf0TDjbPr06epxkPsg93fcuHHqvm1LspTksZXHuE2bNirwIo/TtuoeX9le+Thr1qwmbWdtba0KRPXr1w8PPvjgdt8/8cQTccEFF6jn69dff1XXnXDCCejVq9cOf94BBxyA4cOHN7rujTfeqL8PBQUFOOuss1BcXLzdcyLbPX/+fFVCKMGoW2+9FZHuKSXZa/JcSBBOXv+dO3dGdnY2Tj/9dNhsNng8HvX6ateuHbKysnDRRRep67bVlPtERESUqpgpRURElAIWL16Mo446SgU9JODh9/tVIKQpZVZyewlCXHLJJdh3331ht9vx559/4q+//sKRRx6Jyy+/HJs3b1ZBqm3LpYSUpJ100kk499xzVdBIslXOOOMMfPrppzj++OO3C5x9+OGHuPLKK1UA4IknnsDo0aNRVFSkglpCfpdshwRmJENHmoNL8EUCXZIxk5GRoT4eeuih6nrZvm7dumHu3LmYOHEitmzZ0uQeUbfddpsKQDQs+ZIARF2QRoIYq1evVsE0CYxJYEiCdLJtV199dZN+h2zLa6+9poJDzzzzjPr5Q4cOrX/sJSAyatQoFXST0kq5zR9//IE5c+aopujilVdeUUERCTrKc1VaWqoed7nNggUL6jOwpERNHs+BAweq21VWVqp/16VLl91upzw3kmUk90uv3/Eh5JgxY/Dyyy+r53b//ffHmWeeqa6T7ZVtqyNBPglcNcy2uv/++3HHHXeojCt5rZWXl+PJJ59UgaeG90HIdh977LEqwCPBt2iWC8rjJAGlW265RT3Xsk3yuEuJqzwe8hzJfZHnQF4Dd955Z4vuExERUUoKERERUdI75ZRTQiaTKbRhw4b665YtWxbS6XShbQ8HunfvHrrgggvqv95zzz1Dxx9//C5//rhx47b7OXVcLlejr71eb2jw4MGhww8/vNH18u8zMjJCq1evrr9u0aJF6vonn3yy/roxY8aE0tPTQ3/88cd2vysYDKqP9957b8hisYRWrlzZ6Pu33HKLus9FRUWhppL7Lo/Jth577DG1bW+88Uaj+3bAAQeEsrKyQna7vcm/46677lI/q7y8vP66srIy9XgcddRRoUAgUH/9U089pW770ksv1f/Odu3aqce0tra2/naffvqput2dd95Zf91ee+0V6tixY8hqtdZf9/XXX6vb7eg+7uj+zpo1a6e3qaqqUrc57bTT1Nc2my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G0JjxoxRv09+rtwf+bcej6f+Ng6HIzRx4sRQnz591H1u06ZN6MADDww9/PDDjbZ9d5xOZ+icc85R91+2UbanTmlpaeiiiy5SP1t+x5AhQ9T9a666x6O8vHy77z311FPqcTMYDKH27duHrrjiilB1dfV2t3vnnXdCe++9t3o8CgoKQueee25o48aN293ugw8+CA0YMEDdbuDAgaEPP/xQPb4N79euBAIBdR9HjhwZysnJCZlMptCgQYNCkyZNUo/Vzsj2yH0cNWrUTm8j23bQQQeFLBaLusj9lud1xYoV9bc59NBD1e9rieOPP36n91N+rlzqfP/992p733vvvUa3k/su1//xxx9Neg6bcp+IiIhSVZr8L/KhLiIiIiIiIiIiop1jTykiIiIiIiIiIoo59pQiIiKilCT9lGSS3c5I7yPp65Tov4OIiIhIq1i+R0RERClJmrf/+OOPO/1+9+7dVYPqRP8dRERERFrFoBQRERGlJJmYV11dvdPvy1S5kSNHJvzvICIiItIqBqWIiIiIiIiIiCjm2OiciIiIiIiIiIhijo3OAQSDQWzevBnZ2dlIS0uL/bNARERERERERJQkQqEQHA4HOnXqhPT0nedDMSgFqIBU165dY/n8EBERERERERElteLiYnTp0mWn32dQClAZUnUPVk5OTuyeHSIiIiIiIiKiJGO321XyT128ZWcYlJJu7/+W7ElAikEpIiIiIiIiIqLW212LpLg2Or/77rvVBja89O/fv/77brcb48aNQ2FhIbKysjB69GiUlpY2+hlFRUU4/vjjYTab0a5dO9x4443w+/1xuDdERERERERERNRUcc+UGjRoEL799tv6r/X6rZt07bXX4rPPPsN7772H3NxcjB8/HqeddhrmzJmjvh8IBFRAqkOHDpg7dy62bNmCMWPGwGAw4IEHHojL/SEiIiIiIiIiIg0EpSQIJUGlbdlsNrz44ouYOXMmDj/8cHXdyy+/jAEDBuDXX3/F/vvvj6+//hrLli1TQa327dtjr732wr333oubb75ZZWFlZGTE4R4REREREREREdHuxLV8T6xatUqNCOzVqxfOPfdcVY4n5s+fD5/Ph1GjRtXfVkr7unXrhnnz5qmv5eOQIUNUQKrO0UcfrRpqLV26dKe/0+PxqNs0vBARERERERERUYoEpfbbbz+88sor+PLLL/HMM89g3bp1OPjgg+FwOFBSUqIynfLy8hr9GwlAyfeEfGwYkKr7ft33dubBBx9U5YB1F+kIT0REREREREREKVK+d+yxx9Z/PnToUBWk6t69O959911kZmZG7fdOnDgR11133XajComIiIiIiIiIKEXK9xqSrKh+/fph9erVqs+U1+uF1WptdBuZvlfXg0o+bjuNr+7rHfWpqmM0GpGTk9PoQkREREREREREKRqUcjqdWLNmDTp27Ihhw4apKXqzZ8+u//6KFStUz6kDDjhAfS0fFy9ejLKysvrbfPPNNyrINHDgwLjcByIiIiIiIiIiSvDyvRtuuAEnnniiKtnbvHkz7rrrLuh0Opx99tmq19PYsWNVmV1BQYEKNE2YMEEFomTynjjqqKNU8On888/HlClTVB+p22+/HePGjVPZUERERERERERElJjiGpTauHGjCkBVVlaibdu2OOigg/Drr7+qz8Wjjz6K9PR0jB49Wk3Mk8l606dPr//3EsD69NNPccUVV6hglcViwQUXXIB77rknjveKiIiIiIiIiIh2Jy0UCoWQ4qTRuWRm2Ww29pciIiIiIiIiIopBnCWhekoRETWFxNJXlznhDwT5gBEREREREWkUg1JEpDnLtziwvqIG/5Q44r0pRERERERE1EIMShGRpizbbMdma636vMTmVhciIiIiIiLSHgaliEgzlm/ZGpCq80+JHW5fIG7bRERERERERC3DoBQRaYIEnzZVNw5ICX8ghKWbbarPFBElv+oaLwPRRERERElCH+8NICJqSkBqY9X2Aak61TU+bKh0oUcbCx9MoiQUDIZQ6nCjqNIFh9uPfEsGhnXPj/dmEREREVErMShFRAltRYljlwGpOmsrnCjIykCOyRCT7SLSkrpMwrS0NGiJ1x/EJmstNla74PEFG2VLbaisQfdCBqKJiIiItIxBKSJKWCtLHSiucjXptsEgsGSTDfv1LIQuXVsn3kTRzjJastmmAjwDO+XAnJH4u/4ajx9FVS41yCAQ3HFp7ppyJwosGchmIJqIiIhIs9hTiogS0uoyhyrVaQ6XJ4BVZY6obROR1vgDQSw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FKz093frb3/4W2OaJJ54wf+ffeOMNa+PGjdY3vvENq3///lZjY2Ngm6997WvWqFGjrI8//tj66KOPzKqT06ZNi9B3hVhz2223WX369LHefvttq7y83Hr11VetvLw862c/+1lgG8YpIrXK7n//+19z07e7Tz/9tPnYv2pZOMalrtiXn59vzZgxw9q8ebN5L6bH6WeffTYi3zNia5y2tLRYN9xwg1VcXGzeEwW/twpeSS9WximhVAyZP3++ecOfnJxsjR8/3lq9enWkdwlxRA+mnd3++te/BrbRP/Z33XWXWZpUD4g33XSTObgG27NnjzVlyhQrLS3NnNzee++9VmtrawS+I8RjKMUYhVO89dZbJqTXC05lZWXWokWLQl7XZc3nzJljTjZ1m0mTJlk7duwI2ebYsWPm5DQzM9Pyer3W7bffbk6CgXCoqakxx08990xNTbUuuugi6xe/+EXIGybGKSJhxYoVnZ6TapAaznG5YcMGa+LEieZzaECrYRcQjnFaXl7e5Xsr/XexNk5d+p9IV2sBAAAAAAAgvtBTCgAAAAAAALYjlAIAAAAAAIDtCKUAAAAAAABgO0IpAAAAAAAA2I5QCgAAAAAAALYjlAIAAAAAAIDtCKUAAAAAAABgO0IpAAAAAAAA2I5QCgAAoBPf/e535cYbb4yan01paan87ne/69bn+PDDD8Xlckl1dXXY9gsAAKArhFIAACDuaPByptvDDz8sv//972Xx4sW27lddXZ0kJSXJkiVLQp6/9dZbzX7t2bPntCBqzpw55uO1a9fKzJkzbd1fAACA7iCUAgAAcefQoUOBm1YXeb3ekOfuu+8+8fl8kpWVZet+ZWZmytixY03FUjB9XFJSEvJ8eXm57N27V77yla+Yx7169ZL09HRb9xcAAKA7CKUAAEDcKSgoCNw0fNIqpODnNBw6dfrel770JfnRj34ks2fPluzsbMnPz5fnnntO6uvr5fbbbxePxyMXX3yxLFu2LORrbd68WaZMmWI+p/6bGTNmyNGjR7vcty9/+csh4dO2bdukqalJ7rzzzpDn9eOUlBSZMGFCp9P39Hv685//LDfddJMJqwYOHChvvvlmyNd65513ZNCgQZKWlma+7qmVWO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9Of+uKTtPT1e7mz58fUmk0fvx4M/3ujTfeOOvUvbO54447TPB1//33m8bqGoD5G5j7aX+o999/Xx555BHTA0sbvWufrPvuuy9kiqCuRqj/PjiU0pX4dBrfqdP/AAAA/AilAAAAekhRUZGpFtIASlfm0/5Ts2fPlqysLHG7uz4N0wbql19+udTW1oZUGmlQ5X++u6FU37595ZVXXjHhkTZwX7hwoWmGfmql18svvyxLliwxTc21kftvfvObkIboOiXwqquuMvda1eUPqnQa39ixY89YEQYAAOKby7IsK9I7AQAAAAAAgPhCpRQAAAAAAABsRygFAAAAAAAA2xFKAQAAAAAAwHaEUgAAAAAAALAdoRQAAAAAAABsRygFAAAAAAAA2xFKAQAAAAAAwHaEUgAAAAAAALAdoRQAAAAAAABsRygFAAAAAAAA2xFKAQAAAAAAwHaEUgAAAAAAABC7/R/DexTC9jqEZgAAAABJRU5ErkJggg==", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# Get time series of extended properties (windowed)\n", + "if len(props) > 0:\n", + " property_id = props.iloc[0][\"property_id\"]\n", + "\n", + " timeseries = query.get_extended_properties_timeseries(\n", + " episode_id=episode_id, window_size=10, property_ids=[property_id]\n", + " )\n", + "\n", + " if len(timeseries) > 0:\n", + " fig, ax = plt.subplots(figsize=(12, 4))\n", + " ax.fill_between(\n", + " timeseries[\"time_window\"],\n", + " timeseries[\"avg_value\"] - timeseries[\"std_value\"],\n", + " timeseries[\"avg_value\"] + timeseries[\"std_value\"],\n", + " alpha=0.3,\n", + " )\n", + " ax.plot(timeseries[\"time_window\"], timeseries[\"avg_value\"], \"b-\")\n", + " ax.set_xlabel(\"Time Window\")\n", + " ax.set_ylabel(property_id)\n", + " ax.set_title(f\"{property_id} Over Time\")\n", + " plt.tight_layout()\n", + " plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Cleanup" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2026-02-23 15:30:10 | INFO | collab_env.data.db.query_backend:close:91 - Closing database connection...\n", + "2026-02-23 15:30:10 | INFO | collab_env.data.db.db_loader:close:231 - Database connection closed\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Connection closed\n" + ] + } + ], + "source": [ + "# Close database connection\n", + "query.close()\n", + "print(\"Connection closed\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Troubleshooting\n", + "\n", + "### \"Connection refused\" error\n", + "- Make sure Cloud SQL Proxy is running in another terminal\n", + "- Check that port 5433 is not in use: `lsof -i :5433`\n", + "\n", + "### \"Permission denied\" for secrets\n", + "- Run `gcloud auth application-default login`\n", + "- Verify project: `gcloud config get-value project`\n", + "\n", + "### Package import errors\n", + "- Ensure you installed from the correct branch:\n", + " ```bash\n", + " pip install \"collab-env[db] @ git+https://github.com/BasisResearch/collab-environment.git@db-eda-dashboard\"\n", + " ```" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.19" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/docs/data/db/schema.md b/docs/data/db/schema.md new file mode 100644 index 00000000..e45e5509 --- /dev/null +++ b/docs/data/db/schema.md @@ -0,0 +1,415 @@ +# Tracking Analytics Database Schema + +## Overview + +PostgreSQL-based database schema for unified time-series animal tracking data from three sources: + +1. **3D Boids Simulations**: Parquet files from `collab_env.sim.boids` +2. **2D Boids Simulations**: PyTorch `.pt` datasets from `collab_env.sim.boids_gnn_temp` +3. **Real-World Tracking**: CSV files from `collab_env.tracking` video analysis + +**Version**: 1.0 +**Database**: PostgreSQL (can be ported to DuckDB) + +## Schema Design + +### Core Principle: EAV with Flat Property List + +- **Core observations**: Positions and velocities in main `observations` table (universal data only) +- **Extended properties**: Flexible EAV (Entity-Attribute-Value) pattern for all other data +- **Flat property definitions**: All properties in a simple list, no categorization +- **Property discovery**: Query what actually exists in the data, not what's defined +- **No hardcoded columns**: All extended properties defined in `property_definitions` table + +### Entity-Relationship Structure + +``` +categories (session data source types only) + └─> sessions (ON DELETE CASCADE) + └─> episodes (ON DELETE CASCADE) + └─> observations (PK: episode_id, time_index, agent_id, agent_type_id) (ON DELETE CASCADE) + └─> extended_properties (PK: observation_id, property_id) (ON DELETE CASCADE) + +agent_types + └─> observations (FK: agent_type_id) + +property_definitions (flat list) + └─> extended_properties (FK: property_id) +``` + +**Cascading Deletes**: Deleting a category, session, or episode automatically deletes all child records. See [cascading_deletes.md](../docs/data/db/cascading_deletes.md) for details and safety guidelines. + +## Quick Start + +### 1. Initialize Database + +```bash +# Using the unified Python script (PostgreSQL or DuckDB) +source .venv-310/bin/activate + +# For DuckDB (local analytics) +python -m collab_env.data.init_database --backend duckdb --dbpath tracking.duckdb + +# For PostgreSQL (requires running server) +python -m collab_env.data.init_database --backend postgres + +# Or manually with psql +createdb tracking_analytics +psql tracking_analytics < schema/01_core_tables.sql +psql tracking_analytics < schema/02_extended_properties.sql +psql tracking_analytics < schema/03_seed_data.sql +``` + +### 2. Verify Setup + +```bash +# PostgreSQL +psql tracking_analytics + +tracking_analytics=# \dt +# Should show: sessions, episodes, agent_types, observations, +# categories, property_definitions, extended_properties + +tracking_analytics=# SELECT * FROM categories; +# Should show: boids_3d, boids_2d, tracking_csv + +# DuckDB +duckdb tracking.duckdb + +D> SHOW TABLES; +D> SELECT * FROM categories; +``` + +### 3. Connect Grafana + +1. Add PostgreSQL data source in Grafana +2. Connection string: `host=localhost dbname=tracking_analytics user=youruser` +3. Use example queries from `04_views_examples.sql` + +## Schema Files + +| File | Purpose | Required | +|------|---------|----------| +| `01_core_tables.sql` | Dimension and fact tables | Yes | +| `02_extended_properties.sql` | EAV schema for flexible properties | Yes | +| `03_seed_data.sql` | Default agent types and property definitions | Yes | +| `04_views_examples.sql` | Example queries and view templates | No (reference) | + +## Table Descriptions + +### Dimension Tables + +#### `sessions` +Top-level container for related episodes (simulation run or fieldwork session). + +**Primary Key**: `session_id` VARCHAR + +**Columns**: +- `session_name`: Human-readable name +- `category_id`: Data source type (boids_3d, boids_2d, tracking_csv) - references categories table +- `config`: Full configuration as JSONB +- `metadata`: Additional metadata (environment, mesh paths, notes) + +#### `episodes` +Single simulation run or video tracking session. + +**Primary Key**: `episode_id` VARCHAR + +**Columns**: +- `session_id`: Foreign key to parent session +- `episode_number`: Sequence number within session +- `num_frames`: Total timesteps/frames +- `num_agents`: Number of agents/tracks +- `frame_rate`: Frames per second (default 30) +- `file_path`: Original source file + +#### `agent_types` +Agent/track type definitions. + +**Primary Key**: `type_id` VARCHAR + +**Examples**: agent, target, bird, rat, gerbil + +### Fact Tables + +#### `observations` +Core time-series data: positions and velocities. + +**Primary Key**: Composite `(episode_id, time_index, agent_id)` +**Surrogate Key**: `observation_id` BIGSERIAL (for foreign key references) + +**Core Columns**: +- `x, y, z`: Spatial coordinates (z NULL for 2D) +- `v_x, v_y, v_z`: Velocity components (may be NULL) + +**Note**: Tracking metadata (confidence, detection_class) moved to extended_properties table + +**Why composite PK?** +- Ensures uniqueness: One observation per (episode, time, agent) +- Natural query pattern: Filter by episode and time +- observation_id available for FK references + +### Extended Properties (EAV) + +#### `property_definitions` +Defines all available extended properties. + +**Columns**: +- `property_id`: Unique identifier +- `property_name`: Display name +- `data_type`: float, vector, string +- `unit`: Measurement unit (scene_units, pixels, m/s^2, etc.) + +**Examples**: +- `distance_to_target_center`: Distance to target +- `bbox_x1, bbox_y1, bbox_x2, bbox_y2`: Bounding boxes +- `acceleration_x, acceleration_y`: Computed accelerations +- `confidence`: Detection confidence (tracking data) +- `detection_class`: Detected object class (tracking data) + +#### `extended_properties` +EAV table storing property values. + +**Primary Key**: Composite `(observation_id, property_id)` + +**Columns**: +- `value_float`: For numeric properties +- `value_text`: For strings, arrays (JSON), etc. + +## Query Patterns + +### 1. Get Available Properties for a Session (Property Discovery) + +```sql +-- Discover which properties actually exist for a session +SELECT DISTINCT + pd.property_id, + pd.property_name, + pd.unit +FROM property_definitions pd +WHERE pd.property_id IN ( + SELECT DISTINCT ep.property_id + FROM extended_properties ep + JOIN observations o ON ep.observation_id = o.observation_id + JOIN episodes e ON o.episode_id = e.episode_id + WHERE e.session_id = 'session-...' +); +``` + +### 2. Query Observations with Extended Properties + +```sql +-- EAV format (property_name in rows) +SELECT + o.time_index, + o.agent_id, + o.x, o.y, o.z, + pd.property_name, + ep.value_float as property_value +FROM observations o +JOIN extended_properties ep ON o.observation_id = ep.observation_id +JOIN property_definitions pd ON ep.property_id = pd.property_id +WHERE o.episode_id = 'episode-0-...' +ORDER BY o.time_index, o.agent_id, pd.property_name; +``` + +### 3. Pivot Properties to Columns + +```sql +-- Denormalized format (properties as columns) +SELECT + o.time_index, + o.agent_id, + o.x, o.y, o.z, + MAX(CASE WHEN ep.property_id = 'distance_to_target_center' THEN ep.value_float END) as distance_to_target, + MAX(CASE WHEN ep.property_id = 'speed' THEN ep.value_float END) as speed +FROM observations o +LEFT JOIN extended_properties ep ON o.observation_id = ep.observation_id +WHERE o.episode_id = 'episode-0-...' +GROUP BY o.observation_id, o.time_index, o.agent_id, o.x, o.y, o.z; +``` + +### 4. Spatial Heatmap + +```sql +SELECT + floor(x / 10) * 10 as x_bin, + floor(y / 10) * 10 as y_bin, + count(*) as density +FROM observations +WHERE episode_id = 'episode-0-...' + AND time_index BETWEEN 500 AND 1000 +GROUP BY x_bin, y_bin; +``` + +### 5. Time-Series for Grafana + +```sql +-- Speed over time +SELECT + to_timestamp(o.time_index * (1.0 / e.frame_rate)) as time, + sqrt(o.v_x*o.v_x + o.v_y*o.v_y + COALESCE(o.v_z*o.v_z, 0)) as speed +FROM observations o +JOIN episodes e ON o.episode_id = e.episode_id +WHERE o.episode_id = $episode_id +ORDER BY o.time_index; +``` + +See `04_views_examples.sql` for more query templates. + +## Session Categories Reference + +Categories define data source types (used only for `sessions.category_id`): + +### boids_3d +3D boid simulation sessions. Common properties include: +- `distance_to_target_center` +- `distance_to_target_mesh` +- `distance_to_scene_mesh` +- `target_mesh_closest_x/y/z` +- `scene_mesh_closest_x/y/z` +- Computed: `speed`, `acceleration_x/y/z` + +### boids_2d +2D boid simulation sessions. Common properties include: +- Computed: `speed`, `acceleration_x/y` + +### tracking_csv +Real-world tracking sessions from video data. Common properties include: +- `bbox_x1, bbox_y1, bbox_x2, bbox_y2` (bounding boxes) +- `confidence` (detection confidence) +- `detection_class` (object class label) + +## Adding New Properties + +### Example: Add a new property "distance_to_boundary" + +```sql +-- 1. Define the property +INSERT INTO property_definitions (property_id, property_name, data_type, description, unit) +VALUES ('distance_to_boundary', 'Distance to Boundary', 'float', 'Minimum distance to any boundary', 'scene_units'); + +-- 2. Insert values (during data loading) +INSERT INTO extended_properties (observation_id, property_id, value_float) +SELECT observation_id, 'distance_to_boundary', computed_distance_value +FROM observations o +WHERE ...; + +-- 3. Discover where it's used +SELECT DISTINCT s.session_name, s.category_id +FROM sessions s +JOIN episodes e ON s.session_id = e.session_id +JOIN observations o ON e.episode_id = o.episode_id +JOIN extended_properties ep ON o.observation_id = ep.observation_id +WHERE ep.property_id = 'distance_to_boundary'; +``` + +## Performance Considerations + +### Indexes + +Current indexes (bare-bones): +- `observations(episode_id, time_index)` - Time-slice queries +- `observations(episode_id)` - Episode scans +- `extended_properties(observation_id)` - Property lookups +- `extended_properties(property_id)` - Property-centric queries + +### Query Optimization Tips + +1. **Always filter by episode_id**: Uses primary index +2. **Limit property pivoting**: Only pivot properties you need +3. **Use CTEs for complex queries**: Improves readability and may help planner +4. **Consider materialized views**: For frequently-accessed aggregations + +### Materialized Views (Optional) + +For common query patterns, create materialized views: + +```sql +CREATE MATERIALIZED VIEW boids_3d_flat AS +SELECT + o.*, + MAX(CASE WHEN ep.property_id = 'distance_to_target_center' THEN ep.value_float END) as distance_to_target +FROM observations o +LEFT JOIN extended_properties ep ON o.observation_id = ep.observation_id +GROUP BY o.observation_id, ... (all columns); + +CREATE INDEX ON boids_3d_flat(episode_id, time_index); + +-- Refresh after loading new data +REFRESH MATERIALIZED VIEW boids_3d_flat; +``` + +## Migration to DuckDB + +To use DuckDB instead of PostgreSQL: + +1. Convert data types: + - `BIGSERIAL` → `BIGINT AUTO_INCREMENT` + - `DOUBLE PRECISION` → `DOUBLE` + - `JSONB` → `JSON` + +2. DuckDB can query PostgreSQL directly: + ```sql + INSTALL postgres; + LOAD postgres; + SELECT * FROM postgres_scan('postgresql://...', 'observations'); + ``` + +3. Or export/import via parquet: + ```sql + -- PostgreSQL: Export + COPY observations TO '/tmp/observations.parquet' (FORMAT parquet); + + -- DuckDB: Import + CREATE TABLE observations AS SELECT * FROM '/tmp/observations.parquet'; + ``` + +## Troubleshooting + +### Issue: UNIQUE constraint violation on observations PK + +**Cause**: Duplicate (episode_id, time_index, agent_id) in source data + +**Solution**: Check source parquet/CSV for duplicates before loading + +### Issue: Slow queries on extended_properties + +**Cause**: Large number of properties per observation + +**Solutions**: +1. Filter by property_id in WHERE clause +2. Create materialized view for specific category +3. Add index on (property_id, observation_id) if querying by property first + +### Issue: NULL observation_id in extended_properties + +**Cause**: Inserting extended properties before observations + +**Solution**: Load in correct order: sessions → episodes → observations → extended_properties + +## Implementation Status + +### Complete ✅ + +1. **Data Ingestion**: `collab_env/data/db_loader.py` + - 3D Boids: Parquet files with extended properties + - 2D Boids: PyTorch .pt files with velocity computation + - Multi-session bulk loading with single transaction +2. **Query Interface**: `collab_env/data/db/query_backend.py` (see [docs/data/db/README.md](../docs/data/db/README.md)) +3. **Grafana Dashboards**: Time-series visualizations with query library (see [docs/dashboard/grafana/](../docs/dashboard/grafana/)) +4. **Cascading Deletes**: Automatic cleanup on PostgreSQL (DuckDB limitation documented) + +### TODO ⏳ + +1. **Tracking CSV Loader**: Real-world video tracking data ingestion +2. **Computed Properties**: Pipeline to compute accelerations, speeds +3. **Pairwise Interactions**: Implement if needed (commented out in design) +4. **PostgreSQL COPY**: 10-100x faster bulk loading (see [data_loader_plan.md](../docs/data/db/data_loader_plan.md)) + +## References + +- **data_formats.md**: Source format documentation +- **spatial_analysis.md**: Analytics requirements +- **db_layer_todo.md**: Implementation tasks +- [PostgreSQL Documentation](https://www.postgresql.org/docs/) diff --git a/docs/data/db/testing_safety.md b/docs/data/db/testing_safety.md new file mode 100644 index 00000000..d5fadc8c --- /dev/null +++ b/docs/data/db/testing_safety.md @@ -0,0 +1,203 @@ +# Testing Safety Guidelines + +## 🚨 CRITICAL: Database Safety + +**NEVER run tests against production databases!** + +Tests will: +- Drop ALL tables with CASCADE +- Delete ALL data +- Recreate schema from scratch + +## Test Database Setup + +### PostgreSQL Test Database + +**Required:** Database name MUST end with `_test` + +```bash +# Create dedicated test database +createdb tracking_analytics_test + +# Set environment variables for testing +export POSTGRES_DB=tracking_analytics_test +export POSTGRES_USER=your_user +export POSTGRES_PASSWORD=your_password +export POSTGRES_HOST=localhost +export POSTGRES_PORT=5432 +``` + +### Safety Checks + +The test fixtures include safety checks that will **refuse to run** if: + +1. Database name is in the forbidden list: + - `tracking_analytics` (production) + - `production` + - `prod` + - `main` + +2. Database name doesn't end with `_test` + +**Example error:** +``` +SKIPPED [1] tests/db/conftest.py:87: SAFETY: Database name 'tracking_analytics' must end with '_test'. +Example: tracking_analytics_test. +This prevents accidentally running destructive tests on production. +``` + +### DuckDB + +DuckDB tests automatically use temporary files - no production risk. + +## Running Tests Safely + +### 1. Check Your Environment + +```bash +# Verify test database is configured +echo $POSTGRES_DB +# Should output: tracking_analytics_test (or similar with _test suffix) + +# NOT: tracking_analytics, production, etc. +``` + +### 2. Create Test Database + +```bash +# PostgreSQL +createdb tracking_analytics_test + +# Grant permissions if needed +psql -d tracking_analytics_test -c "GRANT ALL PRIVILEGES ON SCHEMA public TO your_user;" +``` + +### 3. Run Tests + +```bash +# Run all database tests +pytest tests/db/ -v + +# Run specific test file +pytest tests/db/test_2d_boids_loader.py -v + +# Run only DuckDB tests (no PostgreSQL setup needed) +pytest tests/db/ -v -k duckdb +``` + +## What Tests Do + +### Setup (per test) +1. Connect to database +2. **DROP ALL TABLES** with CASCADE +3. Recreate schema from SQL files +4. Insert seed data + +### Test Execution +1. Load test data +2. Verify data +3. Test functionality + +### Cleanup (per test) +1. Delete test data +2. Tables remain for next test + +## Production Safety Checklist + +- [ ] Test database name ends with `_test` +- [ ] Test database is separate from production +- [ ] Production credentials are NOT in test environment +- [ ] `.env` file has test database configuration +- [ ] CI/CD uses separate test database + +## Example .env for Testing + +```bash +# Production database (read-only for analysis) +POSTGRES_DB=tracking_analytics +POSTGRES_USER=readonly_user +POSTGRES_PASSWORD=*** +POSTGRES_HOST=production.example.com + +# Test database (for pytest) +TEST_POSTGRES_DB=tracking_analytics_test +TEST_POSTGRES_USER=test_user +TEST_POSTGRES_PASSWORD=*** +TEST_POSTGRES_HOST=localhost +``` + +## Common Mistakes to Avoid + +❌ **DON'T:** +```bash +# Running tests with production DB +export POSTGRES_DB=tracking_analytics +pytest tests/db/ # DANGEROUS! +``` + +✅ **DO:** +```bash +# Always use test database +export POSTGRES_DB=tracking_analytics_test +pytest tests/db/ # Safe +``` + +❌ **DON'T:** +```bash +# Testing on main production database +POSTGRES_DB=production pytest tests/db/ +``` + +✅ **DO:** +```bash +# Use dedicated test database +POSTGRES_DB=myapp_test pytest tests/db/ +``` + +## CI/CD Configuration + +Ensure your CI/CD pipeline uses test databases: + +```yaml +# GitHub Actions example +env: + POSTGRES_DB: tracking_analytics_test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_HOST: localhost + +services: + postgres: + image: postgres:16 + env: + POSTGRES_DB: tracking_analytics_test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres +``` + +## Recovery from Mistakes + +If you accidentally ran tests on production: + +1. **Stop immediately** - Don't run more tests +2. **Restore from backup** - Use your most recent backup +3. **Review environment** - Check `env` variables +4. **Update safety checks** - Add your DB name to forbidden list +5. **Test on test DB first** - Always verify configuration + +## Adding New Tests + +When writing new tests: + +1. Use the `backend_config` or `postgres_initialized` fixtures +2. Safety checks are automatic +3. Document any special database requirements +4. Test on test database first +5. Never hardcode production credentials + +## Questions? + +- "Can I skip the `_test` suffix?" - **NO.** This is a critical safety feature. +- "Can I use my production DB for read-only tests?" - **NO.** Tests drop tables. +- "What if I need real data?" - Export from production, import to test DB. +- "Can I disable safety checks?" - **NO.** They exist for a reason. diff --git a/pyproject.toml b/pyproject.toml index 653cf404..1596750e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ dependencies = [ "seaborn", "plotly", "ultralytics", + "lap>=0.5.12", "dotenv", "jupyterlab", "ipywidgets", @@ -58,11 +59,12 @@ dependencies = [ "importlib-metadata" ] -[tool.setuptools] # NEW +[tool.setuptools] packages = [ "collab_env.alignment", - "collab_env.dashboard", + "collab_env.dashboard", "collab_env.data", + "collab_env.data.db", "collab_env.gnn", "collab_env.sim", "collab_env.sim.boids", @@ -72,9 +74,24 @@ packages = [ "collab_env.tracking", "collab_env.tracking.model", "collab_env.utils" +] + +[tool.setuptools.package-data] +"collab_env.data.db" = [ + "queries/*.sql", + "schema/*.sql", +] +"collab_env.dashboard" = [ + "templates/*.html", + "static/js/**/*.js", ] [project.optional-dependencies] +db = [ + "aiosql<14", + "sqlalchemy", + "psycopg2" +] docs = [ "setuptools", "sphinx", @@ -84,6 +101,12 @@ docs = [ "nbsphinx", ] dev = [ + "aiosql<14", + "sqlalchemy", + "psycopg2", + "duckdb-engine", + "holoviews", + "bokeh", "setuptools", "sphinx", "sphinxcontrib-bibtex", @@ -103,6 +126,17 @@ dev = [ "types-PyYAML", ] +db-dashboard = [ + "aiosql<14", + "sqlalchemy", + "psycopg2", + "panel", + "param", + "holoviews", + "bokeh", + "plotly", +] + [build-system] requires = ["setuptools<70.0"] build-backend = "setuptools.build_meta" diff --git a/requirements-db.txt b/requirements-db.txt new file mode 100644 index 00000000..ebc36e44 --- /dev/null +++ b/requirements-db.txt @@ -0,0 +1,30 @@ +# Database requirements for tracking analytics +# Install: pip install -r requirements-db.txt + +# Unified database interface +sqlalchemy>=2.0.0 + +# PostgreSQL adapter for SQLAlchemy +psycopg2-binary>=2.9.0 + +# DuckDB and SQLAlchemy dialect +duckdb>=1.0.0 +duckdb-engine>=0.12.0 + +# Data handling +pandas>=2.0.0 +pyarrow>=14.0.0 +pyyaml>=6.0.0 + +# SQL query management +aiosql>=9.0,<14 + +# Dashboard and visualization (for spatial_analysis_gui) +panel>=1.3.0 +holoviews>=1.18.0 +bokeh>=3.3.0 +plotly>=5.18.0 + +# Optional: Advanced data loading tools +dlt[duckdb,postgres]>=1.0.0 +ibis-framework[duckdb,postgres]>=9.0.0 diff --git a/scripts/analysis_dashboard.sh b/scripts/analysis_dashboard.sh new file mode 100755 index 00000000..e5f6f180 --- /dev/null +++ b/scripts/analysis_dashboard.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# source $(dirname $0)/deploy/config.sh + +panel serve collab_env/dashboard/spatial_analysis_app.py --dev --show --port 5008 --static-dirs dashboard-static=collab_env/dashboard/static \ No newline at end of file diff --git a/scripts/deploy/Dockerfile.dashboard b/scripts/deploy/Dockerfile.dashboard new file mode 100644 index 00000000..a5ada3df --- /dev/null +++ b/scripts/deploy/Dockerfile.dashboard @@ -0,0 +1,43 @@ +FROM python:3.10-slim + +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + libpq-dev \ + git \ + && rm -rf /var/lib/apt/lists/* + +# Install uv +RUN pip install uv + +# Copy application code first (needed for pyproject.toml) +COPY collab_env/ /app/collab_env/ +COPY schema/ /app/schema/ +COPY pyproject.toml . +COPY README.rst . + +# Install dependencies with uv +COPY requirements-db.txt . +RUN uv pip install --system --no-cache -r requirements-db.txt + +# Install package in editable mode with uv +RUN uv pip install --system --no-cache -e . + +# Environment +ENV PORT=8080 +ENV PYTHONUNBUFFERED=1 + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ + CMD python -c "import requests; requests.get('http://localhost:8080/', timeout=5)" || exit 1 + +# Run dashboard +# Use wildcard for Cloud Run deployment (per Panel docs) +CMD panel serve collab_env/dashboard/spatial_analysis_app.py \ + --address 0.0.0.0 \ + --port ${PORT} \ + --allow-websocket-origin="*" \ + --num-threads 4 \ + --static-dirs dashboard-static=collab_env/dashboard/static diff --git a/scripts/deploy/README.md b/scripts/deploy/README.md new file mode 100644 index 00000000..36254de0 --- /dev/null +++ b/scripts/deploy/README.md @@ -0,0 +1,200 @@ +# Cloud Deployment Scripts + +Automated scripts for deploying the spatial analysis dashboard to Google Cloud Run with Cloud SQL. + +## Quick Start + +```bash +# 1. Configure project (edit if needed) +vim scripts/deploy/config.sh + +# 2. Create Cloud SQL instance (see caveat below) +./scripts/deploy/setup_cloud_sql.sh + +# 3. Start proxy, init database, and load data locally +./scripts/deploy/start_proxy.sh +# In another terminal: +source scripts/deploy/config.sh +python -m collab_env.data.db.init_database --backend postgres +python -m collab_env.data.db.db_loader --source boids2d --path simulated_data/boid_food_basic.pt + +# 4. Deploy dashboard to Cloud Run +./scripts/deploy/build_and_deploy.sh +``` + +## Scripts + +### Core Setup + +**`setup_cloud_sql.sh`** +- Creates Cloud SQL PostgreSQL 17 instance, database, and user +- Stores password in Secret Manager +- Grants IAM permissions (Cloud SQL Client role) +- One-time setup +- **Note:** The `gcloud sql instances create` command may fail; you may need to create the instance manually via the Cloud Console + +**`start_proxy.sh`** +- Starts Cloud SQL Auth Proxy on `PROXY_PORT` (default 5433) +- Requires `GOOGLE_APPLICATION_CREDENTIALS` to be set +- Run in a dedicated terminal; leave running during local dev + +### Deployment + +**`build_and_deploy.sh`** +- Submits build to Cloud Build via `cloudbuild.yaml` +- Grants IAM roles (Cloud Build -> Cloud Run admin, service account user, secret access) +- Grants public access (`allUsers` invoker role) to the Cloud Run service +- Use for initial deployment and updates + +**`cloudbuild.yaml`** +- Cloud Build configuration used by `build_and_deploy.sh` +- Builds Docker image from `Dockerfile.dashboard` +- Pushes to Google Container Registry (`gcr.io`) +- Deploys to Cloud Run with Cloud SQL connection and secrets + +### Configuration + +**`config.sh`** +- Centralized configuration sourced by all scripts +- Reads `PROJECT_ID` from `gcloud config` by default +- Fetches password from Secret Manager +- Sets all `POSTGRES_*` and `DB_*` environment variables for local use +- Edit to customize project, region, instance names, database tier, Cloud Run resources + +**`Dockerfile.dashboard`** +- Python 3.10 slim image +- Installs deps via `uv` from `requirements-db.txt` +- Runs `panel serve collab_env/dashboard/spatial_analysis_app.py` +- Used by `cloudbuild.yaml` + +## Typical Workflows + +### Initial Setup + +```bash +# One-time: create Cloud SQL instance +./scripts/deploy/setup_cloud_sql.sh + +# Start proxy (in a dedicated terminal) +./scripts/deploy/start_proxy.sh + +# In another terminal: init database and deploy +source scripts/deploy/config.sh +python -m collab_env.data.db.init_database --backend postgres +./scripts/deploy/build_and_deploy.sh +``` + +### Daily Development + +```bash +# Terminal 1: Start proxy +./scripts/deploy/start_proxy.sh + +# Terminal 2: Source config (sets all DB env vars) and work +source scripts/deploy/config.sh + +# Load data +python -m collab_env.data.db.db_loader --source boids2d --path simulated_data/boid_food_basic.pt + +# Run dashboard locally (proxy uses port 5433 by default) +panel serve collab_env/dashboard/spatial_analysis_app.py --show --dev + +# When done: Ctrl-C the proxy in Terminal 1 +``` + +### Update Deployment + +```bash +# After code changes +./scripts/deploy/build_and_deploy.sh +``` + +## Configuration + +Edit `scripts/deploy/config.sh` to customize. Defaults: + +```bash +# Google Cloud (PROJECT_ID reads from gcloud config by default) +export REGION="us-central1" +export INSTANCE_NAME="spatial-analysis-db" + +# Database +export DB_NAME="tracking_analytics" +export DB_USER="postgres" +export DB_TIER="db-g1-small" # or db-f1-micro for testing + +# Local proxy +export PROXY_PORT="5433" # avoids conflict with local postgres on 5432 + +# Cloud Run +export SERVICE_NAME="spatial-analysis-dashboard" +export MEMORY="5Gi" +export CPU="2" +export TIMEOUT="3600" +``` + +## Troubleshooting + +### Proxy won't connect + +```bash +# Check instance is running +gcloud sql instances describe spatial-analysis-db + +# Test proxy with verbose logging +cloud-sql-proxy PROJECT_ID:REGION:INSTANCE_NAME --verbose +``` + +### Cloud Run can't access database + +```bash +# Verify Cloud SQL connection +gcloud run services describe spatial-analysis-dashboard \ + --region us-central1 \ + --format="value(spec.template.spec.containers[0].env)" + +# Check logs +gcloud run logs read spatial-analysis-dashboard --limit 50 +``` + +### Password issues + +```bash +# Verify secret exists +gcloud secrets versions access latest --secret=postgres-password + +# Reset if needed +echo -n "new_password" | gcloud secrets versions add postgres-password --data-file=- +gcloud sql users set-password postgres --instance=spatial-analysis-db --password="new_password" +``` + +## Cost Management + +```bash +# Stop instance when not in use (saves ~$25/month) +gcloud sql instances patch spatial-analysis-db --activation-policy=NEVER + +# Restart when needed +gcloud sql instances patch spatial-analysis-db --activation-policy=ALWAYS + +# Use smaller tier for testing +# Edit config.sh: export DB_TIER="db-f1-micro" +``` + +## Clean Up + +```bash +# Delete Cloud Run service +gcloud run services delete spatial-analysis-dashboard --region us-central1 + +# Delete Cloud SQL instance (WARNING: destroys all data) +gcloud sql instances delete spatial-analysis-db + +# Delete secrets +gcloud secrets delete postgres-password +``` + +## See Also + +- [Complete Setup Guide](../../docs/dashboard/CLOUD_SETUP.md) +- [Database Documentation](../../docs/data/db/README.md) diff --git a/scripts/deploy/build_and_deploy.sh b/scripts/deploy/build_and_deploy.sh new file mode 100755 index 00000000..51e0bfe0 --- /dev/null +++ b/scripts/deploy/build_and_deploy.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# Build Docker image and deploy to Cloud Run + +set -e + +# Load configuration +source "$(dirname "$0")/config.sh" + +echo "==========================================" +echo "Build and Deploy to Cloud Run" +echo "==========================================" +echo "Project: ${PROJECT_ID}" +echo "Service: ${SERVICE_NAME}" +echo "Region: ${REGION}" +echo "Image: gcr.io/${PROJECT_ID}/spatial-dashboard" +echo "==========================================" +echo "" + +# Navigate to project root +cd "$(dirname "$0")/../.." + +# Get project number for service accounts +PROJECT_NUMBER=$(gcloud projects describe ${PROJECT_ID} --format="value(projectNumber)") + +# Ensure Cloud Build service account can deploy to Cloud Run +log_info "Ensuring Cloud Build can deploy to Cloud Run..." +gcloud projects add-iam-policy-binding ${PROJECT_ID} \ + --member="serviceAccount:${PROJECT_NUMBER}@cloudbuild.gserviceaccount.com" \ + --role="roles/run.admin" \ + --condition=None 2>/dev/null || log_warn "Cloud Build permission already granted" + +gcloud projects add-iam-policy-binding ${PROJECT_ID} \ + --member="serviceAccount:${PROJECT_NUMBER}@cloudbuild.gserviceaccount.com" \ + --role="roles/iam.serviceAccountUser" \ + --condition=None 2>/dev/null || log_warn "Service Account User permission already granted" + +# Ensure Cloud Run service account has secret access +log_info "Ensuring Cloud Run service account has secret access..." +gcloud secrets add-iam-policy-binding postgres-password \ + --member="serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com" \ + --role="roles/secretmanager.secretAccessor" \ + --project=${PROJECT_ID} \ + --condition=None 2>/dev/null || log_warn "Secret access already granted" + +# Build, push, and deploy (all in one step) +log_info "Building Docker image and deploying to Cloud Run..." +log_info "This will take 3-5 minutes..." + +gcloud builds submit \ + --config=scripts/deploy/cloudbuild.yaml \ + --project=${PROJECT_ID} + +# Explicitly grant public access (allUsers can invoke) +log_info "Ensuring public access to Cloud Run service..." +gcloud run services add-iam-policy-binding ${SERVICE_NAME} \ + --region=${REGION} \ + --member="allUsers" \ + --role="roles/run.invoker" \ + --project=${PROJECT_ID} 2>/dev/null || log_warn "Public access already granted" + +# Get service URL +SERVICE_URL=$(gcloud run services describe ${SERVICE_NAME} \ + --region ${REGION} \ + --project=${PROJECT_ID} \ + --format="value(status.url)") + +echo "" +echo "==========================================" +log_info "Deployment complete!" +echo "==========================================" +echo "" +echo "Dashboard URL: ${SERVICE_URL}" +echo "" +echo "Useful commands:" +echo " View logs: gcloud run services logs read ${SERVICE_NAME} --region ${REGION} --limit 50" +echo " Update: ./scripts/deploy/build_and_deploy.sh" +echo " Delete: gcloud run services delete ${SERVICE_NAME} --region ${REGION}" diff --git a/scripts/deploy/cloudbuild.yaml b/scripts/deploy/cloudbuild.yaml new file mode 100644 index 00000000..c0d10650 --- /dev/null +++ b/scripts/deploy/cloudbuild.yaml @@ -0,0 +1,45 @@ +steps: + # Build the container image + - name: 'gcr.io/cloud-builders/docker' + args: + - 'build' + - '-t' + - 'gcr.io/$PROJECT_ID/spatial-dashboard' + - '-f' + - 'scripts/deploy/Dockerfile.dashboard' + - '.' + + # Push the image to Container Registry + - name: 'gcr.io/cloud-builders/docker' + args: + - 'push' + - 'gcr.io/$PROJECT_ID/spatial-dashboard' + + # Deploy to Cloud Run + - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk' + entrypoint: gcloud + args: + - 'run' + - 'deploy' + - 'spatial-analysis-dashboard' + - '--image' + - 'gcr.io/$PROJECT_ID/spatial-dashboard' + - '--region' + - 'us-central1' + - '--platform' + - 'managed' + - '--memory' + - '5Gi' + - '--cpu' + - '2' + - '--timeout' + - '3600' + - '--add-cloudsql-instances' + - '$PROJECT_ID:us-central1:spatial-analysis-db' + - '--set-env-vars' + - 'DB_BACKEND=postgres,POSTGRES_DB=tracking_analytics,POSTGRES_USER=postgres,POSTGRES_HOST=/cloudsql/$PROJECT_ID:us-central1:spatial-analysis-db' + - '--set-secrets' + - 'POSTGRES_PASSWORD=postgres-password:latest' + +images: + - 'gcr.io/$PROJECT_ID/spatial-dashboard' diff --git a/scripts/deploy/config.sh b/scripts/deploy/config.sh new file mode 100755 index 00000000..7313ba8d --- /dev/null +++ b/scripts/deploy/config.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Deployment configuration +# Source this file in other scripts: source scripts/deploy/config.sh + +# Google Cloud Configuration +export PROJECT_ID="${PROJECT_ID:-$(gcloud config get-value project 2>/dev/null)}" +export REGION="${REGION:-us-central1}" +export INSTANCE_NAME="${INSTANCE_NAME:-spatial-analysis-db}" +export DB_NAME="${DB_NAME:-tracking_analytics}" +export DB_USER="${DB_USER:-postgres}" + +# Local proxy port (use 5433 if you have local postgres on 5432) +export PROXY_PORT="${PROXY_PORT:-5433}" + +# Get password from Secret Manager +export POSTGRES_PASSWORD=$(gcloud secrets versions access latest --secret=postgres-password --project=${PROJECT_ID}) + +# Set database connection environment variables +export DB_BACKEND=postgres +export POSTGRES_HOST=localhost +export POSTGRES_PORT=${PROXY_PORT} +export POSTGRES_DB=${DB_NAME} +export POSTGRES_USER=${DB_USER} + +# Cloud Run Configuration +export SERVICE_NAME="${SERVICE_NAME:-spatial-analysis-dashboard}" +export MEMORY="${MEMORY:-5Gi}" +export CPU="${CPU:-2}" +export TIMEOUT="${TIMEOUT:-3600}" + +# Database tier (db-f1-micro, db-g1-small, db-n1-standard-1, etc.) +export DB_TIER="${DB_TIER:-db-g1-small}" + +# Cloud SQL connection string +export CLOUD_SQL_INSTANCE="${PROJECT_ID}:${REGION}:${INSTANCE_NAME}" + +# Validate configuration +if [ -z "$PROJECT_ID" ]; then + echo "Error: PROJECT_ID not set. Run: gcloud config set project YOUR_PROJECT_ID" + exit 1 +fi + +# Colors for output +export GREEN='\033[0;32m' +export YELLOW='\033[1;33m' +export RED='\033[0;31m' +export NC='\033[0m' # No Color + +# Helper functions +log_info() { + echo -e "${GREEN}✓${NC} $1" +} + +log_warn() { + echo -e "${YELLOW}⚠${NC} $1" +} + +log_error() { + echo -e "${RED}✗${NC} $1" +} diff --git a/scripts/deploy/setup_cloud_sql.sh b/scripts/deploy/setup_cloud_sql.sh new file mode 100755 index 00000000..089bf118 --- /dev/null +++ b/scripts/deploy/setup_cloud_sql.sh @@ -0,0 +1,118 @@ +#!/bin/bash +# Create and configure Cloud SQL instance + +set -e + +# Load configuration +source "$(dirname "$0")/config.sh" + +echo "==========================================" +echo "Cloud SQL Instance Setup" +echo "==========================================" +echo "Project: ${PROJECT_ID}" +echo "Region: ${REGION}" +echo "Instance: ${INSTANCE_NAME}" +echo "Database: ${DB_NAME}" +echo "Tier: ${DB_TIER}" +echo "==========================================" +echo "" + +# Check if instance already exists +if gcloud sql instances describe ${INSTANCE_NAME} --project=${PROJECT_ID} &>/dev/null; then + log_warn "Instance ${INSTANCE_NAME} already exists" + read -p "Continue anyway? (y/N) " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + exit 0 + fi +else + # Generate secure password + export DB_PASSWORD="$(openssl rand -base64 32)" + + ######################################################################## + #### WARNING: THIS DOESN"T WORK. CREATE MANUALLY IN THE WEB UI. #### + ######################################################################## + log_info "Creating Cloud SQL instance (this may take 5-10 minutes)..." + gcloud sql instances create ${INSTANCE_NAME} \ + --database-version=POSTGRES_17 \ + --tier=${DB_TIER} \ + --region=${REGION} \ + --database-flags=max_connections=100 \ + --backup-start-time=03:00 \ + --project=${PROJECT_ID} + + log_info "Cloud SQL instance created: ${INSTANCE_NAME}" + ######################################################################## + + # Create database + log_info "Creating database: ${DB_NAME}" + gcloud sql databases create ${DB_NAME} \ + --instance=${INSTANCE_NAME} \ + --project=${PROJECT_ID} + + # Set password + log_info "Setting database password..." + gcloud sql users set-password ${DB_USER} \ + --instance=${INSTANCE_NAME} \ + --password="${DB_PASSWORD}" \ + --project=${PROJECT_ID} + + # Store password in Secret Manager + log_info "Storing password in Secret Manager..." + + # Check if secret exists + if gcloud secrets describe postgres-password --project=${PROJECT_ID} &>/dev/null; then + log_warn "Secret postgres-password already exists, adding new version..." + echo -n "${DB_PASSWORD}" | gcloud secrets versions add postgres-password \ + --data-file=- \ + --project=${PROJECT_ID} + else + echo -n "${DB_PASSWORD}" | gcloud secrets create postgres-password \ + --data-file=- \ + --replication-policy="automatic" \ + --project=${PROJECT_ID} + fi + + log_info "Password stored in Secret Manager: postgres-password" + + # Grant IAM permissions + log_info "Granting Cloud SQL Client permissions..." + + # Try user account first + USER_EMAIL=$(gcloud config get-value account 2>/dev/null || echo "") + if [ -n "$USER_EMAIL" ]; then + gcloud projects add-iam-policy-binding ${PROJECT_ID} \ + --member="user:${USER_EMAIL}" \ + --role="roles/cloudsql.client" \ + --condition=None 2>/dev/null || log_warn "Permission already granted or failed" + log_info "Granted Cloud SQL Client role to: ${USER_EMAIL}" + fi + + # Also grant to service account if available + if [ -n "${GOOGLE_APPLICATION_CREDENTIALS:-}" ] && [ -f "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then + SA_EMAIL=$(cat ${GOOGLE_APPLICATION_CREDENTIALS} | python3 -c "import sys, json; print(json.load(sys.stdin)['client_email'])" 2>/dev/null || echo "") + if [ -n "$SA_EMAIL" ]; then + gcloud projects add-iam-policy-binding ${PROJECT_ID} \ + --member="serviceAccount:${SA_EMAIL}" \ + --role="roles/cloudsql.client" \ + --condition=None 2>/dev/null || log_warn "Permission already granted or failed" + log_info "Granted Cloud SQL Client role to: ${SA_EMAIL}" + fi + fi + + echo "" + echo "==========================================" + log_info "Cloud SQL setup complete!" + echo "==========================================" + echo "" + echo "Connection details:" + echo " Instance: ${CLOUD_SQL_INSTANCE}" + echo " Database: ${DB_NAME}" + echo " User: ${DB_USER}" + echo " Password: Stored in Secret Manager (postgres-password)" + echo "" + echo "Next steps:" + echo " 1. Start proxy: ./scripts/deploy/start_proxy.sh" + echo " 2. Init database: source scripts/deploy/config.sh && python -m collab_env.data.db.init_database --backend postgres" + echo " 3. Deploy dashboard: ./scripts/deploy/build_and_deploy.sh" +fi diff --git a/scripts/deploy/start_proxy.sh b/scripts/deploy/start_proxy.sh new file mode 100755 index 00000000..19d6d927 --- /dev/null +++ b/scripts/deploy/start_proxy.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +# Load configuration +source "$(dirname "$0")/config.sh" + +cloud-sql-proxy ${PROJECT_ID}:${REGION}:${INSTANCE_NAME} \ + --credentials-file ${GOOGLE_APPLICATION_CREDENTIALS} \ + --port ${PROXY_PORT} \ No newline at end of file diff --git a/scripts/test_notebooks.sh b/scripts/test_notebooks.sh index dcca0946..536d860b 100755 --- a/scripts/test_notebooks.sh +++ b/scripts/test_notebooks.sh @@ -17,6 +17,7 @@ EXCLUDED_NOTEBOOKS=( if [ -n "${SKIP_GCS_TESTS:-}" ]; then EXCLUDED_NOTEBOOKS+=( "docs/data/gcloud_bucket_manipulation.ipynb" + "docs/data/db/query_cloud_db.ipynb" ) fi diff --git a/tests/dashboard/__init__.py b/tests/dashboard/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/dashboard/test_analysis_widgets.py b/tests/dashboard/test_analysis_widgets.py new file mode 100644 index 00000000..8b30eab5 --- /dev/null +++ b/tests/dashboard/test_analysis_widgets.py @@ -0,0 +1,271 @@ +""" +Tests for widget refactoring. + +Tests the modular widget system without database connection. +""" + +import pytest +from pathlib import Path + +from collab_env.dashboard.widgets import ( + QueryScope, + ScopeType, + AnalysisContext, + BaseAnalysisWidget, + WidgetRegistry, +) + + +class TestImports: + """Test that all modules import correctly.""" + + def test_core_modules_import(self): + """Test that core widget modules can be imported.""" + from collab_env.dashboard.widgets import ( + QueryScope, + ScopeType, + AnalysisContext, + WidgetRegistry, + ) + + # If we get here, imports succeeded + assert QueryScope is not None + assert ScopeType is not None + assert AnalysisContext is not None + assert BaseAnalysisWidget is not None + assert WidgetRegistry is not None + + def test_widget_modules_import(self): + """Test that all widget modules can be imported.""" + from collab_env.dashboard.widgets.velocity_widget import VelocityStatsWidget + from collab_env.dashboard.widgets.distance_widget import DistanceStatsWidget + from collab_env.dashboard.widgets.correlation_widget import CorrelationWidget + + assert VelocityStatsWidget is not None + assert DistanceStatsWidget is not None + assert CorrelationWidget is not None + + +class TestQueryScope: + """Test QueryScope creation and parameter extraction.""" + + def test_episode_scope_creation(self): + """Test creating an episode scope.""" + scope = QueryScope.from_episode( + episode_id="ep_123", start_time=0, end_time=500, agent_type="agent" + ) + + assert scope.scope_type == ScopeType.EPISODE + assert scope.episode_id == "ep_123" + assert scope.start_time == 0 + assert scope.end_time == 500 + + def test_episode_scope_to_query_params(self): + """Test converting episode scope to query parameters.""" + scope = QueryScope.from_episode( + episode_id="ep_123", start_time=0, end_time=500, agent_type="agent" + ) + + params = scope.to_query_params() + + assert params["episode_id"] == "ep_123" + assert params["start_time"] == 0 + assert params["end_time"] == 500 + assert params["agent_type"] == "agent" + + def test_session_scope_creation(self): + """Test creating a session scope.""" + scope = QueryScope.from_session(session_id="sess_456", agent_type="target") + + assert scope.scope_type == ScopeType.SESSION + assert scope.session_id == "sess_456" + + def test_custom_scope_creation(self): + """Test creating a custom scope.""" + scope = QueryScope.from_custom( + session_id="sess_789", min_speed=5.0, max_distance=100.0 + ) + + assert scope.scope_type == ScopeType.CUSTOM + assert scope.custom_filters["min_speed"] == 5.0 + assert scope.custom_filters["max_distance"] == 100.0 + + +@pytest.fixture(scope="module") +def init_holoviews(): + """Initialize HoloViews extensions once for all tests.""" + import holoviews as hv + + hv.extension("bokeh") + + +class TestWidgetRegistry: + """Test widget registry loading from config.""" + + def test_registry_loads_config(self, init_holoviews): + """Test that WidgetRegistry loads config file.""" + # Find config file (relative to project root) + config_path = ( + Path(__file__).parent.parent.parent + / "collab_env" + / "dashboard" + / "analysis_widgets.yaml" + ) + + if not config_path.exists(): + pytest.skip(f"Config file not found at {config_path}") + + registry = WidgetRegistry(str(config_path)) + widgets = registry.get_enabled_widgets() + + # Expected: BasicDataViewer, VelocityStats, DistanceStats, Correlation + assert len(widgets) == 4, f"Expected 4 enabled widgets, got {len(widgets)}" + + def test_registry_loads_default_parameters(self, init_holoviews): + """Test that WidgetRegistry loads default parameters.""" + config_path = ( + Path(__file__).parent.parent.parent + / "collab_env" + / "dashboard" + / "analysis_widgets.yaml" + ) + + if not config_path.exists(): + pytest.skip(f"Config file not found at {config_path}") + + registry = WidgetRegistry(str(config_path)) + defaults = registry.get_defaults() + + assert defaults["spatial_bin_size"] == 10.0 + assert defaults["temporal_window_size"] == 10 + assert defaults["min_samples"] == 100 + + def test_widgets_have_correct_attributes(self, init_holoviews): + """Test that loaded widgets have expected attributes.""" + config_path = ( + Path(__file__).parent.parent.parent + / "collab_env" + / "dashboard" + / "analysis_widgets.yaml" + ) + + if not config_path.exists(): + pytest.skip(f"Config file not found at {config_path}") + + registry = WidgetRegistry(str(config_path)) + widgets = registry.get_enabled_widgets() + + for widget in widgets: + assert hasattr(widget, "widget_name") + assert hasattr(widget, "widget_category") + assert widget.widget_name is not None + assert widget.widget_category is not None + + +class TestWidgetInstantiation: + """Test individual widget instantiation.""" + + def test_velocity_widget_creation(self, init_holoviews): + """Test creating a VelocityStatsWidget.""" + from collab_env.dashboard.widgets.velocity_widget import VelocityStatsWidget + + velocity = VelocityStatsWidget() + + assert velocity.widget_name == "Velocity Stats" + assert velocity.load_btn is not None + assert velocity.display_pane is not None + + def test_widget_has_ui_components(self, init_holoviews): + """Test that widgets have required UI components.""" + from collab_env.dashboard.widgets.velocity_widget import VelocityStatsWidget + + widget = VelocityStatsWidget() + + # Check for standard components + assert hasattr(widget, "load_btn") + assert hasattr(widget, "display_pane") + assert widget.load_btn is not None + assert widget.display_pane is not None + + +class TestAnalysisContext: + """Test AnalysisContext creation and parameter merging.""" + + def test_context_creation_with_episode_scope(self): + """Test creating AnalysisContext with episode scope.""" + scope = QueryScope.from_episode("ep_123", start_time=0, end_time=500) + + context = AnalysisContext( + query_backend=None, # Mock backend not needed for this test + scope=scope, + spatial_bin_size=5.0, + temporal_window_size=50, + min_samples=20, + ) + + assert context.scope == scope + assert context.spatial_bin_size == 5.0 + assert context.temporal_window_size == 50 + assert context.min_samples == 20 + + def test_get_query_params_merges_scope_and_context(self): + """Test that get_query_params() merges scope and context parameters.""" + scope = QueryScope.from_episode("ep_123", start_time=0, end_time=500) + + context = AnalysisContext( + query_backend=None, + scope=scope, + spatial_bin_size=5.0, + temporal_window_size=50, + min_samples=20, + ) + + params = context.get_query_params() + + # Scope parameters + assert params["episode_id"] == "ep_123" + assert params["start_time"] == 0 + assert params["end_time"] == 500 + + # Context parameters + assert params["bin_size"] == 5.0 + assert params["window_size"] == 50 + assert params["min_samples"] == 20 + + def test_get_query_params_allows_overrides(self): + """Test that get_query_params() allows parameter overrides.""" + scope = QueryScope.from_episode("ep_123") + + context = AnalysisContext( + query_backend=None, + scope=scope, + spatial_bin_size=5.0, + temporal_window_size=50, + min_samples=20, + ) + + # Override bin_size and add custom param + params = context.get_query_params(bin_size=15.0, custom_param="test") + + assert params["bin_size"] == 15.0 # Overridden + assert params["window_size"] == 50 # Not overridden + assert params["min_samples"] == 20 # Not overridden + assert params["custom_param"] == "test" # Added + + def test_context_with_session_scope(self): + """Test creating AnalysisContext with session scope.""" + scope = QueryScope.from_session(session_id="sess_456") + + context = AnalysisContext( + query_backend=None, + scope=scope, + spatial_bin_size=10.0, + temporal_window_size=100, + min_samples=100, + ) + + params = context.get_query_params() + + assert "session_id" in params + assert params["session_id"] == "sess_456" + assert "episode_id" not in params or params["episode_id"] is None diff --git a/tests/dashboard/test_api_validation.py b/tests/dashboard/test_api_validation.py new file mode 100644 index 00000000..19699ac6 --- /dev/null +++ b/tests/dashboard/test_api_validation.py @@ -0,0 +1,201 @@ +""" +API Validation Tests for SQL-Level Session Scope Implementation + +Tests that QueryBackend methods correctly accept both episode_id and session_id +parameters, handle extra parameters gracefully, and validate inputs properly. +""" + +import pytest +from unittest.mock import Mock +import pandas as pd + +from collab_env.data.db.query_backend import QueryBackend +from collab_env.dashboard.widgets import QueryScope, AnalysisContext + + +@pytest.fixture +def mock_backend(): + """Create a QueryBackend with mocked _execute_query method.""" + backend = QueryBackend.__new__(QueryBackend) + backend._execute_query = Mock(return_value=pd.DataFrame()) + return backend + + +@pytest.fixture +def shared_params(): + """Shared parameters that AnalysisContext.get_query_params() produces.""" + return { + "episode_id": "ep_123", + "bin_size": 10.0, + "window_size": 100, + "min_samples": 100, + "agent_type": "agent", + "start_time": 0, + "end_time": 500, + } + + +# List of QueryBackend analysis methods supporting both episode_id and session_id +SESSION_SUPPORTED_METHODS = [ + "get_spatial_heatmap", +] + +# List of correlation methods supporting only episode_id (session-level disabled) +EPISODE_ONLY_METHODS = ["get_velocity_correlations", "get_distance_correlations"] + +# All analysis methods combined +ANALYSIS_METHODS = SESSION_SUPPORTED_METHODS + EPISODE_ONLY_METHODS + + +class TestQueryBackendMethodSignatures: + """Test that QueryBackend methods accept both episode_id and session_id.""" + + @pytest.mark.parametrize("method_name", ANALYSIS_METHODS) + def test_accepts_episode_id(self, mock_backend, method_name): + """Test that all methods accept episode_id parameter.""" + method = getattr(mock_backend, method_name) + + # Should not raise + if "heatmap" in method_name: + method(episode_id="ep_123", bin_size=10.0) + elif "correlation" in method_name: + method(episode_id="ep_123", min_samples=100) + else: + method(episode_id="ep_123", window_size=100) + + @pytest.mark.parametrize("method_name", SESSION_SUPPORTED_METHODS) + def test_accepts_session_id(self, mock_backend, method_name): + """Test that session-supported methods accept session_id parameter.""" + method = getattr(mock_backend, method_name) + + # Should not raise + if "heatmap" in method_name: + method(session_id="sess_456", bin_size=10.0) + else: + method(session_id="sess_456", window_size=100) + + +class TestExtraParameters: + """Test that methods accept extra parameters without error.""" + + def test_spatial_heatmap_accepts_extra_params(self, mock_backend, shared_params): + """Spatial heatmap should accept extra params like window_size, min_samples.""" + # Should not raise TypeError + mock_backend.get_spatial_heatmap(**shared_params) + + def test_velocity_correlations_accepts_extra_params( + self, mock_backend, shared_params + ): + """Velocity correlations should accept extra params like bin_size, window_size.""" + # Should not raise TypeError + mock_backend.get_velocity_correlations(**shared_params) + + def test_distance_correlations_accepts_extra_params( + self, mock_backend, shared_params + ): + """Distance correlations should accept extra params like bin_size, window_size.""" + # Should not raise TypeError + mock_backend.get_distance_correlations(**shared_params) + + +class TestParameterValidation: + """Test that methods validate episode_id/session_id correctly.""" + + @pytest.mark.parametrize("method_name", SESSION_SUPPORTED_METHODS) + def test_rejects_missing_both_parameters(self, mock_backend, method_name): + """Session-supported methods should raise ValueError when both episode_id and session_id are missing.""" + method = getattr(mock_backend, method_name) + + with pytest.raises( + ValueError, match="Either episode_id or session_id must be provided" + ): + method() + + @pytest.mark.parametrize("method_name", EPISODE_ONLY_METHODS) + def test_correlation_methods_require_episode_id(self, mock_backend, method_name): + """Correlation methods should raise TypeError when episode_id is missing (required parameter).""" + method = getattr(mock_backend, method_name) + + with pytest.raises(TypeError): + method() + + @pytest.mark.parametrize("method_name", SESSION_SUPPORTED_METHODS) + def test_rejects_both_parameters(self, mock_backend, method_name): + """Session-supported methods should raise ValueError when both episode_id and session_id are provided.""" + method = getattr(mock_backend, method_name) + + with pytest.raises( + ValueError, match="Cannot specify both episode_id and session_id" + ): + method(episode_id="ep_123", session_id="sess_456") + + +class TestAnalysisContextIntegration: + """Test that AnalysisContext.get_query_params() produces compatible output.""" + + def test_episode_scope_params(self, mock_backend): + """Test that episode scope parameters work with all methods.""" + scope = QueryScope.from_episode(episode_id="ep_123", start_time=0, end_time=500) + context = AnalysisContext( + query_backend=mock_backend, + scope=scope, + spatial_bin_size=10.0, + temporal_window_size=100, + min_samples=100, + ) + + params = context.get_query_params() + + # Should have episode_id + assert "episode_id" in params + assert params["episode_id"] == "ep_123" + + # Should not have session_id + assert "session_id" not in params or params["session_id"] is None + + # All methods should accept these params + mock_backend.get_spatial_heatmap(**params) + mock_backend.get_velocity_correlations(**params) + + def test_session_scope_params(self, mock_backend): + """Test that session scope parameters work with session-supported methods.""" + scope = QueryScope.from_session(session_id="sess_456") + context = AnalysisContext( + query_backend=mock_backend, + scope=scope, + spatial_bin_size=10.0, + temporal_window_size=100, + min_samples=100, + ) + + params = context.get_query_params() + + # Should have session_id + assert "session_id" in params + assert params["session_id"] == "sess_456" + + # Should not have episode_id + assert "episode_id" not in params or params["episode_id"] is None + + # Session-supported methods should accept these params + mock_backend.get_spatial_heatmap(**params) + # Note: Correlation methods do NOT support session scope + + def test_shared_parameters_included(self, mock_backend): + """Test that shared parameters are included in query params.""" + scope = QueryScope.from_episode(episode_id="ep_123") + context = AnalysisContext( + query_backend=mock_backend, + scope=scope, + spatial_bin_size=15.0, + temporal_window_size=200, + min_samples=50, + ) + + params = context.get_query_params() + + # Check shared parameters are present + assert params["bin_size"] == 15.0 + assert params["window_size"] == 200 + assert params["min_samples"] == 50 + assert "agent_type" in params diff --git a/tests/db/__init__.py b/tests/db/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/db/conftest.py b/tests/db/conftest.py new file mode 100644 index 00000000..6c71e26e --- /dev/null +++ b/tests/db/conftest.py @@ -0,0 +1,235 @@ +""" +Pytest fixtures for database tests - with 2D boids fixture. +""" + +import os +import tempfile +from pathlib import Path +from typing import Generator + +import pandas as pd +import pytest +import torch +import yaml + +from collab_env.data.db.config import DBConfig, get_db_config +from collab_env.data.db.init_database import DatabaseBackend +from collab_env.data.file_utils import get_project_root + + +@pytest.fixture +def temp_duckdb() -> Generator[Path, None, None]: + """Create a temporary DuckDB file path (file created by DuckDB).""" + # Create temp file to get the name, then delete it so DuckDB can create it fresh + with tempfile.NamedTemporaryFile(suffix=".duckdb", delete=True) as f: + db_path = Path(f.name) + + # File is deleted by tempfile, DuckDB will create it fresh + yield db_path + + # Cleanup + if db_path.exists(): + db_path.unlink() + # Also clean up .wal file if it exists + wal_file = db_path.with_suffix(".duckdb.wal") + if wal_file.exists(): + wal_file.unlink() + + +@pytest.fixture +def duckdb_config(temp_duckdb: Path) -> DBConfig: + """DuckDB configuration for testing.""" + os.environ["DB_BACKEND"] = "duckdb" + os.environ["DUCKDB_PATH"] = str(temp_duckdb) + return get_db_config("duckdb") + + +@pytest.fixture +def postgres_config() -> DBConfig: + """PostgreSQL configuration from .env file.""" + os.environ["DB_BACKEND"] = "postgres" + return get_db_config("postgres") + + +@pytest.fixture +def duckdb_initialized(duckdb_config: DBConfig) -> DBConfig: + """DuckDB with schema initialized.""" + backend = DatabaseBackend(duckdb_config) + backend.connect() + + # Initialize schema + project_root = get_project_root() + schema_dir = project_root / "collab_env" / "data" / "db" / "schema" + backend.execute_file(schema_dir / "01_core_tables.sql") + backend.execute_file(schema_dir / "02_extended_properties.sql") + backend.execute_file(schema_dir / "03_seed_data.sql") + + backend.close() + return duckdb_config + + +@pytest.fixture +def postgres_initialized(postgres_config: DBConfig) -> DBConfig: + """PostgreSQL with schema initialized (or skip if unavailable).""" + backend = None + try: + backend = DatabaseBackend(postgres_config) + backend.connect() + + # SAFETY CHECK: Ensure we're using a test database + # Refuse to run tests on production databases + assert postgres_config.postgres is not None + db_name = postgres_config.postgres.dbname.lower() + forbidden_names = ["tracking_analytics", "production", "prod", "main"] + + if db_name in forbidden_names: + pytest.skip( + f"SAFETY: Refusing to run tests on database '{db_name}'. " + f"Please set POSTGRES_DB=tracking_analytics_test in your environment. " + f"Tests drop all tables and should only run on dedicated test databases!" + ) + + # Require explicit '_test' suffix for safety + if not db_name.endswith("_test"): + pytest.skip( + f"SAFETY: Database name '{db_name}' must end with '_test'. " + f"Example: tracking_analytics_test. " + f"This prevents accidentally running destructive tests on production." + ) + + # Clean up any existing test data + # DROP TABLE IF EXISTS with CASCADE should always succeed + backend.execute_query("DROP TABLE IF EXISTS extended_properties CASCADE") + backend.execute_query("DROP TABLE IF EXISTS observations CASCADE") + backend.execute_query("DROP TABLE IF EXISTS episodes CASCADE") + backend.execute_query("DROP TABLE IF EXISTS sessions CASCADE") + backend.execute_query("DROP TABLE IF EXISTS property_definitions CASCADE") + backend.execute_query("DROP TABLE IF EXISTS categories CASCADE") + backend.execute_query("DROP TABLE IF EXISTS agent_types CASCADE") + + # Initialize schema + project_root = get_project_root() + schema_dir = project_root / "collab_env" / "data" / "db" / "schema" + backend.execute_file(schema_dir / "01_core_tables.sql") + backend.execute_file(schema_dir / "02_extended_properties.sql") + backend.execute_file(schema_dir / "03_seed_data.sql") + + backend.close() + return postgres_config + except Exception as e: + if backend: + backend.close() + pytest.skip(f"PostgreSQL not available: {e}") + + +@pytest.fixture +def sample_boids_data(tmp_path: Path) -> Path: + """Create a small sample boids dataset for testing.""" + # Create config.yaml + config = { + "frame_rate": 30.0, + "num_agents": 10, + "num_frames": 100, + "scene_size": [100, 100, 100], + } + + config_path = tmp_path / "config.yaml" + with open(config_path, "w") as f: + yaml.dump(config, f) + + # Create sample episode data with both agents and environment entities + num_agents = 5 + num_env_entities = 2 # Environment entities (walls, obstacles) + num_frames = 10 + + data = [] + for t in range(num_frames): + # Agent entities + for agent_id in range(num_agents): + data.append( + { + "time": t, + "id": agent_id, + "type": "agent", + "x": float(agent_id * 10 + t), + "y": float(agent_id * 10 + t * 0.5), + "z": float(agent_id * 5), + "v_x": 1.0, + "v_y": 0.5, + "v_z": 0.0, + "distance_to_target_center": float(100 - t * agent_id), + } + ) + + # Environment entities (can have same IDs as agents - now supported!) + for env_id in range(num_env_entities): + data.append( + { + "time": t, + "id": env_id, # Same IDs as agents - no conflict with new schema + "type": "env", + "x": float(500 + env_id * 100), + "y": float(500 + env_id * 100), + "z": 0.0, + "v_x": 0.0, # Environment entities don't move + "v_y": 0.0, + "v_z": 0.0, + "distance_to_target_center": None, + } + ) + + df = pd.DataFrame(data) + episode_path = tmp_path / "episode-0-test.parquet" + df.to_parquet(episode_path) + + return tmp_path + + +@pytest.fixture(params=["duckdb", "postgres"]) +def backend_config(request): + """Parametrized fixture that tests both backends.""" + if request.param == "duckdb": + # Get duckdb_initialized fixture + return request.getfixturevalue("duckdb_initialized") + else: + # Get postgres_initialized fixture (may skip) + return request.getfixturevalue("postgres_initialized") + + +@pytest.fixture +def sample_2d_boids_data(tmp_path: Path) -> Path: + """Create a small sample 2D boids dataset for testing.""" + # Create config + config = { + "A": { + "visual_range": 50, + "centering_factor": 0.005, + "min_distance": 15, + "avoid_factor": 0.05, + "matching_factor": 0.5, + "margin": 5, + "turn_factor": 10, + "speed_limit": 7, + "counts": 5, + "independent": False, + }, + "scene_size": 480.0, + } + + config_path = tmp_path / "test_2d_boids_config.pt" + torch.save(config, config_path) + + # Create dataset with 3 samples + # Use the actual dataset class from real data + dataset = torch.load( + "simulated_data/boid_single_species_basic.pt", weights_only=False + ) + + # Create a simple test dataset with just the first 3 samples + test_samples = [dataset[i] for i in range(3)] + + # Save as simple list + data_path = tmp_path / "test_2d_boids.pt" + torch.save(test_samples, data_path) + + return data_path diff --git a/tests/db/test_2d_boids_loader.py b/tests/db/test_2d_boids_loader.py new file mode 100644 index 00000000..de3819e5 --- /dev/null +++ b/tests/db/test_2d_boids_loader.py @@ -0,0 +1,219 @@ +""" +Tests for 2D boids data loader. +""" + +from pathlib import Path + +from collab_env.data.db.config import DBConfig +from collab_env.data.db.db_loader import ( + DatabaseConnection, + Boids2DLoader, +) + + +class TestBoids2DLoader: + """Test 2D boids data loader.""" + + def test_load_2d_boids_dataset( + self, backend_config: DBConfig, sample_2d_boids_data: Path + ): + """Test loading a complete 2D boids dataset.""" + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids2DLoader(db) + loader.load_dataset(sample_2d_boids_data) + + # Verify session was created + result = db.fetch_one( + "SELECT COUNT(*) FROM sessions WHERE category_id = :cat", + {"cat": "boids_2d"}, + ) + assert result is not None + assert result[0] >= 1, "Should have created at least one 2D boids session" + + # Verify episodes were created (3 samples) + result = db.fetch_one( + "SELECT COUNT(*) FROM episodes WHERE session_id LIKE :pattern", + {"pattern": "%2d%"}, + ) + assert result is not None + assert result[0] == 3, f"Expected 3 episodes, found {result[0]}" + + # Verify observations were loaded (3 samples × 10 timesteps × 5 agents = 150) + result = db.fetch_one( + "SELECT COUNT(*) FROM observations WHERE episode_id LIKE :pattern", + {"pattern": "%2d%"}, + ) + assert result is not None + assert result[0] == 600, f"Expected 600 observations, found {result[0]}" + + # Cleanup + db.execute( + "DELETE FROM observations WHERE episode_id LIKE :pattern", + {"pattern": "%2d%"}, + ) + db.execute( + "DELETE FROM episodes WHERE session_id LIKE :pattern", {"pattern": "%2d%"} + ) + db.execute("DELETE FROM sessions WHERE category_id = :cat", {"cat": "boids_2d"}) + db.close() + + def test_2d_boids_data_integrity( + self, backend_config: DBConfig, sample_2d_boids_data: Path + ): + """Test that 2D boids observations are loaded with correct data.""" + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids2DLoader(db) + loader.load_dataset(sample_2d_boids_data) + + # Check that all observations have x, y coordinates + result = db.fetch_one( + """ + SELECT + COUNT(*) as total, + SUM(CASE WHEN x IS NULL THEN 1 ELSE 0 END) as null_x, + SUM(CASE WHEN y IS NULL THEN 1 ELSE 0 END) as null_y, + SUM(CASE WHEN z IS NOT NULL THEN 1 ELSE 0 END) as non_null_z, + SUM(CASE WHEN v_x IS NULL THEN 1 ELSE 0 END) as null_vx, + SUM(CASE WHEN v_y IS NULL THEN 1 ELSE 0 END) as null_vy, + SUM(CASE WHEN v_z IS NOT NULL THEN 1 ELSE 0 END) as non_null_vz + FROM observations + WHERE episode_id LIKE :pattern + """, + {"pattern": "%2d%"}, + ) + + assert result is not None + total, null_x, null_y, non_null_z, null_vx, null_vy, non_null_vz = result + + assert null_x == 0, "All observations should have x coordinate" + assert null_y == 0, "All observations should have y coordinate" + assert non_null_z == 0, "2D boids should not have z coordinate" + assert null_vx == 0, "All observations should have v_x velocity" + assert null_vy == 0, "All observations should have v_y velocity" + assert non_null_vz == 0, "2D boids should not have v_z velocity" + + # Check position values are in expected range (scaled by scene_size=480) + # Boids can slightly exceed [0, scene_size] bounds during simulation + result = db.fetch_one( + """ + SELECT MIN(x), MAX(x), MIN(y), MAX(y) + FROM observations + WHERE episode_id LIKE :pattern + """, + {"pattern": "%2d%"}, + ) + + assert result is not None + min_x, max_x, min_y, max_y = result + assert min_x >= -50 and max_x <= 530, ( + f"X coordinates should be roughly in [0, 480], got [{min_x}, {max_x}]" + ) + assert min_y >= -50 and max_y <= 530, ( + f"Y coordinates should be roughly in [0, 480], got [{min_y}, {max_y}]" + ) + + # Cleanup + db.execute( + "DELETE FROM observations WHERE episode_id LIKE :pattern", + {"pattern": "%2d%"}, + ) + db.execute( + "DELETE FROM episodes WHERE session_id LIKE :pattern", {"pattern": "%2d%"} + ) + db.execute("DELETE FROM sessions WHERE category_id = :cat", {"cat": "boids_2d"}) + db.close() + + def test_2d_boids_velocity_computation( + self, backend_config: DBConfig, sample_2d_boids_data: Path + ): + """Test that velocities are computed correctly from positions.""" + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids2DLoader(db) + loader.load_dataset(sample_2d_boids_data) + + # Get observations for agent 0 in first episode at consecutive timesteps + results = db.fetch_all( + """ + SELECT time_index, x, y, v_x, v_y + FROM observations + WHERE episode_id LIKE :pattern + AND agent_id = 0 + ORDER BY time_index + LIMIT 3 + """, + {"pattern": "%episode-0000%"}, + ) + + assert len(results) >= 2, "Need at least 2 timesteps to verify velocity" + + # For first two timesteps, verify v[t] ≈ (p[t+1] - p[t]) + t0, x0, y0, vx0, vy0 = results[0] + t1, x1, y1, vx1, vy1 = results[1] + + # Computed velocity should approximate position difference + expected_vx = x1 - x0 + expected_vy = y1 - y0 + + # Allow for floating point precision + assert abs(vx0 - expected_vx) < 0.01, ( + f"v_x mismatch: expected {expected_vx:.4f}, got {vx0:.4f}" + ) + assert abs(vy0 - expected_vy) < 0.01, ( + f"v_y mismatch: expected {expected_vy:.4f}, got {vy0:.4f}" + ) + + # Cleanup + db.execute( + "DELETE FROM observations WHERE episode_id LIKE :pattern", + {"pattern": "%2d%"}, + ) + db.execute( + "DELETE FROM episodes WHERE session_id LIKE :pattern", {"pattern": "%2d%"} + ) + db.execute("DELETE FROM sessions WHERE category_id = :cat", {"cat": "boids_2d"}) + db.close() + + def test_2d_boids_episode_metadata( + self, backend_config: DBConfig, sample_2d_boids_data: Path + ): + """Test that episode metadata is correct for 2D boids.""" + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids2DLoader(db) + loader.load_dataset(sample_2d_boids_data) + + # Check episode metadata + results = db.fetch_all( + """ + SELECT episode_number, num_frames, num_agents, frame_rate + FROM episodes + WHERE session_id LIKE :pattern + ORDER BY episode_number + """, + {"pattern": "%2d%"}, + ) + + assert len(results) == 3, f"Expected 3 episodes, found {len(results)}" + + for episode_num, num_frames, num_agents, frame_rate in results: + assert num_frames == 10, f"Expected 10 frames, got {num_frames}" + assert num_agents == 20, f"Expected 20 agents, got {num_agents}" + assert frame_rate == 1.0, f"Expected frame_rate=1.0, got {frame_rate}" + + # Cleanup + db.execute( + "DELETE FROM observations WHERE episode_id LIKE :pattern", + {"pattern": "%2d%"}, + ) + db.execute( + "DELETE FROM episodes WHERE session_id LIKE :pattern", {"pattern": "%2d%"} + ) + db.execute("DELETE FROM sessions WHERE category_id = :cat", {"cat": "boids_2d"}) + db.close() diff --git a/tests/db/test_db_loader.py b/tests/db/test_db_loader.py new file mode 100644 index 00000000..9a5ae1b1 --- /dev/null +++ b/tests/db/test_db_loader.py @@ -0,0 +1,275 @@ +""" +Tests for data loading functionality. +""" + +from pathlib import Path + +from collab_env.data.db.config import DBConfig +from collab_env.data.db.db_loader import ( + DatabaseConnection, + Boids3DLoader, + SessionMetadata, + EpisodeMetadata, +) + + +class TestDataLoader: + """Test data loading pipeline.""" + + def test_load_session(self, backend_config: DBConfig): + """Test loading session metadata.""" + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids3DLoader(db) + metadata = SessionMetadata( + session_id="test-session-1", + session_name="Test Session", + category_id="boids_3d", + config={"frame_rate": 30.0}, + metadata={"test": True}, + ) + + loader.load_session(metadata) + + # Verify session was loaded + result_row = db.fetch_one( + "SELECT session_name FROM sessions WHERE session_id = :sid", + {"sid": "test-session-1"}, + ) + assert result_row is not None + assert result_row[0] == "Test Session" + + # Cleanup + db.execute( + "DELETE FROM sessions WHERE session_id = :sid", {"sid": "test-session-1"} + ) + db.close() + + def test_load_episode(self, backend_config: DBConfig): + """Test loading episode metadata.""" + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids3DLoader(db) + + # First load session + session_metadata = SessionMetadata( + session_id="test-session-2", + session_name="Test Session", + category_id="boids_3d", + config={}, + ) + loader.load_session(session_metadata) + + # Then load episode + episode_metadata = EpisodeMetadata( + episode_id="test-episode-1", + session_id="test-session-2", + episode_number=0, + num_frames=100, + num_agents=10, + frame_rate=30.0, + file_path="/tmp/test.parquet", + ) + loader.load_episode(episode_metadata) + + # Verify episode was loaded + result_row = db.fetch_one( + "SELECT num_agents FROM episodes WHERE episode_id = :eid", + {"eid": "test-episode-1"}, + ) + assert result_row is not None + assert result_row[0] == 10 + + # Cleanup + db.execute( + "DELETE FROM episodes WHERE episode_id = :eid", {"eid": "test-episode-1"} + ) + db.execute( + "DELETE FROM sessions WHERE session_id = :sid", {"sid": "test-session-2"} + ) + db.close() + + def test_load_boids_simulation( + self, backend_config: DBConfig, sample_boids_data: Path + ): + """Test loading a complete boids simulation.""" + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids3DLoader(db) + loader.load_simulation(sample_boids_data) + + # Verify session was created + session_name = sample_boids_data.name + result = db.fetch_one( + "SELECT COUNT(*) FROM sessions WHERE session_name = :name", + {"name": session_name}, + ) + assert result is not None and result[0] >= 1 + + # Verify episodes were created + result = db.fetch_one( + "SELECT COUNT(*) FROM episodes WHERE session_id LIKE :pattern", + {"pattern": f"%{session_name}%"}, + ) + assert result is not None and result[0] >= 1 + + # Verify observations were loaded + result = db.fetch_one("SELECT COUNT(*) FROM observations") + assert result is not None + assert result[0] > 0, "Should have loaded some observations" + + # Expected: (5 agents + 2 env entities) * 10 frames = 70 observations + assert result[0] == 70, ( + f"Expected 70 observations (5 agents + 2 env), found {result[0]}" + ) + + # Cleanup + db.execute( + "DELETE FROM extended_properties WHERE observation_id IN (SELECT observation_id FROM observations WHERE episode_id LIKE :pattern)", + {"pattern": "%test%"}, + ) + db.execute( + "DELETE FROM observations WHERE episode_id LIKE :pattern", + {"pattern": "%test%"}, + ) + db.execute( + "DELETE FROM episodes WHERE session_id LIKE :pattern", + {"pattern": f"%{session_name}%"}, + ) + db.execute( + "DELETE FROM sessions WHERE session_name = :name", {"name": session_name} + ) + db.close() + + def test_observations_data_integrity( + self, backend_config: DBConfig, sample_boids_data: Path + ): + """Test that observations are loaded with correct data.""" + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids3DLoader(db) + loader.load_simulation(sample_boids_data) + + # Check specific observation values (filter by agent_type_id to get agent, not env entity) + result = db.fetch_one(""" + SELECT x, y, z, v_x, v_y, v_z + FROM observations + WHERE agent_id = 0 AND time_index = 0 AND agent_type_id = 'agent' + ORDER BY episode_id DESC + LIMIT 1 + """) + + assert result is not None, "Should find observation for agent 0 at time 0" + x, y, z, v_x, v_y, v_z = result + + # Check values match our sample data generation + assert x == 0.0, f"Expected x=0.0, got {x}" + assert y == 0.0, f"Expected y=0.0, got {y}" + assert z == 0.0, f"Expected z=0.0, got {z}" + assert v_x == 1.0, f"Expected v_x=1.0, got {v_x}" + assert v_y == 0.5, f"Expected v_y=0.5, got {v_y}" + assert v_z == 0.0, f"Expected v_z=0.0, got {v_z}" + + # Cleanup + session_name = sample_boids_data.name + db.execute( + "DELETE FROM extended_properties WHERE observation_id IN (SELECT observation_id FROM observations WHERE episode_id LIKE :pattern)", + {"pattern": "%test%"}, + ) + db.execute( + "DELETE FROM observations WHERE episode_id LIKE :pattern", + {"pattern": "%test%"}, + ) + db.execute( + "DELETE FROM episodes WHERE session_id LIKE :pattern", + {"pattern": f"%{session_name}%"}, + ) + db.execute( + "DELETE FROM sessions WHERE session_name = :name", {"name": session_name} + ) + db.close() + + def test_extended_properties_loaded( + self, backend_config: DBConfig, sample_boids_data: Path + ): + """Test that extended properties are loaded.""" + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids3DLoader(db) + loader.load_simulation(sample_boids_data) + + # Check if extended properties were loaded + result = db.fetch_one("SELECT COUNT(*) FROM extended_properties") + assert result is not None + count = result[0] + + # We should have some extended properties (distance_to_target_center) + assert count > 0, f"Expected some extended properties, found {count}" + + # Expected: 50 observations * 1 property each = 50 extended properties + assert count == 50, f"Expected 50 extended properties, found {count}" + + # Cleanup + session_name = sample_boids_data.name + db.execute( + "DELETE FROM extended_properties WHERE observation_id IN (SELECT observation_id FROM observations WHERE episode_id LIKE :pattern)", + {"pattern": "%test%"}, + ) + db.execute( + "DELETE FROM observations WHERE episode_id LIKE :pattern", + {"pattern": "%test%"}, + ) + db.execute( + "DELETE FROM episodes WHERE session_id LIKE :pattern", + {"pattern": f"%{session_name}%"}, + ) + db.execute( + "DELETE FROM sessions WHERE session_name = :name", {"name": session_name} + ) + db.close() + + +class TestDataLoaderPerformance: + """Test data loading performance.""" + + def test_bulk_insert_performance( + self, backend_config: DBConfig, sample_boids_data: Path + ): + """Test that bulk inserts are reasonably fast.""" + import time + + db = DatabaseConnection(backend_config) + db.connect() + + loader = Boids3DLoader(db) + + start = time.time() + loader.load_simulation(sample_boids_data) + elapsed = time.time() - start + + # Should load 70 observations (5 agents + 2 env * 10 frames) in under 2 seconds + assert elapsed < 2.0, f"Loading took {elapsed:.2f}s, expected < 2s" + + # Cleanup + session_name = sample_boids_data.name + db.execute( + "DELETE FROM extended_properties WHERE observation_id IN (SELECT observation_id FROM observations WHERE episode_id LIKE :pattern)", + {"pattern": "%test%"}, + ) + db.execute( + "DELETE FROM observations WHERE episode_id LIKE :pattern", + {"pattern": "%test%"}, + ) + db.execute( + "DELETE FROM episodes WHERE session_id LIKE :pattern", + {"pattern": f"%{session_name}%"}, + ) + db.execute( + "DELETE FROM sessions WHERE session_name = :name", {"name": session_name} + ) + db.close() diff --git a/tests/db/test_init_database.py b/tests/db/test_init_database.py new file mode 100644 index 00000000..d85338fc --- /dev/null +++ b/tests/db/test_init_database.py @@ -0,0 +1,314 @@ +""" +Tests for database initialization (schema creation). +""" + +import pytest +from collab_env.data.db.config import DBConfig +from collab_env.data.db.db_loader import DatabaseConnection +from collab_env.data.db.init_database import DatabaseBackend + + +class TestDatabaseInitialization: + """Test database schema creation and seed data.""" + + def test_tables_created(self, backend_config: DBConfig): + """Test that all 7 tables are created.""" + db = DatabaseConnection(backend_config) + db.connect() + + # Query information schema for table count + if backend_config.backend == "postgres": + query = """ + SELECT count(*) + FROM information_schema.tables + WHERE table_schema = 'public' + AND table_type = 'BASE TABLE' + """ + else: # duckdb + query = """ + SELECT count(*) + FROM information_schema.tables + WHERE table_schema = 'main' + """ + + result = db.fetch_one(query) + assert result is not None + table_count = result[0] + + db.close() + + assert table_count == 7, f"Expected 7 tables, found {table_count}" + + def test_agent_types_seeded(self, backend_config: DBConfig): + """Test that agent types seed data is loaded.""" + db = DatabaseConnection(backend_config) + db.connect() + + result = db.fetch_one("SELECT COUNT(*) FROM agent_types") + assert result is not None + count = result[0] + + db.close() + + assert count == 7, ( + f"Expected 7 agent types (agent, env, target, food, bird, rat, gerbil), found {count}" + ) + + def test_property_definitions_seeded(self, backend_config: DBConfig): + """Test that property definitions seed data is loaded.""" + db = DatabaseConnection(backend_config) + db.connect() + + result = db.fetch_one("SELECT COUNT(*) FROM property_definitions") + assert result is not None + count = result[0] + + db.close() + + assert count == 28, f"Expected 28 property definitions, found {count}" + + def test_categories_seeded(self, backend_config: DBConfig): + """Test that session categories seed data is loaded.""" + db = DatabaseConnection(backend_config) + db.connect() + + result = db.fetch_one("SELECT COUNT(*) FROM categories") + assert result is not None + count = result[0] + + db.close() + + assert count == 4, ( + f"Expected 4 categories (boids_3d, boids_2d, boids_2d_rollout, tracking_csv), found {count}" + ) + + def test_foreign_key_relationships(self, backend_config: DBConfig): + """Test that foreign key relationships work.""" + db = DatabaseConnection(backend_config) + db.connect() + + # Test we can query type_id from agent_types + result = db.fetch_one("SELECT type_id FROM agent_types WHERE type_id = 'agent'") + assert result is not None, "agent_types table should have 'agent' type" + + # Test we can query categories + result = db.fetch_one( + "SELECT category_id FROM categories WHERE category_id = 'boids_3d'" + ) + assert result is not None, "categories should have 'boids_3d' category" + + db.close() + + def test_sessions_table_structure(self, backend_config: DBConfig): + """Test that sessions table has correct columns.""" + db = DatabaseConnection(backend_config) + db.connect() + + # Insert and retrieve a test session + db.execute( + """ + INSERT INTO sessions (session_id, session_name, category_id, config, metadata) + VALUES (:sid, :name, :cat, :config, :meta) + """, + { + "sid": "test-session", + "name": "Test Session", + "cat": "boids_3d", + "config": '{"test": true}', + "meta": None, + }, + ) + + result = db.fetch_one( + "SELECT session_name FROM sessions WHERE session_id = :sid", + {"sid": "test-session"}, + ) + assert result is not None + assert result[0] == "Test Session" + + # Cleanup + db.execute( + "DELETE FROM sessions WHERE session_id = :sid", {"sid": "test-session"} + ) + db.close() + + +class TestDuckDBSpecific: + """DuckDB-specific tests.""" + + def test_auto_increment_works(self, duckdb_initialized: DBConfig): + """Test that DuckDB auto-increment for observation_id works.""" + db = DatabaseConnection(duckdb_initialized) + db.connect() + + # First create required parent records + db.execute(""" + INSERT INTO sessions (session_id, session_name, category_id, config) + VALUES ('test-s', 'Test', 'boids_3d', '{}') + """) + + db.execute(""" + INSERT INTO episodes (episode_id, session_id, episode_number, num_frames, num_agents, frame_rate, file_path) + VALUES ('test-e', 'test-s', 0, 10, 5, 30.0, '/tmp/test') + """) + + # Insert two observations without specifying observation_id + db.execute(""" + INSERT INTO observations (episode_id, time_index, agent_id, agent_type_id, x, y) + VALUES ('test-e', 0, 0, 'agent', 0.0, 0.0) + """) + + db.execute(""" + INSERT INTO observations (episode_id, time_index, agent_id, agent_type_id, x, y) + VALUES ('test-e', 1, 0, 'agent', 1.0, 1.0) + """) + + # Check that auto-increment IDs were generated + result = db.fetch_all( + "SELECT observation_id FROM observations WHERE episode_id = 'test-e' ORDER BY time_index" + ) + + assert len(result) == 2, "Should have 2 observations" + assert result[0][0] is not None, "First observation should have an ID" + assert result[1][0] is not None, "Second observation should have an ID" + assert result[0][0] != result[1][0], "IDs should be different" + + # Cleanup + db.execute("DELETE FROM observations WHERE episode_id = 'test-e'") + db.execute("DELETE FROM episodes WHERE episode_id = 'test-e'") + db.execute("DELETE FROM sessions WHERE session_id = 'test-s'") + db.close() + + +class TestPostgreSQLSpecific: + """PostgreSQL-specific tests.""" + + @pytest.mark.skip(reason="Requires PostgreSQL connection") + def test_jsonb_support(self, postgres_initialized: DBConfig): + """Test that PostgreSQL JSONB columns work.""" + db = DatabaseConnection(postgres_initialized) + db.connect() + + # Insert session with JSON config + db.execute( + """ + INSERT INTO sessions (session_id, session_name, category_id, config) + VALUES (:sid, :name, :cat, :config::jsonb) + """, + { + "sid": "test-json", + "name": "Test", + "cat": "boids_3d", + "config": '{"frame_rate": 30}', + }, + ) + + # Query with JSONB operators (PostgreSQL-specific) + result = db.fetch_one( + """ + SELECT config->>'frame_rate' as frame_rate + FROM sessions + WHERE session_id = :sid + """, + {"sid": "test-json"}, + ) + + assert result is not None + assert result[0] == "30" + + # Cleanup + db.execute("DELETE FROM sessions WHERE session_id = :sid", {"sid": "test-json"}) + db.close() + + +class TestDatabaseBackendExecuteQuery: + """Test DatabaseBackend.execute_query method specifically.""" + + def test_execute_query_returns_select_results(self, backend_config: DBConfig): + """Test that execute_query returns results from SELECT queries.""" + backend = DatabaseBackend(backend_config) + backend.connect() + + # Query table count (this was the failing scenario) + if backend_config.backend == "postgres": + query = """ + SELECT count(*) + FROM information_schema.tables + WHERE table_schema = 'public' AND table_type = 'BASE TABLE' + """ + else: # duckdb + query = "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'main'" + + result = backend.execute_query(query) + + # This would fail with "list index out of range" if commit happens before fetchall + assert result is not None, ( + "execute_query should return results for SELECT queries" + ) + assert len(result) > 0, "Should have at least one row" + assert result[0][0] == 7, f"Expected 7 tables, got {result[0][0]}" + + backend.close() + + def test_execute_query_returns_multiple_rows(self, backend_config: DBConfig): + """Test that execute_query returns all rows from multi-row SELECT.""" + backend = DatabaseBackend(backend_config) + backend.connect() + + # Query all agent types (should return 7 rows) + query = "SELECT type_id, type_name FROM agent_types ORDER BY type_id" + result = backend.execute_query(query) + + assert result is not None, "Should return results" + assert len(result) == 7, f"Expected 7 agent types, got {len(result)}" + # Check specific types are present (alphabetically: agent, bird, env, food, gerbil, rat, target) + type_ids = [row[0] for row in result] + assert "agent" in type_ids, "Should have 'agent' type" + assert "env" in type_ids, "Should have 'env' type" + assert "food" in type_ids, "Should have 'food' type" + assert type_ids[0] == "agent", "First type (alphabetically) should be 'agent'" + + backend.close() + + def test_execute_query_handles_ddl_statements(self, backend_config: DBConfig): + """Test that execute_query handles DDL statements that don't return rows.""" + backend = DatabaseBackend(backend_config) + backend.connect() + + # Create a temporary table + if backend_config.backend == "postgres": + result = backend.execute_query(""" + CREATE TEMPORARY TABLE test_temp (id INTEGER, name VARCHAR) + """) + else: # duckdb + result = backend.execute_query(""" + CREATE TEMPORARY TABLE test_temp (id INTEGER, name VARCHAR) + """) + + # DDL statements should return None (not an empty list) + assert result is None or result == [], "DDL statements should not return rows" + + backend.close() + + def test_execute_query_with_aggregate_functions(self, backend_config: DBConfig): + """Test execute_query with aggregate functions and GROUP BY.""" + backend = DatabaseBackend(backend_config) + backend.connect() + + # Query count of property definitions by data type + query = """ + SELECT data_type, COUNT(*) as count + FROM property_definitions + GROUP BY data_type + ORDER BY data_type + """ + result = backend.execute_query(query) + + assert result is not None, "Should return aggregate results" + assert len(result) > 0, "Should have at least one row" + # Verify structure: each row should have (data_type, count) + for row in result: + assert len(row) == 2, "Each row should have 2 columns" + assert isinstance(row[1], int), "Count should be an integer" + + backend.close() diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 1e049007..2b56d16c 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -99,49 +99,6 @@ def test_rclone_client_integration(): assert isinstance(buckets, list) -@pytest.mark.skip(reason="YML viewer removed from dashboard") -def test_file_viewer_yml(): - """Test YML file viewer functionality.""" - import tempfile - import os - from collab_env.dashboard.file_viewers import ( - FileViewerRegistry, - TextViewer, - ) - - # Test registry creation - registry = FileViewerRegistry() - assert registry is not None - - # Test text viewer assignment for YML - text_viewer = registry.get_viewer("test.yml") - assert text_viewer is not None - assert isinstance(text_viewer, TextViewer) - - # Test text rendering with actual file - test_content = "test: value\nother: 123" - - # Create temporary file for testing - with tempfile.NamedTemporaryFile( - mode="w", suffix=".yml", delete=False - ) as temp_file: - temp_file.write(test_content) - temp_file_path = temp_file.name - - try: - render_info = text_viewer.render_view(temp_file_path, "test.yml") - assert render_info["type"] == "text" - assert "content" in render_info - assert render_info["content"] == test_content - assert render_info["language"] == "yaml" - finally: - # Clean up temporary file - os.unlink(temp_file_path) - - # Test editing capabilities - assert text_viewer.can_edit() - - def test_file_viewer_csv(): """Test CSV file viewer functionality.""" import tempfile