aractingi commited on
Commit
eff9a58
·
1 Parent(s): e8df620

clean debugging and unused functions and vars

Browse files
src/app/[org]/[dataset]/[episode]/episode-viewer.tsx CHANGED
@@ -46,7 +46,6 @@ function EpisodeViewerInner({ data, org, dataset }: { data: any; org?: string; d
46
  videosInfo,
47
  chartDataGroups,
48
  episodes,
49
- ignoredColumns,
50
  } = data;
51
 
52
  const [videosReady, setVideosReady] = useState(!videosInfo.length);
@@ -75,11 +74,10 @@ function EpisodeViewerInner({ data, org, dataset }: { data: any; org?: string; d
75
 
76
  const preloadAdjacent = async () => {
77
  try {
78
- const adjacentInfo = await getAdjacentEpisodesVideoInfo(org, dataset, episodeId, 2);
79
- // The OptimizedVideosPlayer will handle preloading these URLs automatically
80
- console.log(`Preloading videos for ${adjacentInfo.length} adjacent episodes`);
81
- } catch (err) {
82
- console.warn("Failed to preload adjacent episodes:", err);
83
  }
84
  };
85
 
 
46
  videosInfo,
47
  chartDataGroups,
48
  episodes,
 
49
  } = data;
50
 
51
  const [videosReady, setVideosReady] = useState(!videosInfo.length);
 
74
 
75
  const preloadAdjacent = async () => {
76
  try {
77
+ await getAdjacentEpisodesVideoInfo(org, dataset, episodeId, 2);
78
+ // Preload adjacent episodes for smoother navigation
79
+ } catch {
80
+ // Skip preloading on error
 
81
  }
82
  };
83
 
src/app/[org]/[dataset]/[episode]/fetch-data.ts CHANGED
@@ -8,9 +8,6 @@ import {
8
  import { pick } from "@/utils/pick";
9
  import { getDatasetVersion, buildVersionedUrl } from "@/utils/versionUtils";
10
 
11
- const DATASET_URL =
12
- process.env.DATASET_URL || "https://huggingface.co/datasets";
13
-
14
  const SERIES_NAME_DELIMITER = " | ";
15
 
16
  export async function getEpisodeData(
@@ -22,18 +19,13 @@ export async function getEpisodeData(
22
  try {
23
  // Check for compatible dataset version (v3.0, v2.1, or v2.0)
24
  const version = await getDatasetVersion(repoId);
25
- console.log(`[DEBUG] Detected dataset version: ${version} for ${repoId}`);
26
-
27
  const jsonUrl = buildVersionedUrl(repoId, version, "meta/info.json");
28
-
29
  const info = await fetchJson<DatasetMetadata>(jsonUrl);
30
 
31
  // Handle different versions
32
  if (version === "v3.0") {
33
- console.log(`[DEBUG] Using v3.0 data loader for ${repoId}`);
34
  return await getEpisodeDataV3(repoId, version, info, episodeId);
35
  } else {
36
- console.log(`[DEBUG] Using v2.x data loader for ${repoId} (version: ${version})`);
37
  return await getEpisodeDataV2(repoId, version, info, episodeId);
38
  }
39
  } catch (err) {
@@ -74,8 +66,8 @@ export async function getAdjacentEpisodesVideoInfo(
74
  // For v2.x, use simpler video info extraction
75
  const episode_chunk = Math.floor(0 / 1000);
76
  videosInfo = Object.entries(info.features)
77
- .filter(([key, value]) => value.dtype === "video")
78
- .map(([key, _]) => {
79
  const videoPath = formatStringWithVars(info.video_path, {
80
  video_key: key,
81
  episode_chunk: episode_chunk.toString().padStart(3, "0"),
@@ -89,15 +81,15 @@ export async function getAdjacentEpisodesVideoInfo(
89
  }
90
 
91
  adjacentVideos.push({ episodeId, videosInfo });
92
- } catch (err) {
93
- console.warn(`Failed to get video info for episode ${episodeId}:`, err);
94
- }
95
  }
96
  }
97
 
98
  return adjacentVideos;
99
- } catch (err) {
100
- console.error("Error getting adjacent episodes video info:", err);
101
  return [];
102
  }
103
  }
@@ -132,10 +124,10 @@ async function getEpisodeDataV2(
132
  .map((x) => parseInt(x.trim(), 10))
133
  .filter((x) => !isNaN(x));
134
 
135
- // Videos information
136
- const videosInfo = Object.entries(info.features)
137
- .filter(([key, value]) => value.dtype === "video")
138
- .map(([key, _]) => {
139
  const videoPath = formatStringWithVars(info.video_path, {
140
  video_key: key,
141
  episode_chunk: episode_chunk.toString().padStart(3, "0"),
@@ -150,7 +142,7 @@ async function getEpisodeDataV2(
150
  // Column data
151
  const columnNames = Object.entries(info.features)
152
  .filter(
153
- ([key, value]) =>
154
  ["float32", "int32"].includes(value.dtype) &&
155
  value.shape.length === 1,
156
  )
@@ -218,7 +210,7 @@ async function getEpisodeDataV2(
218
  // List of columns that are ignored (e.g., 2D or 3D data)
219
  const ignoredColumns = Object.entries(info.features)
220
  .filter(
221
- ([key, value]) =>
222
  ["float32", "int32"].includes(value.dtype) && value.shape.length > 1,
223
  )
224
  .map(([key]) => key);
@@ -354,8 +346,6 @@ async function getEpisodeDataV3(
354
  info: DatasetMetadata,
355
  episodeId: number,
356
  ) {
357
- console.log(`[DEBUG] Loading v3.0 episode data for ${repoId}, episode ${episodeId}`);
358
-
359
  // Create dataset info structure (like v2.x)
360
  const datasetInfo = {
361
  repoId,
@@ -366,7 +356,6 @@ async function getEpisodeDataV3(
366
 
367
  // Generate episodes list based on total_episodes from dataset info
368
  const episodes = Array.from({ length: info.total_episodes }, (_, i) => i);
369
- console.log(`[DEBUG] Available episodes: ${episodes.length} (0 to ${episodes.length - 1})`);
370
 
371
  // Load episode metadata to get timestamps for episode 0
372
  const episodeMetadata = await loadEpisodeMetadataV3Simple(repoId, version, episodeId);
@@ -384,7 +373,7 @@ async function getEpisodeDataV3(
384
  chartDataGroups,
385
  episodes,
386
  ignoredColumns,
387
- duration: episodeMetadata.video_to_timestamp - episodeMetadata.video_from_timestamp, // Use actual episode duration
388
  };
389
  }
390
 
@@ -395,36 +384,23 @@ async function loadEpisodeDataV3(
395
  info: DatasetMetadata,
396
  episodeMetadata: any,
397
  ): Promise<{ chartDataGroups: any[]; ignoredColumns: string[] }> {
398
- console.log(`[DEBUG] Loading v3.0 data for episode ${episodeMetadata.episode_index}`);
399
-
400
  // Build data file path using chunk and file indices
401
  const dataChunkIndex = episodeMetadata.data_chunk_index || 0;
402
  const dataFileIndex = episodeMetadata.data_file_index || 0;
403
  const dataPath = `data/chunk-${dataChunkIndex.toString().padStart(3, "0")}/file-${dataFileIndex.toString().padStart(3, "0")}.parquet`;
404
 
405
- console.log(`[DEBUG] Loading data from: ${dataPath}`);
406
- console.log(`[DEBUG] Data range: ${episodeMetadata.dataset_from_index} to ${episodeMetadata.dataset_to_index}`);
407
-
408
  try {
409
  const dataUrl = buildVersionedUrl(repoId, version, dataPath);
410
  const arrayBuffer = await fetchParquetFile(dataUrl);
411
  const fullData = await readParquetColumn(arrayBuffer, []);
412
 
413
- console.log(`[DEBUG] Loaded ${fullData.length} total data rows`);
414
-
415
  // Extract the episode-specific data slice
416
  // Convert BigInt to number if needed
417
  const fromIndex = Number(episodeMetadata.dataset_from_index || 0);
418
  const toIndex = Number(episodeMetadata.dataset_to_index || fullData.length);
419
-
420
- console.log(`[DEBUG] Converting indices: ${episodeMetadata.dataset_from_index} → ${fromIndex}, ${episodeMetadata.dataset_to_index} → ${toIndex}`);
421
-
422
  const episodeData = fullData.slice(fromIndex, toIndex);
423
 
424
- console.log(`[DEBUG] Episode data slice: ${episodeData.length} rows (${fromIndex} to ${toIndex})`);
425
-
426
  if (episodeData.length === 0) {
427
- console.log(`[DEBUG] No data found for episode ${episodeMetadata.episode_index}`);
428
  return { chartDataGroups: [], ignoredColumns: [] };
429
  }
430
 
@@ -432,8 +408,7 @@ async function loadEpisodeDataV3(
432
  const { chartDataGroups, ignoredColumns } = processEpisodeDataForCharts(episodeData, info, episodeMetadata);
433
 
434
  return { chartDataGroups, ignoredColumns };
435
- } catch (error) {
436
- console.error(`[DEBUG] Failed to load episode data:`, error);
437
  return { chartDataGroups: [], ignoredColumns: [] };
438
  }
439
  }
@@ -444,12 +419,11 @@ function processEpisodeDataForCharts(
444
  info: DatasetMetadata,
445
  episodeMetadata?: any,
446
  ): { chartDataGroups: any[]; ignoredColumns: string[] } {
447
- const SERIES_NAME_DELIMITER = ".";
448
 
449
  // Get numeric column features
450
  const columnNames = Object.entries(info.features)
451
  .filter(
452
- ([key, value]) =>
453
  ["float32", "int32"].includes(value.dtype) &&
454
  value.shape.length === 1,
455
  )
@@ -503,8 +477,6 @@ function processEpisodeDataForCharts(
503
  });
504
 
505
  seriesNames = ["timestamp", ...allKeys];
506
- console.log(`[DEBUG] Detected series:`, allKeys);
507
- console.log(`[DEBUG] First row sample:`, firstRow);
508
  } else {
509
  // Fallback to feature-based approach
510
  seriesNames = [
@@ -526,11 +498,6 @@ function processEpisodeDataForCharts(
526
  obj["timestamp"] = (index / Math.max(episodeData.length - 1, 1)) * videoDuration;
527
 
528
  // For v3.0, data might have numeric string keys, so we need to map them
529
- // Get all available keys from the first row to understand the structure
530
- if (index === 0) {
531
- console.log(`[DEBUG] Data row keys:`, Object.keys(row || {}));
532
- console.log(`[DEBUG] Available features:`, Object.keys(info.features));
533
- }
534
 
535
  // Add all data columns
536
  if (row && typeof row === 'object') {
@@ -570,7 +537,7 @@ function processEpisodeDataForCharts(
570
  const ignoredColumns = [
571
  ...Object.entries(info.features)
572
  .filter(
573
- ([key, value]) =>
574
  ["float32", "int32"].includes(value.dtype) && value.shape.length > 2, // Only ignore 3D+ data
575
  )
576
  .map(([key]) => key),
@@ -620,7 +587,6 @@ function processEpisodeDataForCharts(
620
  }
621
  const suffixGroups = Object.values(suffixGroupsMap);
622
 
623
- console.log(`[DEBUG] Created suffix groups:`, suffixGroupsMap);
624
 
625
  // Compute min/max for each suffix group
626
  const groupStats: Record<string, { min: number; max: number }> = {};
@@ -745,39 +711,10 @@ function processEpisodeDataForCharts(
745
  chartData.map((row) => groupRowBySuffix(pick(row, [...group, "timestamp"])))
746
  );
747
 
748
- console.log(`[DEBUG] Generated ${chartDataGroups.length} chart groups`);
749
- console.log(`[DEBUG] Chart groups structure:`, chartGroups);
750
- if (chartDataGroups.length > 0 && chartDataGroups[0].length > 0) {
751
- console.log(`[DEBUG] Sample chart data:`, chartDataGroups[0][0]);
752
- }
753
 
754
  return { chartDataGroups, ignoredColumns };
755
  }
756
 
757
- // Simplified video info extraction for v3.0 - just use first chunk files
758
- function extractSimpleVideoInfoV3(
759
- repoId: string,
760
- version: string,
761
- info: DatasetMetadata,
762
- ): any[] {
763
- // Get video features from dataset info
764
- const videoFeatures = Object.entries(info.features)
765
- .filter(([key, value]) => value.dtype === "video");
766
-
767
- const videosInfo = videoFeatures.map(([videoKey, _]) => {
768
- // For simplified version, just use chunk-000/file-000.mp4
769
- const videoPath = `videos/${videoKey}/chunk-000/file-000.mp4`;
770
-
771
- return {
772
- filename: videoKey,
773
- url: buildVersionedUrl(repoId, version, videoPath),
774
- // No segmentation - just show the full video file
775
- isSegmented: false,
776
- };
777
- });
778
-
779
- return videosInfo;
780
- }
781
 
782
  // Video info extraction with segmentation for v3.0
783
  function extractVideoInfoV3WithSegmentation(
@@ -788,9 +725,9 @@ function extractVideoInfoV3WithSegmentation(
788
  ): any[] {
789
  // Get video features from dataset info
790
  const videoFeatures = Object.entries(info.features)
791
- .filter(([key, value]) => value.dtype === "video");
792
 
793
- const videosInfo = videoFeatures.map(([videoKey, _]) => {
794
  // Use chunk and file indices from metadata
795
  const chunkIndex = episodeMetadata.video_chunk_index || 0;
796
  const fileIndex = episodeMetadata.video_file_index || 0;
@@ -798,9 +735,6 @@ function extractVideoInfoV3WithSegmentation(
798
  const videoPath = `videos/${videoKey}/chunk-${chunkIndex.toString().padStart(3, "0")}/file-${fileIndex.toString().padStart(3, "0")}.mp4`;
799
  const fullUrl = buildVersionedUrl(repoId, version, videoPath);
800
 
801
- console.log(`[DEBUG] Video URL for ${videoKey}: ${fullUrl}`);
802
- console.log(`[DEBUG] Chunk index: ${chunkIndex}, File index: ${fileIndex}`);
803
- console.log(`[DEBUG] Timestamps: ${episodeMetadata.video_from_timestamp} to ${episodeMetadata.video_to_timestamp}`);
804
 
805
  return {
806
  filename: videoKey,
@@ -813,7 +747,6 @@ function extractVideoInfoV3WithSegmentation(
813
  };
814
  });
815
 
816
- console.log(`[DEBUG] Created segmented video info:`, videosInfo);
817
  return videosInfo;
818
  }
819
 
@@ -823,8 +756,6 @@ async function loadEpisodeMetadataV3Simple(
823
  version: string,
824
  episodeId: number,
825
  ): Promise<any> {
826
- console.log(`[DEBUG] Loading v3.0 metadata for episode ${episodeId}`);
827
-
828
  const episodesMetadataUrl = buildVersionedUrl(
829
  repoId,
830
  version,
@@ -835,8 +766,6 @@ async function loadEpisodeMetadataV3Simple(
835
  const arrayBuffer = await fetchParquetFile(episodesMetadataUrl);
836
  const episodesData = await readParquetColumn(arrayBuffer, []);
837
 
838
- console.log(`[DEBUG] Loaded ${episodesData.length} episode rows`);
839
-
840
  if (episodesData.length === 0) {
841
  throw new Error("No episode metadata found");
842
  }
@@ -844,13 +773,12 @@ async function loadEpisodeMetadataV3Simple(
844
  // Find the row for the requested episode
845
  let episodeRow = null;
846
 
847
- for (let i = 0; i < episodesData.length; i++) { // Check all rows
848
  const row = episodesData[i];
849
- const parsedRow = parseEpisodeRowSimple(row, false); // Don't log for each attempt
850
 
851
  if (parsedRow.episode_index === episodeId) {
852
  episodeRow = row;
853
- console.log(`[DEBUG] Found episode ${episodeId} at row ${i}`);
854
  break;
855
  }
856
  }
@@ -859,26 +787,20 @@ async function loadEpisodeMetadataV3Simple(
859
  // Fallback: if we can't find the exact episode, use the row at index episodeId
860
  if (episodeId < episodesData.length) {
861
  episodeRow = episodesData[episodeId];
862
- console.log(`[DEBUG] Using fallback row ${episodeId} for episode ${episodeId}`);
863
  } else {
864
  throw new Error(`Episode ${episodeId} not found in metadata`);
865
  }
866
  }
867
 
868
  // Convert the row to a usable format
869
- return parseEpisodeRowSimple(episodeRow, true); // Enable logging for final parse
870
  } catch (error) {
871
- console.error(`Failed to load episode metadata:`, error);
872
  throw error;
873
  }
874
  }
875
 
876
  // Simple parser for episode row - focuses on key fields for episodes
877
- function parseEpisodeRowSimple(row: any, enableLogging: boolean = true): any {
878
- if (enableLogging) {
879
- console.log(`[DEBUG] Parsing episode row with keys:`, Object.keys(row || {}));
880
- console.log(`[DEBUG] Row type:`, typeof row);
881
- }
882
 
883
  // Based on the debug output we saw, the row has numeric string keys
884
  // We'll need to map these to meaningful field names
@@ -900,23 +822,6 @@ function parseEpisodeRowSimple(row: any, enableLogging: boolean = true): any {
900
  length: row['9'] || 30, // Episode length
901
  };
902
 
903
- if (enableLogging) {
904
- console.log(`[DEBUG] Raw row values:`);
905
- console.log(` Row['0'] (episode_index): ${row['0']}`);
906
- console.log(` Row['1'] (data_chunk_index): ${row['1']}`);
907
- console.log(` Row['2'] (data_file_index): ${row['2']}`);
908
- console.log(` Row['3'] (dataset_from_index): ${row['3']}`);
909
- console.log(` Row['4'] (dataset_to_index): ${row['4']}`);
910
- console.log(` Row['5'] (video_chunk_index): ${row['5']}`);
911
- console.log(` Row['6'] (video_file_index): ${row['6']}`);
912
- console.log(` Row['7'] (video_from_timestamp): ${row['7']}`);
913
- console.log(` Row['8'] (video_to_timestamp): ${row['8']}`);
914
- console.log(` Row['9'] (length): ${row['9']}`);
915
- }
916
-
917
- if (enableLogging) {
918
- console.log(`[DEBUG] Parsed episode data:`, episodeData);
919
- }
920
  return episodeData;
921
  }
922
 
@@ -934,87 +839,11 @@ function parseEpisodeRowSimple(row: any, enableLogging: boolean = true): any {
934
  length: 30,
935
  };
936
 
937
- if (enableLogging) {
938
- console.log(`[DEBUG] Using fallback episode data:`, fallback);
939
- }
940
  return fallback;
941
  }
942
 
943
- // Parse episode metadata row into structured object
944
- function parseEpisodeRow(row: any): any {
945
- // This is a placeholder - the actual structure depends on how the parquet data is organized
946
- // You may need to adjust this based on the actual column names and order
947
- if (Array.isArray(row)) {
948
- // If it's an array, we need to map positions to field names
949
- // This is a rough mapping - needs to be adjusted based on actual data structure
950
- return {
951
- episode_index: row[0],
952
- data_chunk_index: row[1],
953
- data_file_index: row[2],
954
- dataset_from_index: row[3],
955
- dataset_to_index: row[4],
956
- video_chunk_index: row[5],
957
- video_file_index: row[6],
958
- video_from_timestamp: row[7],
959
- video_to_timestamp: row[8],
960
- length: row[9],
961
- // Add more fields as needed
962
- };
963
- } else {
964
- // If it's already an object, return as-is
965
- return row;
966
- }
967
- }
968
-
969
- // Extract video information for v3.0 format
970
- async function extractVideoInfoV3(
971
- repoId: string,
972
- version: string,
973
- info: DatasetMetadata,
974
- episodeMetadata: any,
975
- ): Promise<any[]> {
976
- // Get video features from dataset info
977
- const videoFeatures = Object.entries(info.features)
978
- .filter(([key, value]) => value.dtype === "video");
979
-
980
- const videosInfo = videoFeatures.map(([videoKey, _]) => {
981
- // For v3.0, video path format is: videos/camera_key/chunk-000/file-000.mp4
982
- // Extract the appropriate chunk and file indices for this video key
983
- const videoChunkKey = `videos/${videoKey}/chunk_index`;
984
- const videoFileKey = `videos/${videoKey}/file_index`;
985
- const videoFromTimestampKey = `videos/${videoKey}/from_timestamp`;
986
- const videoToTimestampKey = `videos/${videoKey}/to_timestamp`;
987
-
988
- const chunkIndex = episodeMetadata[videoChunkKey] || 0;
989
- const fileIndex = episodeMetadata[videoFileKey] || 0;
990
- const fromTimestamp = episodeMetadata[videoFromTimestampKey] || 0;
991
- const toTimestamp = episodeMetadata[videoToTimestampKey] || 0;
992
-
993
- const videoPath = `videos/${videoKey}/chunk-${chunkIndex.toString().padStart(3, "0")}/file-${fileIndex.toString().padStart(3, "0")}.mp4`;
994
-
995
- return {
996
- filename: videoKey,
997
- url: buildVersionedUrl(repoId, version, videoPath),
998
- // Segment information for v3.0 chunked videos
999
- isSegmented: true,
1000
- segmentStart: fromTimestamp,
1001
- segmentEnd: toTimestamp,
1002
- segmentDuration: toTimestamp - fromTimestamp,
1003
- };
1004
- });
1005
 
1006
- return videosInfo;
1007
- }
1008
 
1009
- // DISABLED: Complex episode data loading for simplified v3.0 implementation
1010
- /*
1011
- async function loadEpisodeDataV3(
1012
- episodeMetadata: any,
1013
- ): Promise<{ chartDataGroups: any[]; ignoredColumns: string[]; duration: number }> {
1014
- // Complex data loading disabled for simplified implementation
1015
- throw new Error("Complex data loading disabled in simplified v3.0 implementation");
1016
- }
1017
- */
1018
 
1019
  // Safe wrapper for UI error display
1020
  export async function getEpisodeDataSafe(
 
8
  import { pick } from "@/utils/pick";
9
  import { getDatasetVersion, buildVersionedUrl } from "@/utils/versionUtils";
10
 
 
 
 
11
  const SERIES_NAME_DELIMITER = " | ";
12
 
13
  export async function getEpisodeData(
 
19
  try {
20
  // Check for compatible dataset version (v3.0, v2.1, or v2.0)
21
  const version = await getDatasetVersion(repoId);
 
 
22
  const jsonUrl = buildVersionedUrl(repoId, version, "meta/info.json");
 
23
  const info = await fetchJson<DatasetMetadata>(jsonUrl);
24
 
25
  // Handle different versions
26
  if (version === "v3.0") {
 
27
  return await getEpisodeDataV3(repoId, version, info, episodeId);
28
  } else {
 
29
  return await getEpisodeDataV2(repoId, version, info, episodeId);
30
  }
31
  } catch (err) {
 
66
  // For v2.x, use simpler video info extraction
67
  const episode_chunk = Math.floor(0 / 1000);
68
  videosInfo = Object.entries(info.features)
69
+ .filter(([, value]) => value.dtype === "video")
70
+ .map(([key]) => {
71
  const videoPath = formatStringWithVars(info.video_path, {
72
  video_key: key,
73
  episode_chunk: episode_chunk.toString().padStart(3, "0"),
 
81
  }
82
 
83
  adjacentVideos.push({ episodeId, videosInfo });
84
+ } catch {
85
+ // Skip failed episodes silently
86
+ }
87
  }
88
  }
89
 
90
  return adjacentVideos;
91
+ } catch {
92
+ // Return empty array on error
93
  return [];
94
  }
95
  }
 
124
  .map((x) => parseInt(x.trim(), 10))
125
  .filter((x) => !isNaN(x));
126
 
127
+ // Videos information
128
+ const videosInfo = Object.entries(info.features)
129
+ .filter(([, value]) => value.dtype === "video")
130
+ .map(([key]) => {
131
  const videoPath = formatStringWithVars(info.video_path, {
132
  video_key: key,
133
  episode_chunk: episode_chunk.toString().padStart(3, "0"),
 
142
  // Column data
143
  const columnNames = Object.entries(info.features)
144
  .filter(
145
+ ([, value]) =>
146
  ["float32", "int32"].includes(value.dtype) &&
147
  value.shape.length === 1,
148
  )
 
210
  // List of columns that are ignored (e.g., 2D or 3D data)
211
  const ignoredColumns = Object.entries(info.features)
212
  .filter(
213
+ ([, value]) =>
214
  ["float32", "int32"].includes(value.dtype) && value.shape.length > 1,
215
  )
216
  .map(([key]) => key);
 
346
  info: DatasetMetadata,
347
  episodeId: number,
348
  ) {
 
 
349
  // Create dataset info structure (like v2.x)
350
  const datasetInfo = {
351
  repoId,
 
356
 
357
  // Generate episodes list based on total_episodes from dataset info
358
  const episodes = Array.from({ length: info.total_episodes }, (_, i) => i);
 
359
 
360
  // Load episode metadata to get timestamps for episode 0
361
  const episodeMetadata = await loadEpisodeMetadataV3Simple(repoId, version, episodeId);
 
373
  chartDataGroups,
374
  episodes,
375
  ignoredColumns,
376
+ duration: episodeMetadata.video_to_timestamp - episodeMetadata.video_from_timestamp,
377
  };
378
  }
379
 
 
384
  info: DatasetMetadata,
385
  episodeMetadata: any,
386
  ): Promise<{ chartDataGroups: any[]; ignoredColumns: string[] }> {
 
 
387
  // Build data file path using chunk and file indices
388
  const dataChunkIndex = episodeMetadata.data_chunk_index || 0;
389
  const dataFileIndex = episodeMetadata.data_file_index || 0;
390
  const dataPath = `data/chunk-${dataChunkIndex.toString().padStart(3, "0")}/file-${dataFileIndex.toString().padStart(3, "0")}.parquet`;
391
 
 
 
 
392
  try {
393
  const dataUrl = buildVersionedUrl(repoId, version, dataPath);
394
  const arrayBuffer = await fetchParquetFile(dataUrl);
395
  const fullData = await readParquetColumn(arrayBuffer, []);
396
 
 
 
397
  // Extract the episode-specific data slice
398
  // Convert BigInt to number if needed
399
  const fromIndex = Number(episodeMetadata.dataset_from_index || 0);
400
  const toIndex = Number(episodeMetadata.dataset_to_index || fullData.length);
 
 
 
401
  const episodeData = fullData.slice(fromIndex, toIndex);
402
 
 
 
403
  if (episodeData.length === 0) {
 
404
  return { chartDataGroups: [], ignoredColumns: [] };
405
  }
406
 
 
408
  const { chartDataGroups, ignoredColumns } = processEpisodeDataForCharts(episodeData, info, episodeMetadata);
409
 
410
  return { chartDataGroups, ignoredColumns };
411
+ } catch {
 
412
  return { chartDataGroups: [], ignoredColumns: [] };
413
  }
414
  }
 
419
  info: DatasetMetadata,
420
  episodeMetadata?: any,
421
  ): { chartDataGroups: any[]; ignoredColumns: string[] } {
 
422
 
423
  // Get numeric column features
424
  const columnNames = Object.entries(info.features)
425
  .filter(
426
+ ([, value]) =>
427
  ["float32", "int32"].includes(value.dtype) &&
428
  value.shape.length === 1,
429
  )
 
477
  });
478
 
479
  seriesNames = ["timestamp", ...allKeys];
 
 
480
  } else {
481
  // Fallback to feature-based approach
482
  seriesNames = [
 
498
  obj["timestamp"] = (index / Math.max(episodeData.length - 1, 1)) * videoDuration;
499
 
500
  // For v3.0, data might have numeric string keys, so we need to map them
 
 
 
 
 
501
 
502
  // Add all data columns
503
  if (row && typeof row === 'object') {
 
537
  const ignoredColumns = [
538
  ...Object.entries(info.features)
539
  .filter(
540
+ ([, value]) =>
541
  ["float32", "int32"].includes(value.dtype) && value.shape.length > 2, // Only ignore 3D+ data
542
  )
543
  .map(([key]) => key),
 
587
  }
588
  const suffixGroups = Object.values(suffixGroupsMap);
589
 
 
590
 
591
  // Compute min/max for each suffix group
592
  const groupStats: Record<string, { min: number; max: number }> = {};
 
711
  chartData.map((row) => groupRowBySuffix(pick(row, [...group, "timestamp"])))
712
  );
713
 
 
 
 
 
 
714
 
715
  return { chartDataGroups, ignoredColumns };
716
  }
717
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
718
 
719
  // Video info extraction with segmentation for v3.0
720
  function extractVideoInfoV3WithSegmentation(
 
725
  ): any[] {
726
  // Get video features from dataset info
727
  const videoFeatures = Object.entries(info.features)
728
+ .filter(([, value]) => value.dtype === "video");
729
 
730
+ const videosInfo = videoFeatures.map(([videoKey]) => {
731
  // Use chunk and file indices from metadata
732
  const chunkIndex = episodeMetadata.video_chunk_index || 0;
733
  const fileIndex = episodeMetadata.video_file_index || 0;
 
735
  const videoPath = `videos/${videoKey}/chunk-${chunkIndex.toString().padStart(3, "0")}/file-${fileIndex.toString().padStart(3, "0")}.mp4`;
736
  const fullUrl = buildVersionedUrl(repoId, version, videoPath);
737
 
 
 
 
738
 
739
  return {
740
  filename: videoKey,
 
747
  };
748
  });
749
 
 
750
  return videosInfo;
751
  }
752
 
 
756
  version: string,
757
  episodeId: number,
758
  ): Promise<any> {
 
 
759
  const episodesMetadataUrl = buildVersionedUrl(
760
  repoId,
761
  version,
 
766
  const arrayBuffer = await fetchParquetFile(episodesMetadataUrl);
767
  const episodesData = await readParquetColumn(arrayBuffer, []);
768
 
 
 
769
  if (episodesData.length === 0) {
770
  throw new Error("No episode metadata found");
771
  }
 
773
  // Find the row for the requested episode
774
  let episodeRow = null;
775
 
776
+ for (let i = 0; i < episodesData.length; i++) {
777
  const row = episodesData[i];
778
+ const parsedRow = parseEpisodeRowSimple(row);
779
 
780
  if (parsedRow.episode_index === episodeId) {
781
  episodeRow = row;
 
782
  break;
783
  }
784
  }
 
787
  // Fallback: if we can't find the exact episode, use the row at index episodeId
788
  if (episodeId < episodesData.length) {
789
  episodeRow = episodesData[episodeId];
 
790
  } else {
791
  throw new Error(`Episode ${episodeId} not found in metadata`);
792
  }
793
  }
794
 
795
  // Convert the row to a usable format
796
+ return parseEpisodeRowSimple(episodeRow);
797
  } catch (error) {
 
798
  throw error;
799
  }
800
  }
801
 
802
  // Simple parser for episode row - focuses on key fields for episodes
803
+ function parseEpisodeRowSimple(row: any): any {
 
 
 
 
804
 
805
  // Based on the debug output we saw, the row has numeric string keys
806
  // We'll need to map these to meaningful field names
 
822
  length: row['9'] || 30, // Episode length
823
  };
824
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
825
  return episodeData;
826
  }
827
 
 
839
  length: 30,
840
  };
841
 
 
 
 
842
  return fallback;
843
  }
844
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
845
 
 
 
846
 
 
 
 
 
 
 
 
 
 
847
 
848
  // Safe wrapper for UI error display
849
  export async function getEpisodeDataSafe(
src/app/explore/page.tsx CHANGED
@@ -35,7 +35,7 @@ export default async function ExplorePage({
35
  const startIdx = (currentPage - 1) * perPage;
36
  const endIdx = startIdx + perPage;
37
  datasets = allDatasets.slice(startIdx, endIdx);
38
- } catch (e) {
39
  return <div className="p-8 text-red-600">Failed to load datasets.</div>;
40
  }
41
 
@@ -60,7 +60,7 @@ export default async function ExplorePage({
60
  const jsonUrl = buildVersionedUrl(repoId, version, "meta/info.json");
61
  const info = await fetchJson<DatasetMetadata>(jsonUrl);
62
  const videoEntry = Object.entries(info.features).find(
63
- ([key, value]) => value.dtype === "video",
64
  );
65
  let videoUrl: string | null = null;
66
  if (videoEntry) {
@@ -77,7 +77,7 @@ export default async function ExplorePage({
77
  if (headRes.ok) {
78
  videoUrl = url;
79
  }
80
- } catch (e) {
81
  // If fetch fails, videoUrl remains null
82
  }
83
  }
 
35
  const startIdx = (currentPage - 1) * perPage;
36
  const endIdx = startIdx + perPage;
37
  datasets = allDatasets.slice(startIdx, endIdx);
38
+ } catch {
39
  return <div className="p-8 text-red-600">Failed to load datasets.</div>;
40
  }
41
 
 
60
  const jsonUrl = buildVersionedUrl(repoId, version, "meta/info.json");
61
  const info = await fetchJson<DatasetMetadata>(jsonUrl);
62
  const videoEntry = Object.entries(info.features).find(
63
+ ([, value]) => value.dtype === "video",
64
  );
65
  let videoUrl: string | null = null;
66
  if (videoEntry) {
 
77
  if (headRes.ok) {
78
  videoUrl = url;
79
  }
80
+ } catch {
81
  // If fetch fails, videoUrl remains null
82
  }
83
  }
src/components/simple-videos-player.tsx CHANGED
@@ -121,7 +121,7 @@ export const SimpleVideosPlayer = ({
121
  if (isPlaying) {
122
  video.play().catch(e => {
123
  if (e.name !== 'AbortError') {
124
- console.error("Error playing video:", e);
125
  }
126
  });
127
  } else {
 
121
  if (isPlaying) {
122
  video.play().catch(e => {
123
  if (e.name !== 'AbortError') {
124
+ console.error("Error playing video");
125
  }
126
  });
127
  } else {
src/components/videos-player.tsx CHANGED
@@ -89,7 +89,7 @@ export const VideosPlayer = ({
89
  videoRefs.current.forEach((video) => {
90
  if (video) {
91
  if (isPlaying) {
92
- video.play().catch((e) => console.error("Error playing video:", e));
93
  } else {
94
  video.pause();
95
  }
@@ -202,7 +202,6 @@ export const VideosPlayer = ({
202
  const segmentStart = videoInfo.segmentStart || 0;
203
  const segmentEnd = videoInfo.segmentEnd || video.duration || 0;
204
 
205
- console.log(`[VIDEO DEBUG] Setting up segmentation for ${videoInfo.filename}: ${segmentStart}s to ${segmentEnd}s`);
206
 
207
  // Set initial time to segment start if not already set
208
  if (video.currentTime < segmentStart || video.currentTime > segmentEnd) {
 
89
  videoRefs.current.forEach((video) => {
90
  if (video) {
91
  if (isPlaying) {
92
+ video.play().catch(() => console.error("Error playing video"));
93
  } else {
94
  video.pause();
95
  }
 
202
  const segmentStart = videoInfo.segmentStart || 0;
203
  const segmentEnd = videoInfo.segmentEnd || video.duration || 0;
204
 
 
205
 
206
  // Set initial time to segment start if not already set
207
  if (video.currentTime < segmentStart || video.currentTime > segmentEnd) {
src/utils/parquetUtils.ts CHANGED
@@ -53,21 +53,17 @@ export async function readParquetColumn(
53
  columns: string[],
54
  ): Promise<any[]> {
55
  return new Promise((resolve, reject) => {
56
- parquetRead({
57
- file: fileBuffer,
58
- columns: columns.length > 0 ? columns : undefined, // Let hyparquet read all columns if empty array
59
- onComplete: (data: any[]) => {
60
- console.log('[DEBUG] Parquet read completed, data length:', data.length);
61
- if (data.length > 0) {
62
- console.log('[DEBUG] First data row structure:', typeof data[0], Object.keys(data[0] || {}));
63
  }
64
- resolve(data);
65
- },
66
- onError: (error: any) => {
67
- console.error('[DEBUG] Parquet read error:', error);
68
- reject(error);
69
- }
70
- });
71
  });
72
  }
73
 
 
53
  columns: string[],
54
  ): Promise<any[]> {
55
  return new Promise((resolve, reject) => {
56
+ try {
57
+ parquetRead({
58
+ file: fileBuffer,
59
+ columns: columns.length > 0 ? columns : undefined, // Let hyparquet read all columns if empty array
60
+ onComplete: (data: any[]) => {
61
+ resolve(data);
 
62
  }
63
+ });
64
+ } catch (error) {
65
+ reject(error);
66
+ }
 
 
 
67
  });
68
  }
69
 
src/utils/versionUtils.ts CHANGED
@@ -70,40 +70,30 @@ async function checkV3ChunkedStructure(repoId: string): Promise<boolean> {
70
  * Prefers v3.0, falls back to v2.1, then v2.0, or throws an error if none exist.
71
  */
72
  export async function getDatasetVersion(repoId: string): Promise<string> {
73
- console.log(`[VERSION DEBUG] Checking versions for ${repoId}`);
74
-
75
  // Check for v3.0 first - must have both info.json AND chunked episode structure
76
  const hasV3Info = await checkVersionExists(repoId, "v3.0");
77
- console.log(`[VERSION DEBUG] v3.0 info.json exists: ${hasV3Info}`);
78
 
79
  if (hasV3Info) {
80
  const hasV3Structure = await checkV3ChunkedStructure(repoId);
81
- console.log(`[VERSION DEBUG] v3.0 chunked structure exists: ${hasV3Structure}`);
82
 
83
  if (hasV3Structure) {
84
- console.log(`[VERSION DEBUG] Using v3.0 for ${repoId}`);
85
  return "v3.0";
86
  }
87
  }
88
 
89
  // Check for v2.1
90
  const hasV21 = await checkVersionExists(repoId, "v2.1");
91
- console.log(`[VERSION DEBUG] v2.1 exists: ${hasV21}`);
92
  if (hasV21) {
93
- console.log(`[VERSION DEBUG] Using v2.1 for ${repoId}`);
94
  return "v2.1";
95
  }
96
 
97
  // Fall back to v2.0
98
  const hasV20 = await checkVersionExists(repoId, "v2.0");
99
- console.log(`[VERSION DEBUG] v2.0 exists: ${hasV20}`);
100
  if (hasV20) {
101
- console.log(`[VERSION DEBUG] Using v2.0 for ${repoId}`);
102
  return "v2.0";
103
  }
104
 
105
  // If none of the supported versions exist, throw an error
106
- console.log(`[VERSION DEBUG] No compatible versions found for ${repoId}`);
107
  throw new Error(
108
  `Dataset ${repoId} is not compatible with this visualizer. ` +
109
  "This tool only works with dataset versions 3.0, 2.1, or 2.0. " +
@@ -118,15 +108,3 @@ export function buildVersionedUrl(repoId: string, version: string, path: string)
118
  return `${DATASET_URL}/${repoId}/resolve/${version}/${path}`;
119
  }
120
 
121
- /**
122
- * Debug function to test version checking manually
123
- */
124
- export async function testVersionCheck(repoId: string): Promise<void> {
125
- console.log(`Testing version check for: ${repoId}`);
126
- try {
127
- const version = await getDatasetVersion(repoId);
128
- console.log(`Success! Best version found: ${version}`);
129
- } catch (error) {
130
- console.error(`Failed:`, error);
131
- }
132
- }
 
70
  * Prefers v3.0, falls back to v2.1, then v2.0, or throws an error if none exist.
71
  */
72
  export async function getDatasetVersion(repoId: string): Promise<string> {
 
 
73
  // Check for v3.0 first - must have both info.json AND chunked episode structure
74
  const hasV3Info = await checkVersionExists(repoId, "v3.0");
 
75
 
76
  if (hasV3Info) {
77
  const hasV3Structure = await checkV3ChunkedStructure(repoId);
 
78
 
79
  if (hasV3Structure) {
 
80
  return "v3.0";
81
  }
82
  }
83
 
84
  // Check for v2.1
85
  const hasV21 = await checkVersionExists(repoId, "v2.1");
 
86
  if (hasV21) {
 
87
  return "v2.1";
88
  }
89
 
90
  // Fall back to v2.0
91
  const hasV20 = await checkVersionExists(repoId, "v2.0");
 
92
  if (hasV20) {
 
93
  return "v2.0";
94
  }
95
 
96
  // If none of the supported versions exist, throw an error
 
97
  throw new Error(
98
  `Dataset ${repoId} is not compatible with this visualizer. ` +
99
  "This tool only works with dataset versions 3.0, 2.1, or 2.0. " +
 
108
  return `${DATASET_URL}/${repoId}/resolve/${version}/${path}`;
109
  }
110