Skip to content

Commit f10bb87

Browse files
committed
Moved placeholder to a separate function, ruff format.
1 parent 4c89305 commit f10bb87

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

jupyter_server_documents/outputs/manager.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import glob
21
import json
32
import os
43
from pathlib import Path, PurePath
@@ -43,21 +42,18 @@ def get_output(self, file_id, cell_id, output_index):
4342
with open(path, "r", encoding="utf-8") as f:
4443
output = json.loads(f.read())
4544
return output
46-
45+
4746
def get_outputs(self, file_id, cell_id):
4847
"""Get all outputs by file_id, cell_id."""
4948
path = self._build_path(file_id, cell_id)
5049
if not os.path.isdir(path):
5150
raise FileNotFoundError(f"The output dir doesn't exist: {path}")
52-
51+
5352
outputs = []
5453

55-
output_files = [
56-
(f, int(f.stem))
57-
for f in path.glob("*.output")
58-
]
54+
output_files = [(f, int(f.stem)) for f in path.glob("*.output")]
5955
output_files.sort(key=lambda x: x[1])
60-
output_files = output_files[:self.stream_limit]
56+
output_files = output_files[: self.stream_limit]
6157
has_more_files = len(output_files) >= self.stream_limit
6258

6359
outputs = []
@@ -67,17 +63,10 @@ def get_outputs(self, file_id, cell_id):
6763
outputs.append(output)
6864

6965
if has_more_files:
70-
url = f"/api/outputs/{file_id}/{cell_id}/stream"
71-
placeholder = {
72-
"output_type": "display_data",
73-
"data": {
74-
'text/html': f'<a href="{url}">Click this link to see the full stream output</a>'
75-
}
76-
}
66+
placeholder = self._create_outputs_placeholder(file_id, cell_id)
7767
outputs.append(json.dumps(placeholder))
7868

7969
return outputs
80-
8170

8271
def get_outputs(self, file_id, cell_id):
8372
"""Get all outputs by file_id, cell_id."""

0 commit comments

Comments
 (0)