Skip to content
Snippets Groups Projects
Commit 159f5343 authored by vlorentz's avatar vlorentz
Browse files

Print the end of the log

parent 1b03fa0b
No related branches found
Tags v3.1.0
No related merge requests found
......@@ -6,6 +6,7 @@
import logging
from pathlib import Path
import shlex
import sys
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple
# WARNING: do not import unnecessary things here to keep cli startup time under
......@@ -257,7 +258,21 @@ def compress(ctx, input_dataset, output_directory, graph_name, steps):
try:
webgraph.compress(graph_name, input_dataset, output_directory, steps, conf)
except webgraph.CompressionSubprocessError as e:
raise click.ClickException(e.args[0])
try:
if e.log_path.is_file():
with e.log_path.open("rb") as f:
if e.log_path.stat().st_size > 1000:
f.seek(-1000, 2) # read only the last 1kB
f.readline() # skip first line, might be partial
sys.stderr.write("[...]\n")
sys.stderr.write("\n")
sys.stderr.flush()
sys.stderr.buffer.write(f.read())
sys.stderr.flush()
except Exception:
raise
pass
raise click.ClickException(e.message)
def get_all_subclasses(cls):
......
......@@ -24,7 +24,10 @@ logger = logging.getLogger(__name__)
class CompressionSubprocessError(Exception):
pass
def __init__(self, message: str, log_path: Path):
super().__init__(f"{message}; full logs at {log_path}")
self.message = message
self.log_path = log_path
class CompressionStep(Enum):
......@@ -328,7 +331,7 @@ def do_step(step, conf):
rc = process.wait()
if rc != 0:
raise CompressionSubprocessError(
f"Compression step {step} returned non-zero exit code {rc}, see {log_path}"
f"Compression step {step} returned non-zero exit code {rc}", log_path
)
step_end_time = datetime.now()
step_duration = step_end_time - step_start_time
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment