hemantn commited on
Commit
cf7aac0
·
1 Parent(s): 009d04a

Remove remaining ablang2 package import from modeling_ablang2paired.py

Browse files
Files changed (1) hide show
  1. modeling_ablang2paired.py +22 -26
modeling_ablang2paired.py CHANGED
@@ -9,33 +9,29 @@ try:
9
  except ImportError:
10
  from configuration_ablang2paired import AbLang2PairedConfig
11
 
12
- # Import the AbLang model from the integrated files
13
- try:
14
- from ablang2.models.ablang2.ablang import AbLang
15
- except ImportError:
16
- # Fallback: try to find the ablang.py file in the current directory structure
17
- import importlib.util
18
- import os
19
-
20
- def load_ablang_module():
21
- """Load the AbLang module from the nested directory structure."""
22
- # Try to find the ablang.py file in the nested directory
23
- current_dir = os.path.dirname(os.path.abspath(__file__))
24
- ablang_path = os.path.join(current_dir, "ablang2", "models", "ablang2", "ablang.py")
25
-
26
- if os.path.exists(ablang_path):
27
- spec = importlib.util.spec_from_file_location("ablang", ablang_path)
28
- ablang_module = importlib.util.module_from_spec(spec)
29
- spec.loader.exec_module(ablang_module)
30
- return ablang_module.AbLang
31
- else:
32
- # If not found, raise an error with helpful message
33
- raise ImportError(
34
- "Could not find AbLang module. Please ensure the ablang2 directory structure is present "
35
- "or install the ablang2 package."
36
- )
37
 
38
- AbLang = load_ablang_module()
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  class AbLang2PairedHFModel(PreTrainedModel):
41
  config_class = AbLang2PairedConfig
 
9
  except ImportError:
10
  from configuration_ablang2paired import AbLang2PairedConfig
11
 
12
+ # Import the AbLang model from the local file structure
13
+ import importlib.util
14
+ import os
15
+
16
+ def load_ablang_module():
17
+ """Load the AbLang module from the local directory structure."""
18
+ # Try to find the ablang.py file in the local directory
19
+ current_dir = os.path.dirname(os.path.abspath(__file__))
20
+ ablang_path = os.path.join(current_dir, "ablang2", "models", "ablang2", "ablang.py")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ if os.path.exists(ablang_path):
23
+ spec = importlib.util.spec_from_file_location("ablang", ablang_path)
24
+ ablang_module = importlib.util.module_from_spec(spec)
25
+ spec.loader.exec_module(ablang_module)
26
+ return ablang_module.AbLang
27
+ else:
28
+ # If not found, raise an error with helpful message
29
+ raise ImportError(
30
+ "Could not find AbLang module. Please ensure the ablang2 directory structure is present "
31
+ "in the repository."
32
+ )
33
+
34
+ AbLang = load_ablang_module()
35
 
36
  class AbLang2PairedHFModel(PreTrainedModel):
37
  config_class = AbLang2PairedConfig