Remove remaining ablang2 package import from modeling_ablang2paired.py
Browse files- 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
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|