Skip to content
Snippets Groups Projects
Commit 68520c30 authored by Theo Lesage's avatar Theo Lesage Committed by Erwan Rouchet
Browse files

Add a field for deleting worker results by filtering worker runs

parent 39e28851
No related branches found
No related tags found
1 merge request!1654Add a field for deleting worker results by filtering worker runs
...@@ -8,6 +8,11 @@ export type DeleteWorkerResultsParameters = { ...@@ -8,6 +8,11 @@ export type DeleteWorkerResultsParameters = {
*/ */
element_id?: UUID element_id?: UUID
/**
* Delete results produced by a specific worker run
*/
worker_run_id?: UUID
/** /**
* Delete results produced with a specific worker version. * Delete results produced with a specific worker version.
*/ */
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
:is-large="!advancedMode" :is-large="!advancedMode"
> >
<template v-slot:header> <template v-slot:header>
<p class="modal-card-title mr-5">{{ truncateLong('Delete results ' + originDescription) }}</p> <p class="modal-card-title mr-5">
{{ truncateLong('Delete results ' + originDescription) }}
</p>
<span class="ml-auto"> <span class="ml-auto">
<input <input
id="advancedModeSwitch" id="advancedModeSwitch"
...@@ -13,11 +15,36 @@ ...@@ -13,11 +15,36 @@
class="switch is-rtl is-rounded is-info" class="switch is-rtl is-rounded is-info"
v-model="advancedMode" v-model="advancedMode"
/> />
<label class="is-pulled-right mr-4" for="advancedModeSwitch">Advanced mode</label> <label
class="is-pulled-right mr-4"
for="advancedModeSwitch"
>Advanced mode</label>
</span> </span>
</template> </template>
<div v-if="advancedMode" class="content"> <div v-if="advancedMode" class="content">
<div class="field">
<label class="label">Worker run UUID</label>
<div class="control">
<input
type="text"
placeholder="00000000-0000-0000-0000-000000000000"
maxlength="36"
class="input uuid-input"
v-model="workerRunId"
:disabled="loading || undefined"
/>
<template v-if="errors.worker_run_id">
<p
class="help is-danger"
v-for="err in errors.worker_run_id"
:key="err"
>
{{ err }}
</p>
</template>
</div>
</div>
<div class="field"> <div class="field">
<label class="label">Worker version UUID</label> <label class="label">Worker version UUID</label>
<div class="control"> <div class="control">
...@@ -27,7 +54,7 @@ ...@@ -27,7 +54,7 @@
maxlength="36" maxlength="36"
class="input uuid-input" class="input uuid-input"
v-model="workerVersionId" v-model="workerVersionId"
:disabled="loading || null" :disabled="inWorkerRunMode || loading || undefined"
/> />
<template v-if="errors.worker_version_id"> <template v-if="errors.worker_version_id">
<p <p
...@@ -49,7 +76,7 @@ ...@@ -49,7 +76,7 @@
maxlength="36" maxlength="36"
class="input uuid-input" class="input uuid-input"
v-model="modelVersionId" v-model="modelVersionId"
:disabled="loading || null" :disabled="inWorkerRunMode || loading || undefined"
/> />
<template v-if="errors.model_version_id"> <template v-if="errors.model_version_id">
<p <p
...@@ -68,16 +95,19 @@ ...@@ -68,16 +95,19 @@
<span class="control"> <span class="control">
<label <label
v-for="(value, label) in configurationRadio" v-for="(value, label) in configurationRadio"
:key="value" :key="label"
class="radio ml-4" class="radio ml-4"
:class="{ 'active': configurationField === value }" :class="{ active: configurationField === value }"
v-on:click.capture="setConfigurationField(value)" v-on:click.capture="setConfigurationField(value)"
> >
<input <input
class="is-checkradio" class="is-checkradio"
type="radio" type="radio"
:checked="configurationField === value || null" :checked="
:disabled="loading || null" (configurationField === value && !inWorkerRunMode) ||
undefined
"
:disabled="inWorkerRunMode || loading || undefined"
/> />
{{ label }} {{ label }}
</label> </label>
...@@ -91,7 +121,12 @@ ...@@ -91,7 +121,12 @@
maxlength="36" maxlength="36"
class="input uuid-input" class="input uuid-input"
v-model="configurationId" v-model="configurationId"
:disabled="configurationField !== true || loading || null" :disabled="
inWorkerRunMode ||
configurationField !== true ||
loading ||
undefined
"
/> />
<template v-if="errors.configuration_id"> <template v-if="errors.configuration_id">
<p <p
...@@ -104,11 +139,7 @@ ...@@ -104,11 +139,7 @@
</template> </template>
</div> </div>
</div> </div>
<button <button class="button is-danger" type="button" v-on:click="checkManual">
class="button is-danger is-light"
type="button"
v-on:click="checkManual"
>
Delete Delete
</button> </button>
</div> </div>
...@@ -124,16 +155,28 @@ ...@@ -124,16 +155,28 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="({ worker_version, worker_configuration, model_version }, cacheId) in workerVersionsCache" :key="cacheId"> <tr
v-for="(
{ worker_version, worker_configuration, model_version }, cacheId
) in workerVersionsCache"
:key="cacheId"
>
<td> <td>
<WorkerVersionSummary :worker-version="worker_version" /> <WorkerVersionSummary :worker-version="worker_version" />
</td> </td>
<td> <td>
<ModelVersionSummary v-if="model_version" :model-version="model_version" /> <ModelVersionSummary
v-if="model_version"
:model-version="model_version"
/>
<template v-else></template> <template v-else></template>
</td> </td>
<td> <td>
<ConfigurationSummary v-if="worker_configuration" :configuration="worker_configuration" :worker-version="worker_version" /> <ConfigurationSummary
v-if="worker_configuration"
:configuration="worker_configuration"
:worker-version="worker_version"
/>
<template v-else></template> <template v-else></template>
</td> </td>
<td> <td>
...@@ -154,13 +197,16 @@ ...@@ -154,13 +197,16 @@
</template> </template>
</Modal> </Modal>
<Modal <Modal v-model="confirmationModal" title="Confirm deletion">
v-model="confirmationModal"
title="Confirm deletion"
>
<div class="content"> <div class="content">
<template v-if="deletesAll"> <template v-if="inWorkerRunMode">
You are about to delete <strong>all worker results</strong> {{ originDescription }}. You are about to delete all results from worker run <strong>{{ workerRunId }}</strong>
{{ originDescription }}.
</template>
<template v-else-if="deletesAll">
You are about to delete <strong>all worker results</strong>
{{ originDescription }}.
</template> </template>
<template v-else> <template v-else>
...@@ -169,13 +215,21 @@ ...@@ -169,13 +215,21 @@
</p> </p>
</template> </template>
<hr class="my-3" /> <hr class="my-3" />
<p class="mb-0">Child elements of these results will also be deleted recursively.</p> <p class="mb-0">
Child elements of these results will also be deleted recursively.
</p>
<p>This action is irreversible.</p> <p>This action is irreversible.</p>
</div> </div>
<template v-slot:footer="{ close }"> <template v-slot:footer="{ close }">
<button class="button" v-on:click="close">Cancel</button> <button class="button" v-on:click="close">Cancel</button>
<button class="button is-danger ml-auto" v-on:click="performDelete" :title="originDescription">{{ truncateLong('Delete results ' + originDescription) }}</button> <button
class="button is-danger ml-auto"
v-on:click="performDelete"
:title="originDescription"
>
{{ truncateLong('Delete results ' + originDescription) }}
</button>
</template> </template>
</Modal> </Modal>
</template> </template>
...@@ -196,10 +250,7 @@ import ModelVersionSummary from '@/components/Model/Versions/Summary.vue' ...@@ -196,10 +250,7 @@ import ModelVersionSummary from '@/components/Model/Versions/Summary.vue'
import ConfigurationSummary from '@/components/Process/Workers/Configurations/Summary.vue' import ConfigurationSummary from '@/components/Process/Workers/Configurations/Summary.vue'
export default defineComponent({ export default defineComponent({
mixins: [ mixins: [corporaMixin, truncateMixin],
corporaMixin,
truncateMixin
],
components: { components: {
Modal, Modal,
WorkerVersionSummary, WorkerVersionSummary,
...@@ -219,7 +270,7 @@ export default defineComponent({ ...@@ -219,7 +270,7 @@ export default defineComponent({
*/ */
corpusId: { corpusId: {
type: String as PropType<UUID>, type: String as PropType<UUID>,
validator: value => typeof value === 'string' && UUID_REGEX.test(value), validator: (value) => typeof value === 'string' && UUID_REGEX.test(value),
required: true required: true
}, },
/** /**
...@@ -228,7 +279,7 @@ export default defineComponent({ ...@@ -228,7 +279,7 @@ export default defineComponent({
*/ */
elementId: { elementId: {
type: String as PropType<UUID>, type: String as PropType<UUID>,
validator: value => typeof value === 'string' && UUID_REGEX.test(value), validator: (value) => typeof value === 'string' && UUID_REGEX.test(value),
default: null default: null
}, },
/** /**
...@@ -250,6 +301,7 @@ export default defineComponent({ ...@@ -250,6 +301,7 @@ export default defineComponent({
/** /**
* Custom fields for manual deletion * Custom fields for manual deletion
*/ */
workerRunId: '',
workerVersionId: '', workerVersionId: '',
modelVersionId: '', modelVersionId: '',
configurationId: '', configurationId: '',
...@@ -302,40 +354,64 @@ export default defineComponent({ ...@@ -302,40 +354,64 @@ export default defineComponent({
messages.push(`You are about to delete results ${this.originDescription}`) messages.push(`You are about to delete results ${this.originDescription}`)
// Worker version // Worker version
const versionName = this.truncateLong( const versionName = this.truncateLong(
this.versionCacheToDelete?.worker_version?.worker?.name || this.workerVersionId || 'Any' this.versionCacheToDelete?.worker_version?.worker?.name ||
this.workerVersionId ||
'Any'
) )
messages.push(`• Worker version: ${versionName}`) messages.push(`• Worker version: ${versionName}`)
// Model version // Model version
if (this.advancedMode) { if (this.advancedMode) {
messages.push(`• Model version: ${this.modelVersionId || 'Any'}`) messages.push(`• Model version: ${this.modelVersionId || 'Any'}`)
} else if (this.versionCacheToDelete?.model_version) { } else if (this.versionCacheToDelete?.model_version) {
messages.push(`• Model version: ${this.versionCacheToDelete.model_version.model.name}`) messages.push(
`• Model version: ${this.versionCacheToDelete.model_version.model.name}`
)
} }
// Worker configuration // Worker configuration
const confName = this.advancedMode const confName = this.advancedMode
? this.configurationId || (this.configurationField === null && 'Any') || 'None' ? this.configurationId ||
: this.truncateLong(this.versionCacheToDelete?.worker_configuration?.name || 'None') (this.configurationField === null && 'Any') ||
'None'
: this.truncateLong(
this.versionCacheToDelete?.worker_configuration?.name || 'None'
)
messages.push(`• Configuration: ${confName}`) messages.push(`• Configuration: ${confName}`)
return messages return messages
}, },
payload () { payload () {
const payload: DeleteWorkerResultsParameters = { use_selection: this.selection } const payload: DeleteWorkerResultsParameters = {
use_selection: this.selection
}
if (this.elementId) payload.element_id = this.elementId if (this.elementId) payload.element_id = this.elementId
if (this.advancedMode) { if (this.advancedMode) {
if (this.workerVersionId) payload.worker_version_id = this.workerVersionId if (this.workerRunId) payload.worker_run_id = this.workerRunId
if (this.workerVersionId) { payload.worker_version_id = this.workerVersionId }
if (this.modelVersionId) payload.model_version_id = this.modelVersionId if (this.modelVersionId) payload.model_version_id = this.modelVersionId
if (this.configurationField !== null) { payload.configuration_id = this.configurationField ? this.configurationId : false } if (this.configurationField !== null) {
payload.configuration_id = this.configurationField
? this.configurationId
: false
}
} else if (this.versionCacheToDelete !== null) { } else if (this.versionCacheToDelete !== null) {
payload.worker_version_id = this.versionCacheToDelete.worker_version.id payload.worker_version_id = this.versionCacheToDelete.worker_version.id
payload.configuration_id = this.versionCacheToDelete?.worker_configuration?.id ?? false payload.configuration_id =
if (this.versionCacheToDelete?.model_version?.id) payload.model_version_id = this.versionCacheToDelete.model_version.id this.versionCacheToDelete?.worker_configuration?.id ?? false
if (this.versionCacheToDelete?.model_version?.id) { payload.model_version_id = this.versionCacheToDelete.model_version.id }
} }
return payload return payload
},
inWorkerRunMode (): boolean {
return this.workerRunId !== ''
} }
}, },
methods: { methods: {
...mapActions(useMLResultsStore, ['listWorkerVersionsCache', 'deleteWorkerResults']), ...mapActions(useMLResultsStore, [
updateModelValue (value: boolean) { this.$emit('update:modelValue', value) }, 'listWorkerVersionsCache',
'deleteWorkerResults'
]),
updateModelValue (value: boolean) {
this.$emit('update:modelValue', value)
},
select (cacheId: UUID) { select (cacheId: UUID) {
this.cacheUUIDToDelete = cacheId this.cacheUUIDToDelete = cacheId
this.confirmationModal = true this.confirmationModal = true
...@@ -345,11 +421,24 @@ export default defineComponent({ ...@@ -345,11 +421,24 @@ export default defineComponent({
}, },
checkManual () { checkManual () {
this.errors = {} this.errors = {}
if (this.workerVersionId && !UUID_REGEX.test(this.workerVersionId)) { this.errors.worker_version_id = ['This value must be a valid UUID.'] } if (this.workerRunId && !UUID_REGEX.test(this.workerRunId)) {
if (this.modelVersionId && !UUID_REGEX.test(this.modelVersionId)) { this.errors.model_version_id = ['This value must be a valid UUID.'] } this.errors.worker_run_id = ['This value must be a valid UUID.']
if (this.configurationId && !UUID_REGEX.test(this.configurationId)) { this.errors.configuration_id = ['This value must be a valid UUID.'] } }
if (this.configurationField === true && this.configurationId === '') { this.errors.configuration_id = ['This value must be set.'] } if (this.workerVersionId && !UUID_REGEX.test(this.workerVersionId)) {
if (Object.keys(this.errors).length === 0) { this.confirmationModal = true } this.errors.worker_version_id = ['This value must be a valid UUID.']
}
if (this.modelVersionId && !UUID_REGEX.test(this.modelVersionId)) {
this.errors.model_version_id = ['This value must be a valid UUID.']
}
if (this.configurationId && !UUID_REGEX.test(this.configurationId)) {
this.errors.configuration_id = ['This value must be a valid UUID.']
}
if (this.configurationField === true && this.configurationId === '') {
this.errors.configuration_id = ['This value must be set.']
}
if (Object.keys(this.errors).length === 0) {
this.confirmationModal = true
}
}, },
async performDelete () { async performDelete () {
this.errors = {} this.errors = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment