Skip to content
Open
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
21 changes: 21 additions & 0 deletions admin/backend/views/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,24 @@ def rerun_task(task_id: str):
return jsonify({"ok": False, "error": str(error)}), 500

return jsonify({"ok": True, "task_id": new_task_id})


@tasks_bp.route("/<task_id>/output/download")
def download_task_output(task_id: str):
bench_root = current_app.config["BENCH_ROOT"]
try:
task = TaskReader(bench_root).read_task(task_id)
except TaskNotFoundError as error:
return jsonify({"error": str(error)}), 404
except Exception as error:
return jsonify({"error": str(error)}), 500

output_path = task.output_path
if not output_path.exists():
return jsonify({"error": "No output file found"}), 404

return Response(
output_path.read_bytes(),
mimetype="text/plain",
headers={"Content-Disposition": f'attachment; filename="{task_id}_output.log"'},
)
4 changes: 4 additions & 0 deletions admin/frontend/src/pages/TaskDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRoute, useRouter } from 'vue-router'
import { Button, Badge, Dialog, LoadingText, ErrorMessage } from 'frappe-ui'
import TerminalOutput from '../components/TerminalOutput.vue'
import { processLine } from '../utils/ansi.js'
import LucideDownload from '~icons/lucide/download'

const route = useRoute()
const router = useRouter()
Expand Down Expand Up @@ -131,6 +132,9 @@ onUnmounted(() => { if (es) { es.close(); es = null } })
{{ fmtDuration(task.duration_seconds) }}
</span>
<div class="ml-auto flex gap-2">
<a :href="`/api/tasks/${taskId}/output/download`" class="ml-auto">
<Button variant="ghost" :prefix-icon="LucideDownload">Download</Button>
</a>
<Button
v-if="task.status === 'running'"
variant="outline"
Expand Down
Loading