Skip to content

Commit ef5499e

Browse files
committed
Added various plausible goals
1 parent 724a104 commit ef5499e

15 files changed

Lines changed: 104 additions & 61 deletions

File tree

client/src/api/jobs.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type ProgressResponse = AxiosResponse<Progress>
1313
export const jobsPath = (corpus: UUID): string => `/corpora/${corpus}/jobs`
1414
const jobPath = (corpus: UUID, job: string): string => `/corpora/${corpus}/jobs/${job}`
1515
const jobProgressPath = (corpus: UUID, job: string): string => `/corpora/${corpus}/jobs/${job}/progress`
16+
const jobCancelPath = (corpus: UUID, job: string): string => `/corpora/${corpus}/jobs/${job}/cancel`
1617

1718
/**
1819
* Fetch all jobs for a corpus.
@@ -37,8 +38,12 @@ export function postJob(corpus: UUID, job: string): Promise<ProgressResponse> {
3738
* @param job Tagger job name.
3839
* @param hard True to delete the job, false to cancel it.
3940
*/
40-
export function cancelOrDeleteJob(corpus: UUID, job: string, hard: boolean): Promise<ProgressResponse> {
41-
return axios.delete(jobPath(corpus, job), { params: { hard: hard } })
41+
export function removeJob(corpus: UUID, job: string): Promise<ProgressResponse> {
42+
return axios.delete(jobPath(corpus, job))
43+
}
44+
45+
export function cancelJob(corpus: UUID, job: string): Promise<ProgressResponse> {
46+
return axios.post(jobCancelPath(corpus, job))
4247
}
4348

4449
/**

client/src/components/modals/jobs/JobModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
</GInfo>
9494

9595
<!-- Layer preview -->
96-
<LayerViewer v-if="job.summary.annotations.token > 0" :job />
96+
<LayerViewer v-if="job.annotations.token > 0" :job />
9797
</template>
9898

9999
<!-- delete job modal -->

client/src/components/tables/DocumentsTable.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
<template v-else> This corpus is empty. </template>
1919
</template>
2020

21-
<template #cell-summary="data: TableData<DocumentMetadata>">
21+
<template #cell-annotations="data: TableData<DocumentMetadata>">
2222
<RightFloatCell>
23-
<template #left>
24-
{{ data.value.annotations.token }}
25-
</template>
23+
<template #left> {{ data.item.annotations.token }} </template>
2624
<template #right>
27-
<InspectButton v-if="data.value.annotations.token > 0" @click="previewDocument = data.item" />
25+
<InspectButton v-if="data.item.annotations.token > 0" @click="previewDocument = data.item" />
2826
</template>
2927
</RightFloatCell>
3028
</template>
@@ -81,10 +79,10 @@ const columns = computed<Column<DocumentMetadata>[]>(() => [
8179
{ key: "format" },
8280
{ key: "text" },
8381
{
84-
key: "summary",
82+
key: "annotations",
8583
label: "tokens",
8684
align: "right",
87-
sortOn: (d: DocumentMetadata): number => d.summary?.annotations.token,
85+
sortOn: (d: DocumentMetadata): number => d.annotations.token,
8886
},
8987
{ key: "modified", format: (d: DocumentMetadata): string => formatDate(d.modified) },
9088
{ key: "actions", noSort: true, hidden: !canWrite || type === DocsTableType.dataset },

client/src/components/tables/LayerViewer.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<template #title>Annotations preview of {{ name }}</template>
44
<template #header>
55
<dl>
6-
<dl v-for="[key, value] in Object.entries(summary.annotations)" :key="key">
6+
<dl v-for="[key, value] in Object.entries(annotations)" :key="key">
77
<dt>{{ key }}:</dt>
88
<dd>{{ value }}</dd>
99
</dl>
@@ -21,9 +21,8 @@ const { document, job } = defineProps<{ document?: DocumentMetadata; job?: Job }
2121
2222
// #computed
2323
const name = computed(() => (document ? document.name : job?.tagger.id))
24-
const summary = computed(() => (document ? document.summary : job.summary))
25-
const annotations = computed(() => Object.keys(summary.value.annotations))
26-
const columns = computed(() => annotations.value.map((i) => ({ key: i, label: i, noSort: true })))
24+
const annotations = computed(() => (document ? document.annotations : job.annotations))
25+
const columns = computed(() => Object.keys(annotations.value).map((i) => ({ key: i, label: i, noSort: true })))
2726
const terms = computed(() => (document ? document.preview.terms : job.preview.terms))
2827
const items = computed(() => terms.value.map((t) => t.annotations))
2928
</script>

client/src/stores/evaluation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import stores from "@/stores"
22
import * as API from "@/api/evaluation"
33
import * as Utils from "@/api/utils"
4+
import { plausible } from "@/ts/plausible"
45

56
/** Used to download the evaluation CSV zip. */
67
const useEvaluation = defineStore("evaluation", () => {
7-
const { corpusId } = storeToRefs(stores.useCorpora())
8-
const { hypothesisId, referenceId } = storeToRefs(stores.useJobSelection())
8+
const { corpusId, corpus } = storeToRefs(stores.useCorpora())
9+
const { hypothesisId, referenceId, hypothesisJob, referenceJob } = storeToRefs(stores.useJobSelection())
910

1011
const loading = ref<boolean>()
1112

1213
function downloadCSV(): void {
14+
plausible.evaluationDownloaded(corpus.value, hypothesisJob.value, referenceJob.value)
1315
loading.value = true
1416
API.getDownloadEvaluation(corpusId.value, hypothesisId.value, referenceId.value)
1517
.then(Utils.browserDownloadResponseFile)

client/src/stores/evaluation/confusion.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import stores from "@/stores"
22
import type { Confusion } from "@/types/evaluation"
33
import * as API from "@/api/evaluation"
4+
import { plausible } from "@/ts/plausible"
45

56
/** Stores and fetches the confusion matrix. */
67
const useConfusion = defineStore("confusion", () => {
7-
const { hypothesisId, referenceId } = storeToRefs(stores.useJobSelection())
8-
const { corpusId } = storeToRefs(stores.useCorpora())
8+
const { hypothesisId, referenceId, hypothesisJob, referenceJob } = storeToRefs(stores.useJobSelection())
9+
const { corpusId, corpus } = storeToRefs(stores.useCorpora())
910
const loading = ref<boolean>(false)
1011
const confusions = ref<Record<string, Confusion>>()
1112

1213
function reload(): void {
1314
if (!corpusId.value || !hypothesisId.value || !referenceId.value) return
15+
plausible.confusionEvaluated(corpus.value, hypothesisJob.value, referenceJob.value)
1416
loading.value = true
1517
API.getConfusion(corpusId.value, hypothesisId.value, referenceId.value)
1618
.then((res) => (confusions.value = res.data))

client/src/stores/evaluation/distribution.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import stores from "@/stores"
22
import type { TypeToken } from "@/types/evaluation/distribution"
33
import * as API from "@/api/evaluation"
4+
import { plausible } from "@/ts/plausible"
45

56
/** Stores and fetches the type token distribution. */
67
const useDistribution = defineStore("distribution", () => {
7-
const { hypothesisId } = storeToRefs(stores.useJobSelection())
8-
const { corpusId } = storeToRefs(stores.useCorpora())
8+
const { hypothesisId, hypothesisJob } = storeToRefs(stores.useJobSelection())
9+
const { corpusId, corpus } = storeToRefs(stores.useCorpora())
910
const loading = ref<boolean>(false)
1011
const distributions = ref<Record<string, TypeToken[]>>()
1112

1213
function reload(): void {
1314
if (!corpusId.value || !hypothesisId.value) return
15+
plausible.distributionEvaluated(corpus.value, hypothesisJob.value)
1416
loading.value = true
1517
API.getDistribution(corpusId.value, hypothesisId.value)
1618
.then((res) => (distributions.value = res.data))

client/src/stores/evaluation/metrics.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { UUID } from "@/types/corpora"
88
import { useAxios } from "@/api/useAxios"
99

1010
import type { Metrics, MetricsRow } from "@/types/evaluation"
11+
import { plausible } from "@/ts/plausible"
1112

1213
export const metricsPerPosColumns = [
1314
{
@@ -38,10 +39,11 @@ export const metricsPerPosColumns = [
3839
* Stores and fetches the Lemma & PoS accuracy metrics.
3940
*/
4041
const useMetrics = defineStore("metrics", () => {
41-
const { hypothesisId, referenceId } = storeToRefs(stores.useJobSelection())
42-
const { corpusId } = storeToRefs(stores.useCorpora())
42+
const { hypothesisId, referenceId, hypothesisJob, referenceJob } = storeToRefs(stores.useJobSelection())
43+
const { corpusId, corpus } = storeToRefs(stores.useCorpora())
4344
const url = computed<string>(() => {
4445
if (!(hypothesisId.value && referenceId.value)) return undefined
46+
plausible.metricsEvaluated(corpus.value, hypothesisJob.value, referenceJob.value)
4547
return metricsPath(corpusId.value)
4648
})
4749
const { loading, data: metrics } = useAxios<Metrics>(

client/src/stores/jobs.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as API from "@/api/jobs"
22
import type { ProgressResponse } from "@/api/jobs"
33
import { getDocsAtTaggers } from "@/api/taggers"
44
import stores from "@/stores"
5+
import { plausible } from "@/ts/plausible"
56
import { type Job, SOURCE_LAYER } from "@/types/jobs"
67

78
const POLL_INTERVAL = 5000
@@ -10,7 +11,7 @@ const POLL_INTERVAL = 5000
1011
const useJobs = defineStore("jobs", () => {
1112
// Stores
1213
const corporaStore = stores.useCorpora()
13-
const { corpusId } = storeToRefs(corporaStore)
14+
const { corpusId, corpus } = storeToRefs(corporaStore)
1415

1516
// Fields
1617
const loading = ref<boolean>(false)
@@ -78,6 +79,7 @@ const useJobs = defineStore("jobs", () => {
7879
}
7980

8081
function tag(job: string): void {
82+
plausible.jobStarted(corpus.value, jobs.value.find((j) => j.tagger.id === job))
8183
posting.value = true
8284
API.postJob(corporaStore.corpusId, job)
8385
.then((response) => {
@@ -93,8 +95,9 @@ const useJobs = defineStore("jobs", () => {
9395
}
9496

9597
function cancel(job: string): void {
98+
plausible.jobStopped(corpus.value, jobs.value.find((j) => j.tagger.id === job))
9699
posting.value = true
97-
API.cancelOrDeleteJob(corporaStore.corpusId, job, false)
100+
API.cancelJob(corporaStore.corpusId, job)
98101
.then((response) => {
99102
posting.value = false
100103
setProgress(job, response)
@@ -104,8 +107,9 @@ const useJobs = defineStore("jobs", () => {
104107

105108
// 'delete' is a reserved keyword
106109
function remove(job: string): void {
110+
plausible.jobDeleted(corpus.value, jobs.value.find((j) => j.tagger.id === job))
107111
posting.value = true
108-
API.cancelOrDeleteJob(corporaStore.corpusId, job, true)
112+
API.removeJob(corporaStore.corpusId, job)
109113
.then((response) => {
110114
posting.value = false
111115
setProgress(job, response)

client/src/stores/jobselection.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ import { useRouteQuery } from "@vueuse/router"
55

66
/** Stores the current job selection from the <select>. Used in Evaluation & Export. */
77
const useJobSelection = defineStore("jobSelection", () => {
8-
// Stores
98
const { jobs } = storeToRefs(stores.useJobs())
109
const { corpusId } = storeToRefs(stores.useCorpora())
1110

12-
// Fields
1311
const hypothesisId = useRouteQuery<string>("hypothesis")
1412
const referenceId = useRouteQuery<string>("reference")
13+
const hypothesisJob = computed<Job>(() => jobs.value.find((j: Job) => j.tagger.id === hypothesisId.value))
14+
const referenceJob = computed<Job>(() => jobs.value.find((j: Job) => j.tagger.id === referenceId.value))
1515

16-
// Selectable jobs are jobs that have at least one finished document,
17-
// or have source annotations (i.e. sourceLayer).
1816
const options = computed<SelectOption[]>((): SelectOption[] =>
1917
jobs.value
18+
// Selectable jobs have at least one finished document.
2019
.filter((j: Job) => j.progress.finished > 0)
2120
.map((j: Job) => ({ value: j.tagger.id, text: format(j) })),
2221
)
@@ -28,7 +27,7 @@ const useJobSelection = defineStore("jobSelection", () => {
2827

2928
watch(corpusId, () => { hypothesisId.value = undefined; referenceId.value = undefined })
3029

31-
return { hypothesisId, referenceId, options }
30+
return { hypothesisId, referenceId, hypothesisJob, referenceJob, options }
3231
})
3332

3433
export default useJobSelection

0 commit comments

Comments
 (0)