jkorstad commited on
Commit
5fc6a3e
·
verified ·
1 Parent(s): ed0fa14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +95 -27
app.py CHANGED
@@ -376,42 +376,111 @@ def rig_glb_mesh_multistep(input_glb_file_obj):
376
  import sys
377
  import os
378
  import traceback
379
- print("--- Diagnostic Info from Blender Python ---")
 
380
  print(f"Python Executable: {{sys.executable}}")
 
381
  print(f"Current Working Directory (inside script): {{os.getcwd()}}")
382
- print("sys.path:")
383
- for p in sys.path: print(f" {{p}}")
384
- print("\\nPYTHONPATH Environment Variable (as seen by script):")
 
 
385
  print(os.environ.get('PYTHONPATH', 'PYTHONPATH not set or empty'))
386
- print("\\nLD_LIBRARY_PATH Environment Variable (as seen by script):")
 
387
  print(os.environ.get('LD_LIBRARY_PATH', 'LD_LIBRARY_PATH not set or empty'))
388
- print("\\n--- Attempting Imports ---")
 
 
 
 
389
  try:
390
  import bpy
391
- print("SUCCESS: 'bpy' imported.")
 
392
  except Exception as e:
393
- print(f"FAILED to import 'bpy': {{e}}")
394
- traceback.print_exc()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
  try:
396
- print("\\nChecking for 'src' in CWD (should be UniRig repo root):")
397
- if os.path.isdir('src'): # This check is relative to CWD
398
- print(" 'src' directory FOUND in CWD.")
399
- if os.path.isfile(os.path.join('src', '__init__.py')):
400
- print(" 'src/__init__.py' FOUND.")
401
- else:
402
- print(" WARNING: 'src/__init__.py' NOT FOUND.")
403
- else:
404
- print(" 'src' directory NOT FOUND in CWD.")
405
- print("\\nAttempting: from src.inference.download import download")
406
  from src.inference.download import download
407
- print("SUCCESS: 'from src.inference.download import download' worked.")
408
  except ImportError as e:
409
- print(f"FAILED: 'from src.inference.download import download': {{e}}")
410
- traceback.print_exc()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  except Exception as e:
412
- print(f"FAILED: 'from src.inference.download import download' with other error: {{e}}")
413
- traceback.print_exc()
414
- print("--- End Diagnostic Info ---")
 
