Spaces:
Running
Running
Suppress psql restore noise and deprecation warnings
Browse files- stdout=DEVNULL on psql restore: eliminates CREATE TABLE/ALTER TABLE/COPY spam
- warnings.filterwarnings: silences huggingface_hub local_dir_use_symlinks UserWarning
- tar.extractall filter='data': fixes Python 3.14 DeprecationWarning
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- paperclip-sync.py +6 -1
paperclip-sync.py
CHANGED
|
@@ -11,9 +11,13 @@ import tarfile
|
|
| 11 |
import tempfile
|
| 12 |
import subprocess
|
| 13 |
import logging
|
|
|
|
| 14 |
from datetime import datetime
|
| 15 |
from pathlib import Path
|
| 16 |
|
|
|
|
|
|
|
|
|
|
| 17 |
from huggingface_hub import HfApi
|
| 18 |
from huggingface_hub.utils import RepositoryNotFoundError, EntryNotFoundError
|
| 19 |
|
|
@@ -281,6 +285,7 @@ def restore_database(restore_file: str) -> bool:
|
|
| 281 |
result = subprocess.run(
|
| 282 |
restore_cmd,
|
| 283 |
stdin=f,
|
|
|
|
| 284 |
stderr=subprocess.PIPE,
|
| 285 |
env=env,
|
| 286 |
timeout=300
|
|
@@ -347,7 +352,7 @@ def sync_from_hf() -> bool:
|
|
| 347 |
# Extract tarball
|
| 348 |
logger.info('Extracting backup...')
|
| 349 |
with tarfile.open(snapshot_path, 'r:gz') as tar:
|
| 350 |
-
tar.extractall(temp_dir)
|
| 351 |
|
| 352 |
dump_file = Path(temp_dir) / 'paperclip.sql'
|
| 353 |
if not dump_file.exists():
|
|
|
|
| 11 |
import tempfile
|
| 12 |
import subprocess
|
| 13 |
import logging
|
| 14 |
+
import warnings
|
| 15 |
from datetime import datetime
|
| 16 |
from pathlib import Path
|
| 17 |
|
| 18 |
+
# Suppress huggingface_hub deprecation noise about local_dir_use_symlinks
|
| 19 |
+
warnings.filterwarnings('ignore', category=UserWarning, module='huggingface_hub')
|
| 20 |
+
|
| 21 |
from huggingface_hub import HfApi
|
| 22 |
from huggingface_hub.utils import RepositoryNotFoundError, EntryNotFoundError
|
| 23 |
|
|
|
|
| 285 |
result = subprocess.run(
|
| 286 |
restore_cmd,
|
| 287 |
stdin=f,
|
| 288 |
+
stdout=subprocess.DEVNULL, # suppress CREATE TABLE / ALTER TABLE / COPY noise
|
| 289 |
stderr=subprocess.PIPE,
|
| 290 |
env=env,
|
| 291 |
timeout=300
|
|
|
|
| 352 |
# Extract tarball
|
| 353 |
logger.info('Extracting backup...')
|
| 354 |
with tarfile.open(snapshot_path, 'r:gz') as tar:
|
| 355 |
+
tar.extractall(temp_dir, filter='data')
|
| 356 |
|
| 357 |
dump_file = Path(temp_dir) / 'paperclip.sql'
|
| 358 |
if not dump_file.exists():
|