Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Sync from huggingface/lerobot-dataset-visualizer via hub-sync
Browse filesFiles changed (3)
192 unmodified lines193194195196197198199200201202203114 unmodified lines3183193203213223233241 unmodified line3263273283293303313322 unmodified lines335336337338339340341342343344345346347192 unmodified linesimport { buildVersionedUrl } from "@/utils/versionUtils";import { formatStringWithVars } from "@/utils/parquetUtils";import {buildV3DataPath,buildV3VideoPath,buildV3EpisodesMetadataPath,} from "@/utils/stringFormatting";import { PADDING } from "@/utils/constants";const DATASET_BASE = "https://huggingface.co/datasets";114 unmodified lines});test("data path from episode metadata (chunk 0, file 2)", () => {const path = buildV3DataPath(0, 2);const url = buildVersionedUrl(repoId, version, path);expect(url).toBe(`${DATASET_BASE}/${repoId}/resolve/main/data/chunk-000/file-002.parquet`,1 unmodified line});test("video path for top camera (chunk 0, file 0)", () => {const path = buildV3VideoPath("observation.images.top", 0, 0);const url = buildVersionedUrl(repoId, version, path);expect(url).toBe(`${DATASET_BASE}/${repoId}/resolve/main/videos/observation.images.top/chunk-000/file-000.mp4`,2 unmodified linestest("video path for wrist camera with non-zero file index (per-camera metadata)", () => {// v3.0 supports per-camera video segmentation — each camera can have different file indicesconst path = buildV3VideoPath("observation.images.wrist", 0, 3);expect(path).toBe("videos/observation.images.wrist/chunk-000/file-003.mp4");});test("data path for large dataset spanning multiple chunks", () => {// Episode in chunk 1, file 5 based on episode metadataconst path = buildV3DataPath(1, 5);expect(path).toBe("data/chunk-001/file-005.parquet");});});192 unmodified lines193194195196197198199200201202203204205114 unmodified lines3203213223233243253263273283291 unmodified line3313323333343353363373383393403412 unmodified lines344345346347348349350351352353354355356357358359360361362363192 unmodified linesimport { buildVersionedUrl } from "@/utils/versionUtils";import { formatStringWithVars } from "@/utils/parquetUtils";import { buildV3EpisodesMetadataPath } from "@/utils/stringFormatting";import { formatPathTemplate } from "@huggingface/lerobot";const V3_DATA_TEMPLATE ="data/chunk-{chunk_index:03d}/file-{file_index:03d}.parquet";const V3_VIDEO_TEMPLATE ="videos/{video_key}/chunk-{chunk_index:03d}/file-{file_index:03d}.mp4";import { PADDING } from "@/utils/constants";const DATASET_BASE = "https://huggingface.co/datasets";114 unmodified lines});test("data path from episode metadata (chunk 0, file 2)", () => {const path = formatPathTemplate(V3_DATA_TEMPLATE, {chunk_index: 0,file_index: 2,});const url = buildVersionedUrl(repoId, version, path);expect(url).toBe(`${DATASET_BASE}/${repoId}/resolve/main/data/chunk-000/file-002.parquet`,1 unmodified line});test("video path for top camera (chunk 0, file 0)", () => {const path = formatPathTemplate(V3_VIDEO_TEMPLATE, {video_key: "observation.images.top",chunk_index: 0,file_index: 0,});const url = buildVersionedUrl(repoId, version, path);expect(url).toBe(`${DATASET_BASE}/${repoId}/resolve/main/videos/observation.images.top/chunk-000/file-000.mp4`,2 unmodified linestest("video path for wrist camera with non-zero file index (per-camera metadata)", () => {// v3.0 supports per-camera video segmentation — each camera can have different file indicesconst path = formatPathTemplate(V3_VIDEO_TEMPLATE, {video_key: "observation.images.wrist",chunk_index: 0,file_index: 3,});expect(path).toBe("videos/observation.images.wrist/chunk-000/file-003.mp4");});test("data path for large dataset spanning multiple chunks", () => {// Episode in chunk 1, file 5 based on episode metadataconst path = formatPathTemplate(V3_DATA_TEMPLATE, {chunk_index: 1,file_index: 5,});expect(path).toBe("data/chunk-001/file-005.parquet");});});
4 unmodified lines5678910111264 unmodified lines77787980818283848586878889909192939495969798991001011021031041051061071081091101111121131144 unmodified linesformatEpisodeIndex,formatFileIndex,formatChunkIndex,buildV3VideoPath,buildV3DataPath,buildV3EpisodesMetadataPath,} from "@/utils/stringFormatting";64 unmodified lines});// v3.0 specific path buildersdescribe("buildV3VideoPath", () => {test("single camera, chunk 0, file 0", () => {expect(buildV3VideoPath("observation.image", 0, 0)).toBe("videos/observation.image/chunk-000/file-000.mp4",);});test("nested camera key, non-zero chunk and file", () => {expect(buildV3VideoPath("observation.images.wrist", 2, 5)).toBe("videos/observation.images.wrist/chunk-002/file-005.mp4",);});test("two-camera SO101 dataset style", () => {expect(buildV3VideoPath("observation.images.top", 0, 1)).toBe("videos/observation.images.top/chunk-000/file-001.mp4",);});});describe("buildV3DataPath", () => {test("chunk 0, file 0", () => {expect(buildV3DataPath(0, 0)).toBe("data/chunk-000/file-000.parquet");});test("chunk 1, file 3", () => {expect(buildV3DataPath(1, 3)).toBe("data/chunk-001/file-003.parquet");});test("large indices", () => {expect(buildV3DataPath(10, 99)).toBe("data/chunk-010/file-099.parquet");});});describe("buildV3EpisodesMetadataPath", () => {test("chunk 0, file 0 (default for most datasets)", () => {expect(buildV3EpisodesMetadataPath(0, 0)).toBe(4 unmodified lines567891064 unmodified lines7576777879804 unmodified linesformatEpisodeIndex,formatFileIndex,formatChunkIndex,buildV3EpisodesMetadataPath,} from "@/utils/stringFormatting";64 unmodified lines});// v3.0 specific path buildersdescribe("buildV3EpisodesMetadataPath", () => {test("chunk 0, file 0 (default for most datasets)", () => {expect(buildV3EpisodesMetadataPath(0, 0)).toBe(
55 unmodified lines56575859606162636465666768697071727374757677787980818283848586878855 unmodified linesreturn padNumber(chunkIndex, PADDING.CHUNK_INDEX);}/*** Build video path for v3 datasets** @param videoKey - Video key/name (e.g., "observation.image")* @param chunkIndex - Data chunk index* @param fileIndex - File index within chunk* @returns Formatted video path (e.g., "videos/observation.image/chunk-001/file-000.mp4")*/export function buildV3VideoPath(videoKey: string,chunkIndex: number,fileIndex: number,): string {return `videos/${videoKey}/chunk-${formatChunkIndex(chunkIndex)}/file-${formatFileIndex(fileIndex)}.mp4`;}/*** Build data path for v3 datasets** @param chunkIndex - Data chunk index* @param fileIndex - File index within chunk* @returns Formatted data path (e.g., "data/chunk-001/file-000.parquet")*/export function buildV3DataPath(chunkIndex: number, fileIndex: number): string {return `data/chunk-${formatChunkIndex(chunkIndex)}/file-${formatFileIndex(fileIndex)}.parquet`;}/*** Build episodes metadata path for v3 datasets*55 unmodified lines56575859606155 unmodified linesreturn padNumber(chunkIndex, PADDING.CHUNK_INDEX);}/*** Build episodes metadata path for v3 datasets*
src/app/[org]/[dataset]/[episode]/__tests__/fetch-data.test.ts+25-9
src/utils/__tests__/stringFormatting.test.ts-34
src/utils/stringFormatting.ts-27