Skip to content

Commit d7dd74b

Browse files
committed
Use output.log for completed card and added sanitisation filter
1 parent 4b0a3cb commit d7dd74b

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

completed.html.erb

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,42 @@ def sanitize_live_log(text)
7272
compact.join("\n").strip
7373
end
7474

75+
def sanitize_output_log(text)
76+
return nil if text.nil?
77+
78+
lines = text.split("\n")
79+
cleaned = []
80+
index = 0
81+
82+
while index < lines.length
83+
line = lines[index]
84+
85+
if line.start_with?("WARN: [PBSPRO] queue status cannot be fetched")
86+
index += 1
87+
index += 1 while index < lines.length && !lines[index].strip.empty?
88+
index += 1 if index < lines.length && lines[index].strip.empty?
89+
next
90+
end
91+
92+
if line.strip == "Cleaning up..."
93+
break
94+
end
95+
96+
if line.match?(/^=+$/) && index + 1 < lines.length && lines[index + 1].include?("Resource Usage on ")
97+
break
98+
end
99+
100+
cleaned << line
101+
index += 1
102+
end
103+
104+
while cleaned.any? && cleaned.last.strip.empty?
105+
cleaned.pop
106+
end
107+
108+
cleaned.join("\n").strip
109+
end
110+
75111
base_out_dir = (connect.respond_to?(:base_out_dir) && !connect.base_out_dir.blank?) ? connect.base_out_dir : portal_default_base_out_dir
76112
results_url_base = (connect.respond_to?(:results_url_base) && !connect.results_url_base.blank?) ? connect.results_url_base : portal_default_results_url_base
77113
session_output_dir = (connect.respond_to?(:session_output_dir) && !connect.session_output_dir.blank?) ? connect.session_output_dir : nil
@@ -82,7 +118,11 @@ output_log_path = File.join(log_dir, "output.log")
82118
output_log_url = file_url(results_url_base, output_log_path)
83119
summary_log_url = File.file?(output_log_path) ? output_log_url : live_log_url
84120
summary_log_label = File.file?(output_log_path) ? "output.log" : "live_log.log"
85-
log_text = sanitize_live_log(tail_text(live_log_path))
121+
log_text = if File.file?(output_log_path)
122+
sanitize_output_log(tail_text(output_log_path, 16384, 40))
123+
else
124+
sanitize_live_log(tail_text(live_log_path))
125+
end
86126
%>
87127
<div class="ood-completed-log-card">
88128
<div><b>Log</b>: <a target="_blank" rel="noopener" href="<%= summary_log_url %>"><%= summary_log_label %></a></div>

0 commit comments

Comments
 (0)