hemantn commited on
Commit
6db1bf7
·
1 Parent(s): f07c732

Fix import conflicts by removing /content from sys.path and ensuring imports from cache directory

Browse files
Files changed (1) hide show
  1. adapter.py +29 -7
adapter.py CHANGED
@@ -472,13 +472,35 @@ for f in os.listdir(current_dir):
472
  print(f" {f}")
473
 
474
  # Import utility modules directly (no package structure needed)
475
- from restoration import AbRestore
476
- from ablang_encodings import AbEncoding
477
- from alignment import AbAlignment
478
- from scores import AbScores
479
- import torch
480
- import numpy as np
481
- from extra_utils import res_to_seq, res_to_list
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
482
 
483
  class HuggingFaceTokenizerAdapter:
484
  def __init__(self, tokenizer, device):
 
472
  print(f" {f}")
473
 
474
  # Import utility modules directly (no package structure needed)
475
+ import sys
476
+ import os
477
+
478
+ # Ensure we import from the cache directory, not from /content
479
+ cache_dir = os.path.dirname(os.path.abspath(__file__))
480
+ if cache_dir not in sys.path:
481
+ sys.path.insert(0, cache_dir)
482
+
483
+ # Remove /content from sys.path to avoid conflicts
484
+ content_path = '/content'
485
+ if content_path in sys.path:
486
+ sys.path.remove(content_path)
487
+ print(f"✅ Removed {content_path} from sys.path to avoid import conflicts")
488
+
489
+ # Import utility modules
490
+ try:
491
+ from restoration import AbRestore
492
+ from ablang_encodings import AbEncoding
493
+ from alignment import AbAlignment
494
+ from scores import AbScores
495
+ import torch
496
+ import numpy as np
497
+ from extra_utils import res_to_seq, res_to_list
498
+ print("✅ Successfully imported utility modules from cache directory")
499
+ except ImportError as e:
500
+ print(f"❌ Import error: {e}")
501
+ print(f"🔧 Current sys.path: {sys.path}")
502
+ print(f"🔧 Cache directory: {cache_dir}")
503
+ raise
504
 
505
  class HuggingFaceTokenizerAdapter:
506
  def __init__(self, tokenizer, device):