415
  """
416
  # Save diagnostic script to the processing_temp_dir
417
  diagnostic_script_path = os.path.join(processing_temp_dir, "env_diagnostic_test.py")
@@ -546,5 +615,4 @@ if __name__ == "__main__":
546
  print("Launching Gradio interface...")
547
  iface.launch(share=False, ssr_mode=False)
548
  else:
549
- print("ERROR: Gradio interface not created due to startup errors. Check logs.")
550
-
 
376
  import sys
377
  import os
378
  import traceback
379
+
380
+ print("--- Enhanced Diagnostic Info from Blender Python ---")
381
  print(f"Python Executable: {{sys.executable}}")
382
+ print(f"Python Version: {{sys.version.replace('\n', ' ')}}") # Added sys.version
383
  print(f"Current Working Directory (inside script): {{os.getcwd()}}")
384
+
385
+ print("\nsys.path:")
386
+ for i, p in enumerate(sys.path): print(f" {{i}}: {{p}}")
387
+
388
+ print("\nPYTHONPATH Environment Variable (as seen by script):")
389
  print(os.environ.get('PYTHONPATH', 'PYTHONPATH not set or empty'))
390
+
391
+ print("\nLD_LIBRARY_PATH Environment Variable (as seen by script):")
392
  print(os.environ.get('LD_LIBRARY_PATH', 'LD_LIBRARY_PATH not set or empty'))
393
+
394
+ print("\n--- Attempting Critical Imports ---")
395
+
396
+ # 1. bpy
397
+ print("\n1. Attempting 'bpy' import...")
398
  try:
399
  import bpy
400
+ print(" SUCCESS: 'bpy' imported.")
401
+ print(f" bpy version: {{bpy.app.version_string}}")
402
  except Exception as e:
403
+ print(f" FAILED to import 'bpy': {{e}}")
404
+ traceback.print_exc(file=sys.stderr)
405
+
406
+ # 2. UniRig 'src' module
407
+ print("\n2. Checking for UniRig 'src' module availability...")
408
+ # UNIRIG_REPO_DIR from app.py's function scope will be interpolated here by Python when app.py runs
409
+ # The f-string formatting {os.path.abspath(UNIRIG_REPO_DIR)} ensures this path is correctly embedded
410
+ # into the script content that Blender's Python will execute.
411
+ print(f" Expected UniRig repo parent in sys.path: '{os.path.abspath(UNIRIG_REPO_DIR)}'")
412
+ found_unirig_in_sys_path = any(os.path.abspath(UNIRIG_REPO_DIR) == os.path.abspath(p) for p in sys.path)
413
+ print(f" Is UNIRIG_REPO_DIR ('{os.path.abspath(UNIRIG_REPO_DIR)}') in sys.path (at diagnostic script generation time)? {'Yes' if found_unirig_in_sys_path else 'No'}")
414
+
415
+
416
+ unirig_src_dir_in_cwd_exists = os.path.isdir('src')
417
+ print(f" Is 'src' directory present in CWD ('{{os.getcwd()}}')? {'Yes' if unirig_src_dir_in_cwd_exists else 'No'}")
418
+ if unirig_src_dir_in_cwd_exists:
419
+ init_py_in_src_exists = os.path.isfile(os.path.join('src', '__init__.py'))
420
+ print(f" Is 'src/__init__.py' present? {'Yes' if init_py_in_src_exists else 'No'}")
421
+
422
+ print(" Attempting 'from src.inference.download import download'...")
423
  try:
 
 
 
 
 
 
 
 
 
 
424
  from src.inference.download import download
425
+ print(" SUCCESS: 'from src.inference.download import download' worked.")
426
  except ImportError as e:
427
+ print(f" FAILED: 'from src.inference.download import download': {{e}}")
428
+ print(f" Make sure '{os.path.abspath(UNIRIG_REPO_DIR)}' is correctly added to sys.path by the bootstrap script executed by Blender.")
429
+ traceback.print_exc(file=sys.stderr)
430
+ except Exception as e:
431
+ print(f" FAILED: 'from src.inference.download import download' with other error: {{e}}")
432
+ traceback.print_exc(file=sys.stderr)
433
+
434
+ # 3. flash_attn
435
+ print("\n3. Attempting 'flash_attn' import...")
436
+ try:
437
+ import flash_attn
438
+ print(" SUCCESS: 'flash_attn' imported.")
439
+ if hasattr(flash_attn, '__version__'):
440
+ print(f" flash_attn version: {{flash_attn.__version__}}")
441
+ except Exception as e:
442
+ print(f" FAILED to import 'flash_attn': {{e}}")
443
+ print(f" Note: flash-attn is expected to be installed by setup_blender.sh from a specific wheel.")
444
+ traceback.print_exc(file=sys.stderr)
445
+
446
+ # 4. spconv
447
+ print("\n4. Attempting 'spconv' import...")
448
+ try:
449
+ import spconv
450
+ print(" SUCCESS: 'spconv' imported.")
451
+ if hasattr(spconv, 'constants') and hasattr(spconv.constants, 'SPCONV_VERSION'):
452
+ print(f" spconv version: {{spconv.constants.SPCONV_VERSION}}")
453
+ elif hasattr(spconv, '__version__'):
454
+ print(f" spconv version: {{spconv.__version__}}")
455
+ except Exception as e:
456
+ print(f" FAILED to import 'spconv': {{e}}")
457
+ print(f" Note: spconv (e.g., spconv-cu118) should be installed via unirig_requirements.txt in Blender's Python.")
458
+ traceback.print_exc(file=sys.stderr)
459
+
460
+ # 5. torch with CUDA check
461
+ print("\n5. Attempting 'torch' import and CUDA check...")
462
+ try:
463
+ import torch
464
+ print(" SUCCESS: 'torch' imported.")
465
+ print(f" torch version: {{torch.__version__}}")
466
+ cuda_available = torch.cuda.is_available()
467
+ print(f" torch.cuda.is_available(): {{cuda_available}}")
468
+ if cuda_available:
469
+ print(f" torch.version.cuda: {{torch.version.cuda}}")
470
+ print(f" torch.cuda.get_device_name(0): {{torch.cuda.get_device_name(0)}}")
471
+ print(f" torch.cuda.get_device_capability(0): {{torch.cuda.get_device_capability(0)}}")
472
+ else:
473
+ print(f" CUDA not available to PyTorch in this Blender Python environment.")
474
+ if "cpu" in torch.__version__: # Check if it's a CPU build explicitly
475
+ print(" PyTorch build appears to be CPU-only.")
476
+ else:
477
+ print(" PyTorch build is not CPU-only, but CUDA is still not available. Check drivers/runtime/setup for Blender Python env.")
478
+
479
  except Exception as e:
480
+ print(f" FAILED to import 'torch' or perform CUDA checks: {{e}}")
481
+ traceback.print_exc(file=sys.stderr)
482
+
483
+ print("\n--- End Enhanced Diagnostic Info ---")
484
  """
485
  # Save diagnostic script to the processing_temp_dir
486
  diagnostic_script_path = os.path.join(processing_temp_dir, "env_diagnostic_test.py")
 
615
  print("Launching Gradio interface...")
616
  iface.launch(share=False, ssr_mode=False)
617
  else:
618
+ print("ERROR: Gradio interface not created due to startup errors. Check logs.")