Skip to content

Commit 4d67034

Browse files
committed
fix(#832): fixed task-abort in dashboard
The functionality to abort a task was totally broken in the dashboard. This was fixed now. Signed-off-by: Tobias Anker <tobias.anker@kitsunemimi.moe>
1 parent 01fe198 commit 4d67034

5 files changed

Lines changed: 136 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
- restarts of the same sakura-host doesn't result in duplications in hanami anymore
5151
- progress-bar in dashboard for multiple epochs is now calculated correctly
5252
- fixed number of output-values in case of int and float output-type
53+
- task-abort-endpoint not works
54+
- task-abort-modal was fixed in the dashboard
5355

5456
## v0.10.0
5557

src/binaries/sakura/src/api/routes/v1alpha.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ pub fn v1alpha_routes() -> Scope {
6666
))
6767
.service(resource("/{task_uuid}").route(get().to(get_task_v1_0::get_task)))
6868
.service(
69-
resource("/{task_uuid}/abort").route(put().to(abort_task_v1_0::abort_task)),
69+
resource("/{task_uuid}/abort")
70+
.route(put().to(abort_task_v1_0::abort_task)),
7071
)
7172
.service(resource("").route(get().to(list_task_v1_0::list_task))),
7273
),

src/dashboard/app/src/components/workload/model/model_delete_modal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import { getAuthContext } from "@/auth_context";
5454
import { handleAxiosError } from "@/handleAxiosError";
5555
5656
interface Props {
57-
model: { uuid: number; name: string } | null;
57+
model: { uuid: string; name: string } | null;
5858
icons: { acceptIcon: string; cancelIcon: string };
5959
}
6060
defineProps<Props>();
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!--
2+
// Copyright 2022-2026 Tobias Anker <tobias.anker@kitsunemimi.moe>
3+
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
-->
16+
17+
<template>
18+
<div class="modal-overlay" @click.self="cancel">
19+
<div class="modal task-delete-modal">
20+
<div class="modal-topbar">
21+
<span>Abort task</span>
22+
</div>
23+
<div class="modal-content">
24+
<p>Are you sure you want to abort?</p>
25+
<strong>Task: {{ task?.uuid }}</strong>
26+
</div>
27+
28+
<div class="modal-bottombar">
29+
<div class="modal-actions">
30+
<button
31+
class="icon-button"
32+
@click="handleAccept(task?.uuid, model_uuid, torii_port)"
33+
>
34+
<img :src="icons.acceptIcon" alt="Accept" />
35+
</button>
36+
<button class="icon-button" @click="cancel">
37+
<img :src="icons.cancelIcon" alt="Cancel" />
38+
</button>
39+
</div>
40+
</div>
41+
</div>
42+
</div>
43+
<div v-if="errorPopupMsg" class="error-popup">
44+
<button class="error-close-btn" @click="errorPopupMsg = ''">✕</button>
45+
{{ errorPopupMsg }}
46+
</div>
47+
</template>
48+
49+
<script lang="ts" setup>
50+
import { ref } from "vue";
51+
import axios from "axios";
52+
53+
import { getAuthContext } from "@/auth_context";
54+
import { handleAxiosError } from "@/handleAxiosError";
55+
56+
interface Props {
57+
model_uuid: string;
58+
torii_port: number;
59+
task: { uuid: string } | null;
60+
icons: { acceptIcon: string; cancelIcon: string };
61+
}
62+
defineProps<Props>();
63+
const emit = defineEmits<{
64+
(e: "accept"): void;
65+
(e: "cancel"): void;
66+
}>();
67+
const errorPopupMsg = ref<string>("");
68+
69+
async function handleAccept(task_uuid: string, model_uuid: string, torii_port: number) {
70+
if (!task_uuid) return;
71+
try {
72+
const authContext = getAuthContext();
73+
const sakura_api = axios.create({
74+
baseURL: `${authContext.torii_base_address}:${torii_port}`,
75+
});
76+
77+
await sakura_api.put(`/v1alpha/model/${model_uuid}/task/${task_uuid}/abort`, {}, {
78+
headers: { Authorization: `Bearer ${authContext.token}` },
79+
});
80+
81+
emit("accept");
82+
} catch (err) {
83+
errorPopupMsg.value = handleAxiosError(err, "Failed to delete task");
84+
}
85+
}
86+
87+
function cancel() {
88+
emit("cancel");
89+
}
90+
</script>
91+
92+
<style scoped>
93+
.task-delete-modal {
94+
width: 30rem;
95+
}
96+
</style>

src/dashboard/app/src/components/workload/task/task_overview.vue

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
v-if="openDropdown === task.uuid"
5656
class="table-dropdown-menu"
5757
>
58-
<button @click="openDeleteModal(task)">
59-
Delete
58+
<button @click="openAbortModal(task)">
59+
Abort
6060
</button>
6161
</div>
6262
</div>
@@ -76,6 +76,16 @@
7676
@accept="acceptAddModal"
7777
@cancel="cancelAddModal"
7878
/>
79+
80+
<TaskAbortModal
81+
v-if="showAbortModal"
82+
:model_uuid="props.id"
83+
:torii_port="torii_port"
84+
:task="taskToAbort"
85+
:icons="icons"
86+
@accept="acceptAbortModal"
87+
@cancel="cancelAbortModal"
88+
/>
7989
</div>
8090
<div v-if="errorPopupMsg" class="error-popup">
8191
<button class="error-close-btn" @click="errorPopupMsg = ''">✕</button>
@@ -90,6 +100,7 @@ import axios from "axios";
90100
91101
import { getAuthContext } from "@/auth_context";
92102
import TaskCreateModal from "./task_create_modal.vue";
103+
import TaskAbortModal from "./task_abort_modal.vue";
93104
import ProgressBar from "./progress_bar.vue";
94105
import { handleAxiosError } from "@/handleAxiosError";
95106
@@ -102,6 +113,9 @@ const tasks = ref<{ uuid: string; taskName: string }[]>([]);
102113
const showAddModal = ref(false);
103114
const openDropdown = ref<string | null>(null);
104115
const icons = inject<{ acceptIcon: string; cancelIcon: string }>("icons")!;
116+
const taskToAbort = ref<{ uuid: string } | null>(null);
117+
const showAbortModal = ref(false);
118+
105119
var torii_port = 0;
106120
107121
async function fetchTasks() {
@@ -171,6 +185,25 @@ async function acceptAddModal() {
171185
cancelAddModal();
172186
}
173187
188+
//=============================================================================
189+
// Abort modal
190+
//=============================================================================
191+
function openAbortModal(task: { uuid: string }) {
192+
taskToAbort.value = task;
193+
showAbortModal.value = true;
194+
openDropdown.value = null;
195+
}
196+
function cancelAbortModal() {
197+
showAbortModal.value = false;
198+
taskToAbort.value = null;
199+
openDropdown.value = null; // close any open action dropdown
200+
}
201+
202+
async function acceptAbortModal() {
203+
await fetchTasks();
204+
cancelAbortModal();
205+
}
206+
174207
//=============================================================================
175208
// Listener
176209
//=============================================================================

0 commit comments

Comments
 (0)