Spaces:
Runtime error
Runtime error
update
Browse files
components/services/dataset.py
CHANGED
|
@@ -52,6 +52,7 @@ class DatasetService:
|
|
| 52 |
self.vectorizer = vectorizer
|
| 53 |
self.regulations_path = Path(config.db_config.files.regulations_path)
|
| 54 |
self.documents_path = Path(config.db_config.files.documents_path)
|
|
|
|
| 55 |
logger.info("DatasetService initialized")
|
| 56 |
|
| 57 |
|
|
@@ -274,9 +275,10 @@ class DatasetService:
|
|
| 274 |
"""
|
| 275 |
Получить информацию о процессе обработки датасета.
|
| 276 |
"""
|
| 277 |
-
|
|
|
|
| 278 |
try:
|
| 279 |
-
with open(
|
| 280 |
info = json.load(f)
|
| 281 |
except Exception as e:
|
| 282 |
logger.warning(f"Error loading processing info: {e}")
|
|
@@ -316,7 +318,7 @@ class DatasetService:
|
|
| 316 |
logger.info(f"Uploading ZIP file {file.filename}")
|
| 317 |
self.raise_if_processing()
|
| 318 |
|
| 319 |
-
file_location = Path.
|
| 320 |
logger.debug(f"Saving uploaded file to {file_location}")
|
| 321 |
file_location.parent.mkdir(parents=True, exist_ok=True)
|
| 322 |
with open(file_location, 'wb') as f:
|
|
@@ -352,7 +354,7 @@ class DatasetService:
|
|
| 352 |
status_code=400, detail='Dataset is not draft but trying to apply it'
|
| 353 |
)
|
| 354 |
|
| 355 |
-
TMP_PATH = Path('tmp.json')
|
| 356 |
|
| 357 |
def progress_callback(current: int, total: int) -> None:
|
| 358 |
log_step = total // 100
|
|
|
|
| 52 |
self.vectorizer = vectorizer
|
| 53 |
self.regulations_path = Path(config.db_config.files.regulations_path)
|
| 54 |
self.documents_path = Path(config.db_config.files.documents_path)
|
| 55 |
+
self.tmp_path= Path(os.environ.get(config.db_config.files.documents_path, '.'))
|
| 56 |
logger.info("DatasetService initialized")
|
| 57 |
|
| 58 |
|
|
|
|
| 275 |
"""
|
| 276 |
Получить информацию о процессе обработки датасета.
|
| 277 |
"""
|
| 278 |
+
tmp_file = Path(self.tmp_path / 'tmp.json')
|
| 279 |
+
if tmp_file.exists():
|
| 280 |
try:
|
| 281 |
+
with open(tmp_file, 'r', encoding='utf-8') as f:
|
| 282 |
info = json.load(f)
|
| 283 |
except Exception as e:
|
| 284 |
logger.warning(f"Error loading processing info: {e}")
|
|
|
|
| 318 |
logger.info(f"Uploading ZIP file {file.filename}")
|
| 319 |
self.raise_if_processing()
|
| 320 |
|
| 321 |
+
file_location = Path(self.tmp_path / 'tmp.json' / 'tmp.zip')
|
| 322 |
logger.debug(f"Saving uploaded file to {file_location}")
|
| 323 |
file_location.parent.mkdir(parents=True, exist_ok=True)
|
| 324 |
with open(file_location, 'wb') as f:
|
|
|
|
| 354 |
status_code=400, detail='Dataset is not draft but trying to apply it'
|
| 355 |
)
|
| 356 |
|
| 357 |
+
TMP_PATH = Path(self.tmp_path / 'tmp.json')
|
| 358 |
|
| 359 |
def progress_callback(current: int, total: int) -> None:
|
| 360 |
log_step = total // 100
|