Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/syft-job/src/syft_job/job_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import html
import re
from html import escape
from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand Down Expand Up @@ -149,7 +148,7 @@ def _repr_html_(self) -> str:
char_count = len(clean_content)
line_count = len(lines)
if self.job_info.log_is_truncated("stdout.txt"):
html_content += f"\n{escape(LOG_TRUNCATION_MESSAGE)}"
html_content += f"\n{html.escape(LOG_TRUNCATION_MESSAGE)}"

return f"""
<style>
Expand Down
12 changes: 10 additions & 2 deletions packages/syft-job/tests/test_job_stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

def _viewer(tmp_path: Path, content: str) -> StdoutViewer:
(tmp_path / "stdout.txt").write_text(content)
job_info = SimpleNamespace(status="done", _log_path=lambda name: tmp_path / name)
job_info = SimpleNamespace(
status="done",
_log_path=lambda name: tmp_path / name,
log_is_truncated=lambda name: False,
)
return StdoutViewer(job_info)


Expand All @@ -31,7 +35,11 @@ def test_stderr_repr_html_escapes_output_and_keeps_colors(tmp_path: Path):
(tmp_path / "stderr.txt").write_text(
'File "run.py", line 1, in <module>\n\x1b[31mValueError\x1b[0m\n'
)
job_info = SimpleNamespace(status="done", _log_path=lambda name: tmp_path / name)
job_info = SimpleNamespace(
status="done",
_log_path=lambda name: tmp_path / name,
log_is_truncated=lambda name: False,
)
html = StderrViewer(job_info)._repr_html_()

assert "in &lt;module&gt;" in html
Expand Down
Loading