future-crowd-14830
09/19/2025, 4:56 PMhundreds-rainbow-67050
09/19/2025, 5:12 PMhundreds-rainbow-67050
09/19/2025, 5:21 PMfuture-crowd-14830
09/19/2025, 5:40 PMhundreds-rainbow-67050
09/19/2025, 5:43 PMfuture-crowd-14830
09/19/2025, 5:48 PMwrapper_script = "utils/preprocess_wrapper.py"
<http://logger.info|logger.info>(f"Starting subprocess preprocessing with timeout {timeout_seconds}s")
# Run the preprocessing in subprocess
process = subprocess.run(
[
"uv", "run", "python",
wrapper_script,
input_file_path,
output_file_path,
self.preprocessor_name
],
capture_output=True,
text=True,
timeout=timeout_seconds
)future-crowd-14830
09/19/2025, 5:49 PMfuture-crowd-14830
09/19/2025, 5:51 PMhundreds-rainbow-67050
09/19/2025, 5:55 PMfuture-crowd-14830
09/19/2025, 5:57 PMfuture-crowd-14830
09/19/2025, 6:00 PMtry:
# Get the wrapper script path - it should be in utils/ relative to where we're running
wrapper_script = "utils/preprocess_wrapper.py"
<http://logger.info|logger.info>(f"Starting subprocess preprocessing with timeout {timeout_seconds}s")
# Run the preprocessing in subprocess
process = subprocess.run(
[
"uv", "run", "python",
wrapper_script,
input_file_path,
output_file_path,
self.preprocessor_name
],
capture_output=True,
text=True,
timeout=timeout_seconds
)
# Log subprocess output for debugging (both success and failure cases)
if process.stdout:
stdout_lines = process.stdout.strip().split('\n')
for line in stdout_lines:
if line.strip(): # Skip empty lines
<http://logger.info|logger.info>(f"[Subprocess] {line.strip()}")
if process.stderr:
stderr_lines = process.stderr.strip().split('\n')
for line in stderr_lines:
if line.strip(): # Skip empty lines
if 'ERROR' in line or 'CRITICAL' in line:
logger.error(f"[Subprocess] {line.strip()}")
elif 'WARNING' in line:
logger.warning(f"[Subprocess] {line.strip()}")
else:
<http://logger.info|logger.info>(f"[Subprocess] {line.strip()}")
# Check if subprocess succeeded
if process.returncode != 0:
# Extract just the core error message from stderr if available
core_error = "Unknown preprocessing error"
if process.stderr:
# Look for the actual error line (usually starts with "ERROR -")
lines = process.stderr.strip().split('\n')
for line in lines:
if 'ERROR -' in line or 'failed:' in line.lower():
core_error = line.strip()
break
raise Exception(f"Preprocessing subprocess failed (exit code {process.returncode}): {core_error}")
# Read processed data
if not os.path.exists(output_file_path):
raise Exception(f"Subprocess completed but output file not found: {output_file_path}")
with open(output_file_path, 'r', encoding='utf-8') as f:
processed_data = f.read()
<http://logger.info|logger.info>(f"Subprocess preprocessing completed successfully")
return processed_data
except subprocess.TimeoutExpired:
error_msg = f"Preprocessing subprocess timed out after {timeout_seconds} seconds"
logger.error(error_msg)
raise Exception(error_msg)
except Exception as e:
logger.error(f"Subprocess preprocessing failed: {e}")
raise
finally:
# Clean up temporary files
try:
if os.path.exists(input_file_path):
os.unlink(input_file_path)
if os.path.exists(output_file_path):
os.unlink(output_file_path)
except Exception as cleanup_error:
logger.warning(f"Failed to cleanup temp files: {cleanup_error}")
Here is the full block of code.hundreds-rainbow-67050
09/19/2025, 6:03 PMfuture-crowd-14830
09/19/2025, 6:05 PMfuture-crowd-14830
09/19/2025, 6:19 PMhundreds-rainbow-67050
09/19/2025, 6:34 PMfuture-crowd-14830
09/19/2025, 6:37 PMhundreds-rainbow-67050
09/19/2025, 7:44 PMhundreds-rainbow-67050
09/19/2025, 7:50 PMPopen and stream the logs as they come in, eg:
import subprocess
with subprocess.Popen(
["uv", "run", "python", ...],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
bufsize=1,
) as p:
for line in p.stdout:
print("[child]", line.rstrip())future-crowd-14830
09/19/2025, 10:13 PMhundreds-rainbow-67050
09/22/2025, 10:18 PM2.18.8future-crowd-14830
09/29/2025, 1:35 PM