Skip to content

Commit 19ac115

Browse files
authored
Ignore sparse_logs in created files check (#1859)
SUMMARY: This should fix https://github.com/vllm-project/llm-compressor/actions/runs/17947398242/job/51041390141#step:9:121 until #1828 is complete. Add `sparse_logs` to the ignored folders when checking if any files have been created/left in the root dir during tests. Signed-off-by: Fynn Schmitt-Ulms <[email protected]>
1 parent 4a4f0be commit 19ac115

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

tests/llmcompressor/conftest.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ def setup_modifier_factory():
2323
assert ModifierFactory._loaded, "ModifierFactory not loaded"
2424

2525

26-
def _get_files(directory: str) -> List[str]:
26+
def _get_files(directory: str, ignore_dirs: List[str] = []) -> List[str]:
2727
list_filepaths = []
28+
ignore_dirs = tuple(ignore_dirs) # has to be a tuple for str.startswith
2829
for root, dirs, files in os.walk(directory):
30+
dirs[:] = [dir_ for dir_ in dirs if not str(dir_).startswith(ignore_dirs)]
2931
for file in files:
3032
list_filepaths.append(os.path.join(os.path.abspath(root), file))
3133
return list_filepaths
@@ -46,8 +48,11 @@ def _files_size_mb(path_list: List[str]) -> int:
4648

4749
@pytest.fixture(scope="session", autouse=True)
4850
def check_for_created_files():
49-
start_files_root = _get_files(directory=r".")
50-
start_files_temp = _get_files(directory=tempfile.gettempdir())
51+
ignore_dirs = ["__pycache__", "sparse_logs"]
52+
start_files_root = _get_files(directory=r".", ignore_dirs=ignore_dirs)
53+
start_files_temp = _get_files(
54+
directory=tempfile.gettempdir(), ignore_dirs=["pytest-of"]
55+
)
5156
yield
5257
if wandb:
5358
wandb.finish()
@@ -56,10 +61,7 @@ def check_for_created_files():
5661
shutil.rmtree(log_dir)
5762

5863
# allow creation of __pycache__ directories
59-
end_files_root = [
60-
f_path for f_path in _get_files(directory=r".") if "__pycache__" not in f_path
61-
]
62-
end_files_temp = _get_files(directory=tempfile.gettempdir())
64+
end_files_root = _get_files(directory=r".", ignore_dirs=ignore_dirs)
6365
# assert no files created in root directory while running
6466
# the pytest suite
6567
assert len(start_files_root) >= len(end_files_root), (
@@ -70,12 +72,11 @@ def check_for_created_files():
7072
)
7173

7274
max_allowed_sized_temp_files_megabytes = 1
73-
end_files_temp = _get_files(directory=tempfile.gettempdir())
74-
created_temp_files = set(end_files_temp) - set(start_files_temp)
7575
# pytest temp files are automatically deleted, exclude from size calculation
76-
created_temp_files = [
77-
f_path for f_path in created_temp_files if "pytest-of" not in f_path
78-
]
76+
end_files_temp = _get_files(
77+
directory=tempfile.gettempdir(), ignore_dirs=["pytest-of"]
78+
)
79+
created_temp_files = set(end_files_temp) - set(start_files_temp)
7980

8081
# assert no more than 1 megabyte of temp files created in temp directory
8182
# while running the pytest suite (excluding files created by pytest)

0 commit comments

Comments
 (0)