peppinob-ol commited on
Commit
3e4823c
·
1 Parent(s): 6e03ecd

Fix: handle file paths correctly for generated graphs

Browse files
Files changed (1) hide show
  1. eda/pages/00_Graph_Generation.py +28 -4
eda/pages/00_Graph_Generation.py CHANGED
@@ -349,12 +349,36 @@ if just_generated and generated_path:
349
 
350
  # Convert to Path and handle both absolute and relative paths
351
  gen_path = PathLib(generated_path)
352
- if gen_path.is_absolute():
 
 
353
  # Absolute path - make it relative to parent_dir
354
- selected_json = str(gen_path.relative_to(parent_dir))
 
 
 
 
355
  else:
356
- # Already relative - use as is
357
- selected_json = str(gen_path).replace('\\', '/')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
 
359
  st.info(f"📊 **Ready to analyze**: `{gen_path.name}` (just generated)")
360
 
 
349
 
350
  # Convert to Path and handle both absolute and relative paths
351
  gen_path = PathLib(generated_path)
352
+
353
+ # Check if file exists as absolute path
354
+ if gen_path.is_absolute() and gen_path.exists():
355
  # Absolute path - make it relative to parent_dir
356
+ try:
357
+ selected_json = str(gen_path.relative_to(parent_dir))
358
+ except ValueError:
359
+ # If not relative to parent_dir, use the path as is but show name only
360
+ selected_json = str(gen_path)
361
  else:
362
+ # Relative path - could be relative to eda/ or parent_dir
363
+ # Try to find the file
364
+ possible_paths = [
365
+ parent_dir / generated_path, # Relative to /app
366
+ parent_dir / "eda" / generated_path, # Relative to /app/eda
367
+ Path.cwd() / generated_path, # Relative to current directory
368
+ ]
369
+
370
+ found_path = None
371
+ for p in possible_paths:
372
+ if p.exists():
373
+ found_path = p
374
+ break
375
+
376
+ if found_path:
377
+ selected_json = str(found_path.relative_to(parent_dir))
378
+ gen_path = found_path
379
+ else:
380
+ # Fallback to the original path
381
+ selected_json = str(gen_path).replace('\\', '/')
382
 
383
  st.info(f"📊 **Ready to analyze**: `{gen_path.name}` (just generated)")
384