from pathlib import Path
def count_error_lines(input_file_path):
input_path = Path(input_file_path)
output_path = Path("/workspace/shared/logs/processed") / f"{input_path.stem}.txt"
output_path.parent.mkdir(parents=True, exist_ok=True)
error_count = sum("ERROR" in line for line in input_path.read_text().splitlines())
output_path.write_text(f"{error_count}\n")
return str(output_path)
from burla import remote_parallel_map
processed_file_paths = remote_parallel_map(count_error_lines, input_file_paths)
from pathlib import Path
total_error_count = 0
for processed_file_path in processed_file_paths:
total_error_count += int(Path(processed_file_path).read_text().strip())
final_report_path = Path("/workspace/shared/logs/final/error-report.txt")
final_report_path.parent.mkdir(parents=True, exist_ok=True)
final_report_path.write_text(f"total_error_count={total_error_count}\n")
print(final_report_path)
from burla import remote_parallel_map
remote_parallel_map(count_error_lines, input_file_paths[:20])