Skip to content

Commit 68379b4

Browse files
committed
thin version of is_library, found the guilty one
Signed-off-by: dafnapension <dafnashein@yahoo.com>
1 parent 8a77c7f commit 68379b4

File tree

2 files changed

+47
-51
lines changed

2 files changed

+47
-51
lines changed

src/unitxt/artifact.py

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -92,69 +92,69 @@ def is_library_module(module_name):
9292
):
9393
return False
9494

95-
# if module_name in sys.modules:
96-
# return True
95+
if module_name in sys.modules:
96+
return True
9797

98-
# try:
99-
# importlib.import_module(module_name)
100-
# return True
101-
# except:
102-
# return False
98+
try:
99+
importlib.import_module(module_name)
100+
return True
101+
except:
102+
return False
103103

104-
if module_name not in sys.modules:
105-
try:
106-
__import__(module_name)
107-
except ImportError:
108-
return False
104+
# if module_name not in sys.modules:
105+
# try:
106+
# __import__(module_name)
107+
# except ImportError:
108+
# return False
109109

110-
module = sys.modules[module_name]
110+
# module = sys.modules[module_name]
111111

112-
# Built-in modules
113-
if not hasattr(module, "__file__") or module.__file__ is None:
114-
return True
112+
# # Built-in modules
113+
# if not hasattr(module, "__file__") or module.__file__ is None:
114+
# return True
115115

116-
file_path = module.__file__
116+
# file_path = module.__file__
117117

118-
# Check for standard library patterns
119-
import sysconfig
118+
# # Check for standard library patterns
119+
# import sysconfig
120120

121-
stdlib_path = sysconfig.get_path("stdlib")
121+
# stdlib_path = sysconfig.get_path("stdlib")
122122

123-
# Direct match
124-
if file_path.startswith(stdlib_path):
125-
return True
123+
# # Direct match
124+
# if file_path.startswith(stdlib_path):
125+
# return True
126126

127-
# Handle different Python installations (Homebrew, pyenv, etc.)
128-
# Look for common stdlib patterns: .../lib/python3.x/...
129-
import re
127+
# # Handle different Python installations (Homebrew, pyenv, etc.)
128+
# # Look for common stdlib patterns: .../lib/python3.x/...
129+
# import re
130130

131-
if (
132-
re.search(r"/lib/python\d+\.\d+/", file_path)
133-
and "site-packages" not in file_path
134-
):
135-
return True
131+
# if (
132+
# re.search(r"/lib/python\d+\.\d+/", file_path)
133+
# and "site-packages" not in file_path
134+
# ):
135+
# return True
136136

137-
# Check if it's an installed package
138-
if any(pkg_dir in file_path for pkg_dir in ["site-packages", "dist-packages"]):
139-
return True # Regular installed package
137+
# # Check if it's an installed package
138+
# if any(pkg_dir in file_path for pkg_dir in ["site-packages", "dist-packages"]):
139+
# return True # Regular installed package
140140

141-
# Check if it's an editable install (file outside site-packages but package is installed)
142-
site_packages = sysconfig.get_path("purelib")
143-
package_name = module_name.split(".")[0]
141+
# # Check if it's an editable install (file outside site-packages but package is installed)
142+
# site_packages = sysconfig.get_path("purelib")
143+
# package_name = module_name.split(".")[0]
144144

145-
import glob
145+
# import glob
146146

147-
# Check for various editable install patterns
148-
egg_links = glob.glob(os.path.join(site_packages, f"{package_name}*.egg-link"))
149-
pth_files = glob.glob(os.path.join(site_packages, f"*{package_name}*.pth"))
150-
editable_pth = glob.glob(
151-
os.path.join(site_packages, f"__editable__.{package_name}*.pth")
152-
)
147+
# # Check for various editable install patterns
148+
# egg_links = glob.glob(os.path.join(site_packages, f"{package_name}*.egg-link"))
149+
# pth_files = glob.glob(os.path.join(site_packages, f"*{package_name}*.pth"))
150+
# editable_pth = glob.glob(
151+
# os.path.join(site_packages, f"__editable__.{package_name}*.pth")
152+
# )
153153

154-
if egg_links or pth_files or editable_pth:
155-
return True # It's an editable install, still a library
154+
# if egg_links or pth_files or editable_pth:
155+
# return True # It's an editable install, still a library
156156

157-
return False
157+
# return False
158158

159159

160160
def import_module_from_file(file_path):

tests/catalog/test_preparation.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
# Make sure the order in which the tests are run is deterministic
2828
# Having a different order for local testing and github testing may cause diffs in results.
2929
all_preparation_files.sort()
30-
all_preparation_files = [
31-
file for i, file in enumerate(all_preparation_files) if i % 12 == 1
32-
]
33-
3430
num_par = 1 # num of parallel executions
3531
logger.critical(
3632
f"Over all, {len(all_preparation_files)} files will now be tested over {num_par} parallel processes."

0 commit comments

Comments
 (0)