Skip to content

Commit 69fd86f

Browse files
committed
wip
1 parent 5fcf846 commit 69fd86f

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

requirements-vllm.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ torchaudio==2.5.1 ; python_version >= "3.11" and python_version < "3.12"
184184
torchvision==0.20.1 ; python_version >= "3.11" and python_version < "3.12"
185185
tqdm==4.67.1 ; python_version >= "3.11" and python_version < "3.12"
186186
transformers==4.50.0 ; python_version >= "3.11" and python_version < "3.12"
187-
triton==3.1.0 ; python_version >= "3.11" and python_version < "3.12" and (platform_system == "Linux" or platform_system == "linux") and platform_machine == "x86_64"
187+
triton==3.1.0 ; python_version >= "3.11" and python_version < "3.12" and (platform_system == "linux" or platform_system == "Linux") and platform_machine == "x86_64"
188188
typing-extensions==4.12.2 ; python_version >= "3.11" and python_version < "3.12"
189189
typing-inspect==0.9.0 ; python_version >= "3.11" and python_version < "3.12"
190190
urllib3==2.3.0 ; python_version >= "3.11" and python_version < "3.12"

skynet/modules/ttt/rag/vector_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async def workflow(self, store_id: str, files: list[str], urls: list[str], max_d
126126
zip_files = [f for f in files if f.endswith('.zip')]
127127
if zip_files:
128128
files = [f for f in files if f not in zip_files]
129-
files.extend(extract_files(zip_files, self.get_temp_folder(store_id), min_size_kb=1))
129+
files.extend(await extract_files(zip_files, self.get_temp_folder(store_id), min_size_kb=1))
130130

131131
files = [f for f in files if any(f.endswith(ext) for ext in supported_files)]
132132

skynet/modules/ttt/rag/zip_extractor/main.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import asyncio
12
from pathlib import Path
23
from shutil import unpack_archive
34
from typing import Optional
45

56

6-
def extract_files(compressed_files: list[str], destination_folder: str, min_size_kb: Optional[int] = None) -> list[str]:
7-
"""
8-
Extract all files from the given list of compressed files.
9-
"""
10-
7+
def _extract_files_sync(
8+
compressed_files: list[str], destination_folder: str, min_size_kb: Optional[int] = None
9+
) -> list[str]:
10+
"""Synchronous implementation of file extraction"""
1111
extracted_files = []
1212

1313
for compressed_file in compressed_files:
@@ -24,3 +24,13 @@ def extract_files(compressed_files: list[str], destination_folder: str, min_size
2424
extracted_files = [f for f in extracted_files if Path(f).stat().st_size >= min_size_kb * 1024]
2525

2626
return extracted_files
27+
28+
29+
async def extract_files(
30+
compressed_files: list[str], destination_folder: str, min_size_kb: Optional[int] = None
31+
) -> list[str]:
32+
"""
33+
Extract all files from the given list of compressed files.
34+
Runs the entire extraction process in a separate thread.
35+
"""
36+
return await asyncio.to_thread(_extract_files_sync, compressed_files, destination_folder, min_size_kb)

skynet/modules/ttt/rag/zip_extractor/main_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
import shutil
33
from pathlib import Path
44

5+
import pytest
6+
57
from skynet.modules.ttt.rag.zip_extractor.main import extract_files
68

79

810
class TestExtractFiles:
9-
def test_extract_files(self):
11+
@pytest.mark.asyncio
12+
async def test_extract_files(self):
1013
"""
1114
Test extract_files function retrieves all files in all folders.
1215
"""
@@ -33,7 +36,7 @@ def test_extract_files(self):
3336
for folder, zip_file in zip(folders, zip_files):
3437
shutil.make_archive(zip_file, 'zip', folder)
3538

36-
extracted_files = extract_files([f'{file}.zip' for file in zip_files], 'temp')
39+
extracted_files = await extract_files([f'{file}.zip' for file in zip_files], 'temp')
3740
expected_files = [
3841
'temp/archives/test1/subfolder_0/file_0.txt',
3942
'temp/archives/test1/subfolder_0/file_1.txt',

0 commit comments

Comments
 (0)