Skip to content

Commit 4529a84

Browse files
committed
demo: output file formats
1 parent 87290fb commit 4529a84

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

jupyter_scheduler/environments.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def output_formats_mapping(self) -> Dict[str, str]:
7171
"html": "HTML",
7272
"stdout": "Output",
7373
"stderr": "Errors",
74+
"json": "Results",
7475
}
7576

7677

@@ -100,6 +101,7 @@ def output_formats_mapping(self) -> Dict[str, str]:
100101
"html": "HTML",
101102
"stdout": "Output",
102103
"stderr": "Errors",
104+
"json": "Results",
103105
}
104106

105107

jupyter_scheduler/handlers.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,15 @@ async def post(self):
309309
payload["backend"] = backend.config.id
310310
scheduler = backend.scheduler
311311

312-
# Set default output_formats for Python backend
313-
if backend.config.id == "jupyter_server_py" and not payload.get("output_formats"):
314-
payload["output_formats"] = ["stdout", "stderr"]
312+
# Set default output_formats based on file type
313+
if not payload.get("output_formats"):
314+
input_uri = payload.get("input_uri", "")
315+
if input_uri.endswith(".py"):
316+
payload["output_formats"] = ["stdout", "stderr"]
317+
elif input_uri.endswith(".qasm"):
318+
payload["output_formats"] = ["json"]
319+
elif input_uri.endswith(".ipynb"):
320+
payload["output_formats"] = ["ipynb", "html"]
315321
else:
316322
# Fallback to default scheduler (backwards compatibility)
317323
scheduler = self.scheduler

0 commit comments

Comments
 (0)