Spaces:
Running
Running
refactor: align types with merged PRs #23 and #24
Browse files- Remove duplicate VideoInfo and AdjacentEpisodeVideos types from
fetch-data.ts; import from @/types instead
- Update videos-player and simple-videos-player to import VideoInfo
from @/types instead of fetch-data
- Replace manual Number() BigInt conversions with bigIntToNumber()
from @/utils/typeGuards for consistency
- Replace magic-string SERIES_DELIM in urdf-viewer with
CHART_CONFIG.SERIES_NAME_DELIMITER from @/utils/constants
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
src/app/[org]/[dataset]/[episode]/fetch-data.ts
CHANGED
|
@@ -17,18 +17,10 @@ import {
|
|
| 17 |
buildV3EpisodesMetadataPath,
|
| 18 |
} from "@/utils/stringFormatting";
|
| 19 |
import { bigIntToNumber } from "@/utils/typeGuards";
|
|
|
|
| 20 |
|
| 21 |
const SERIES_NAME_DELIMITER = CHART_CONFIG.SERIES_NAME_DELIMITER;
|
| 22 |
|
| 23 |
-
export type VideoInfo = {
|
| 24 |
-
filename: string;
|
| 25 |
-
url: string;
|
| 26 |
-
isSegmented?: boolean;
|
| 27 |
-
segmentStart?: number;
|
| 28 |
-
segmentEnd?: number;
|
| 29 |
-
segmentDuration?: number;
|
| 30 |
-
};
|
| 31 |
-
|
| 32 |
export type CameraInfo = { name: string; width: number; height: number };
|
| 33 |
|
| 34 |
export type DatasetDisplayInfo = {
|
|
@@ -110,11 +102,6 @@ type ColumnDef = {
|
|
| 110 |
value: string[];
|
| 111 |
};
|
| 112 |
|
| 113 |
-
type AdjacentEpisodeVideos = {
|
| 114 |
-
episodeId: number;
|
| 115 |
-
videosInfo: VideoInfo[];
|
| 116 |
-
};
|
| 117 |
-
|
| 118 |
export async function getEpisodeData(
|
| 119 |
org: string,
|
| 120 |
dataset: string,
|
|
@@ -517,9 +504,8 @@ async function loadEpisodeDataV3(
|
|
| 517 |
const fullData = await readParquetAsObjects(arrayBuffer, []);
|
| 518 |
|
| 519 |
// Extract the episode-specific data slice
|
| 520 |
-
|
| 521 |
-
const
|
| 522 |
-
const toIndex = Number(episodeMetadata.dataset_to_index || fullData.length);
|
| 523 |
|
| 524 |
// Find the starting index of this parquet file by checking the first row's index
|
| 525 |
// This handles the case where episodes are split across multiple parquet files
|
|
@@ -580,11 +566,9 @@ async function loadEpisodeDataV3(
|
|
| 580 |
const tasksData = await readParquetAsObjects(tasksArrayBuffer, []);
|
| 581 |
|
| 582 |
if (tasksData.length > 0) {
|
| 583 |
-
const
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
if (taskIndexNum !== undefined && taskIndexNum < tasksData.length) {
|
| 588 |
const taskData = tasksData[taskIndexNum];
|
| 589 |
const rawTask = taskData.__index_level_0__ ?? taskData.task;
|
| 590 |
task = typeof rawTask === 'string' ? rawTask : undefined;
|
|
|
|
| 17 |
buildV3EpisodesMetadataPath,
|
| 18 |
} from "@/utils/stringFormatting";
|
| 19 |
import { bigIntToNumber } from "@/utils/typeGuards";
|
| 20 |
+
import type { VideoInfo, AdjacentEpisodeVideos } from "@/types";
|
| 21 |
|
| 22 |
const SERIES_NAME_DELIMITER = CHART_CONFIG.SERIES_NAME_DELIMITER;
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
export type CameraInfo = { name: string; width: number; height: number };
|
| 25 |
|
| 26 |
export type DatasetDisplayInfo = {
|
|
|
|
| 102 |
value: string[];
|
| 103 |
};
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
export async function getEpisodeData(
|
| 106 |
org: string,
|
| 107 |
dataset: string,
|
|
|
|
| 504 |
const fullData = await readParquetAsObjects(arrayBuffer, []);
|
| 505 |
|
| 506 |
// Extract the episode-specific data slice
|
| 507 |
+
const fromIndex = bigIntToNumber(episodeMetadata.dataset_from_index, 0);
|
| 508 |
+
const toIndex = bigIntToNumber(episodeMetadata.dataset_to_index, fullData.length);
|
|
|
|
| 509 |
|
| 510 |
// Find the starting index of this parquet file by checking the first row's index
|
| 511 |
// This handles the case where episodes are split across multiple parquet files
|
|
|
|
| 566 |
const tasksData = await readParquetAsObjects(tasksArrayBuffer, []);
|
| 567 |
|
| 568 |
if (tasksData.length > 0) {
|
| 569 |
+
const taskIndexNum = bigIntToNumber(episodeData[0].task_index, -1);
|
| 570 |
+
|
| 571 |
+
if (taskIndexNum >= 0 && taskIndexNum < tasksData.length) {
|
|
|
|
|
|
|
| 572 |
const taskData = tasksData[taskIndexNum];
|
| 573 |
const rawTask = taskData.__index_level_0__ ?? taskData.task;
|
| 574 |
task = typeof rawTask === 'string' ? rawTask : undefined;
|
src/components/simple-videos-player.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
import React, { useEffect, useRef } from "react";
|
| 4 |
import { useTime } from "../context/time-context";
|
| 5 |
import { FaExpand, FaCompress, FaTimes, FaEye } from "react-icons/fa";
|
| 6 |
-
import type { VideoInfo } from "@/
|
| 7 |
|
| 8 |
const THRESHOLDS = {
|
| 9 |
VIDEO_SYNC_TOLERANCE: 0.2,
|
|
|
|
| 3 |
import React, { useEffect, useRef } from "react";
|
| 4 |
import { useTime } from "../context/time-context";
|
| 5 |
import { FaExpand, FaCompress, FaTimes, FaEye } from "react-icons/fa";
|
| 6 |
+
import type { VideoInfo } from "@/types";
|
| 7 |
|
| 8 |
const THRESHOLDS = {
|
| 9 |
VIDEO_SYNC_TOLERANCE: 0.2,
|
src/components/urdf-viewer.tsx
CHANGED
|
@@ -13,9 +13,9 @@ import { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js";
|
|
| 13 |
import { LineGeometry } from "three/examples/jsm/lines/LineGeometry.js";
|
| 14 |
import type { EpisodeData } from "@/app/[org]/[dataset]/[episode]/fetch-data";
|
| 15 |
import { fetchEpisodeChartData } from "@/app/[org]/[dataset]/[episode]/actions";
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
const SERIES_DELIM = " | ";
|
| 19 |
const DEG2RAD = Math.PI / 180;
|
| 20 |
|
| 21 |
function getRobotConfig(robotType: string | null) {
|
|
|
|
| 13 |
import { LineGeometry } from "three/examples/jsm/lines/LineGeometry.js";
|
| 14 |
import type { EpisodeData } from "@/app/[org]/[dataset]/[episode]/fetch-data";
|
| 15 |
import { fetchEpisodeChartData } from "@/app/[org]/[dataset]/[episode]/actions";
|
| 16 |
+
import { CHART_CONFIG } from "@/utils/constants";
|
| 17 |
|
| 18 |
+
const SERIES_DELIM = CHART_CONFIG.SERIES_NAME_DELIMITER;
|
|
|
|
| 19 |
const DEG2RAD = Math.PI / 180;
|
| 20 |
|
| 21 |
function getRobotConfig(robotType: string | null) {
|
src/components/videos-player.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
import { useEffect, useRef, useState } from "react";
|
| 4 |
import { useTime } from "../context/time-context";
|
| 5 |
import { FaExpand, FaCompress, FaTimes, FaEye } from "react-icons/fa";
|
| 6 |
-
import type { VideoInfo } from "@/
|
| 7 |
|
| 8 |
type VideoPlayerProps = {
|
| 9 |
videosInfo: VideoInfo[];
|
|
|
|
| 3 |
import { useEffect, useRef, useState } from "react";
|
| 4 |
import { useTime } from "../context/time-context";
|
| 5 |
import { FaExpand, FaCompress, FaTimes, FaEye } from "react-icons/fa";
|
| 6 |
+
import type { VideoInfo } from "@/types";
|
| 7 |
|
| 8 |
type VideoPlayerProps = {
|
| 9 |
videosInfo: VideoInfo[];
|