Spaces:
Running
Running
fix indexing features (#6)
Browse files
src/app/[org]/[dataset]/[episode]/fetch-data.ts
CHANGED
|
@@ -437,18 +437,33 @@ function processEpisodeDataForCharts(
|
|
| 437 |
// Convert parquet data to chart format
|
| 438 |
let seriesNames: string[] = [];
|
| 439 |
|
| 440 |
-
//
|
| 441 |
-
const v3IndexToFeatureMap: Record<string, string> = {
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
'
|
| 449 |
-
'
|
| 450 |
-
'
|
| 451 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
|
| 453 |
// Columns to exclude from charts
|
| 454 |
const excludedColumns = ['index', 'task_index', 'episode_index', 'frame_index', 'next.done'];
|
|
@@ -488,6 +503,9 @@ function processEpisodeDataForCharts(
|
|
| 488 |
// Map numeric key to feature name if available
|
| 489 |
const featureName = v3IndexToFeatureMap[key] || key;
|
| 490 |
|
|
|
|
|
|
|
|
|
|
| 491 |
// Skip excluded columns
|
| 492 |
if (excludedColumns.includes(featureName)) return;
|
| 493 |
|
|
@@ -541,6 +559,9 @@ function processEpisodeDataForCharts(
|
|
| 541 |
// Map numeric key to feature name if available
|
| 542 |
const featureName = v3IndexToFeatureMap[key] || key;
|
| 543 |
|
|
|
|
|
|
|
|
|
|
| 544 |
// Skip excluded columns
|
| 545 |
if (excludedColumns.includes(featureName)) return;
|
| 546 |
|
|
|
|
| 437 |
// Convert parquet data to chart format
|
| 438 |
let seriesNames: string[] = [];
|
| 439 |
|
| 440 |
+
// Dynamically create a mapping from numeric indices to feature names based on actual dataset features
|
| 441 |
+
const v3IndexToFeatureMap: Record<string, string> = {};
|
| 442 |
+
|
| 443 |
+
// Build mapping based on what features actually exist in the dataset
|
| 444 |
+
const featureKeys = Object.keys(info.features);
|
| 445 |
+
|
| 446 |
+
// Common feature order for v3.0 datasets (but only include if they exist)
|
| 447 |
+
const expectedFeatureOrder = [
|
| 448 |
+
'observation.state',
|
| 449 |
+
'action',
|
| 450 |
+
'timestamp',
|
| 451 |
+
'episode_index',
|
| 452 |
+
'frame_index',
|
| 453 |
+
'next.reward',
|
| 454 |
+
'next.done',
|
| 455 |
+
'index',
|
| 456 |
+
'task_index'
|
| 457 |
+
];
|
| 458 |
+
|
| 459 |
+
// Map indices to features that actually exist
|
| 460 |
+
let currentIndex = 0;
|
| 461 |
+
expectedFeatureOrder.forEach(feature => {
|
| 462 |
+
if (featureKeys.includes(feature)) {
|
| 463 |
+
v3IndexToFeatureMap[currentIndex.toString()] = feature;
|
| 464 |
+
currentIndex++;
|
| 465 |
+
}
|
| 466 |
+
});
|
| 467 |
|
| 468 |
// Columns to exclude from charts
|
| 469 |
const excludedColumns = ['index', 'task_index', 'episode_index', 'frame_index', 'next.done'];
|
|
|
|
| 503 |
// Map numeric key to feature name if available
|
| 504 |
const featureName = v3IndexToFeatureMap[key] || key;
|
| 505 |
|
| 506 |
+
// Skip if feature doesn't exist in dataset
|
| 507 |
+
if (!info.features[featureName]) return;
|
| 508 |
+
|
| 509 |
// Skip excluded columns
|
| 510 |
if (excludedColumns.includes(featureName)) return;
|
| 511 |
|
|
|
|
| 559 |
// Map numeric key to feature name if available
|
| 560 |
const featureName = v3IndexToFeatureMap[key] || key;
|
| 561 |
|
| 562 |
+
// Skip if feature doesn't exist in dataset
|
| 563 |
+
if (!info.features[featureName]) return;
|
| 564 |
+
|
| 565 |
// Skip excluded columns
|
| 566 |
if (excludedColumns.includes(featureName)) return;
|
| 567 |
|