Add files
Browse files
app.py
CHANGED
|
@@ -57,7 +57,7 @@ def search_datasets_fn(query: str) -> List[str]:
|
|
| 57 |
return []
|
| 58 |
|
| 59 |
|
| 60 |
-
def load_episodes_for_dataset(repo_id: str):
|
| 61 |
"""Download dataset and list available episodes"""
|
| 62 |
if not repo_id:
|
| 63 |
return ""
|
|
@@ -66,7 +66,10 @@ def load_episodes_for_dataset(repo_id: str):
|
|
| 66 |
temp_dir = tempfile.mkdtemp(prefix="episode_delete_")
|
| 67 |
|
| 68 |
try:
|
|
|
|
| 69 |
download_dataset(repo_id, temp_dir, hf_token=token)
|
|
|
|
|
|
|
| 70 |
episodes = list_episodes(temp_dir)
|
| 71 |
|
| 72 |
# Cleanup temp directory
|
|
@@ -78,8 +81,16 @@ def load_episodes_for_dataset(repo_id: str):
|
|
| 78 |
# Return info about available episodes
|
| 79 |
return f"Found {len(episodes)} episodes: {', '.join(map(str, episodes))}"
|
| 80 |
except Exception as e:
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
|
| 85 |
def delete_episodes_stream(repo_id: str, episode_indexes_str: str, dest_repo_id: str):
|
|
@@ -184,6 +195,14 @@ with gr.Blocks(title="LeRobot Episode Deleter") as demo:
|
|
| 184 |
# Load initial datasets
|
| 185 |
_initial_choices = search_datasets_fn("griffinlabs-cortex")
|
| 186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
dataset_dropdown = gr.Dropdown(
|
| 188 |
label="Select dataset",
|
| 189 |
choices=_initial_choices,
|
|
@@ -211,6 +230,16 @@ with gr.Blocks(title="LeRobot Episode Deleter") as demo:
|
|
| 211 |
progress_log = gr.Textbox(label="Progress log", lines=20)
|
| 212 |
|
| 213 |
# Event handlers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
dataset_dropdown.change(
|
| 215 |
load_episodes_for_dataset,
|
| 216 |
inputs=dataset_dropdown,
|
|
|
|
| 57 |
return []
|
| 58 |
|
| 59 |
|
| 60 |
+
def load_episodes_for_dataset(repo_id: str, progress=gr.Progress()):
|
| 61 |
"""Download dataset and list available episodes"""
|
| 62 |
if not repo_id:
|
| 63 |
return ""
|
|
|
|
| 66 |
temp_dir = tempfile.mkdtemp(prefix="episode_delete_")
|
| 67 |
|
| 68 |
try:
|
| 69 |
+
progress(0, desc="Downloading dataset...")
|
| 70 |
download_dataset(repo_id, temp_dir, hf_token=token)
|
| 71 |
+
|
| 72 |
+
progress(0.7, desc="Listing episodes...")
|
| 73 |
episodes = list_episodes(temp_dir)
|
| 74 |
|
| 75 |
# Cleanup temp directory
|
|
|
|
| 81 |
# Return info about available episodes
|
| 82 |
return f"Found {len(episodes)} episodes: {', '.join(map(str, episodes))}"
|
| 83 |
except Exception as e:
|
| 84 |
+
import traceback
|
| 85 |
+
error_msg = f"Error: {str(e)}\n{traceback.format_exc()}"
|
| 86 |
+
print(error_msg)
|
| 87 |
+
# Cleanup on error
|
| 88 |
+
try:
|
| 89 |
+
if temp_dir and os.path.exists(temp_dir):
|
| 90 |
+
shutil.rmtree(temp_dir, ignore_errors=True)
|
| 91 |
+
except Exception:
|
| 92 |
+
pass
|
| 93 |
+
return error_msg
|
| 94 |
|
| 95 |
|
| 96 |
def delete_episodes_stream(repo_id: str, episode_indexes_str: str, dest_repo_id: str):
|
|
|
|
| 195 |
# Load initial datasets
|
| 196 |
_initial_choices = search_datasets_fn("griffinlabs-cortex")
|
| 197 |
|
| 198 |
+
with gr.Row():
|
| 199 |
+
org_input = gr.Textbox(
|
| 200 |
+
label="Organization or keyword",
|
| 201 |
+
value="griffinlabs-cortex",
|
| 202 |
+
placeholder="e.g., lerobot, griffinlabs-cortex"
|
| 203 |
+
)
|
| 204 |
+
load_btn = gr.Button("Load Datasets")
|
| 205 |
+
|
| 206 |
dataset_dropdown = gr.Dropdown(
|
| 207 |
label="Select dataset",
|
| 208 |
choices=_initial_choices,
|
|
|
|
| 230 |
progress_log = gr.Textbox(label="Progress log", lines=20)
|
| 231 |
|
| 232 |
# Event handlers
|
| 233 |
+
def load_datasets_from_org(org_name):
|
| 234 |
+
results = search_datasets_fn(org_name)
|
| 235 |
+
return gr.update(choices=results, value=None)
|
| 236 |
+
|
| 237 |
+
load_btn.click(
|
| 238 |
+
load_datasets_from_org,
|
| 239 |
+
inputs=org_input,
|
| 240 |
+
outputs=dataset_dropdown,
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
dataset_dropdown.change(
|
| 244 |
load_episodes_for_dataset,
|
| 245 |
inputs=dataset_dropdown,
|