Skip to content

Commit

Permalink
Merge branch 'strix' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Sep 18, 2023
2 parents a50407b + 5c2ebee commit 2edc47a
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 66 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ BASE=/mink/
VITE_BACKEND_URL=https://ws.spraakbanken.gu.se/ws/mink/
VITE_AUTH_URL=https://sp.spraakbanken.gu.se/auth/
VITE_KORP_URL=https://spraakbanken.gu.se/korp/
VITE_STRIX_URL=https://spraakbanken.gu.se/strix/
9 changes: 8 additions & 1 deletion src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,20 @@ class MinkApi {
return response.data;
}

async installCorpus(corpusId) {
async installKorp(corpusId) {
const response = await this.axios.put("install-korp", null, {
params: { corpus_id: corpusId },
});
return response.data;
}

async installStrix(corpusId) {
const response = await this.axios.put("install-strix", null, {
params: { corpus_id: corpusId },
});
return response.data;
}

async adminModeOn() {
const response = await this.axios.post("admin-mode-on");
return response.data;
Expand Down
14 changes: 11 additions & 3 deletions src/api/backend.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,16 @@ export default function useMinkBackend() {
const runJob = (corpusId) =>
spin(api.runSparv(corpusId), t("job.starting"), `corpus/${corpusId}/job`);

const install = (corpusId) =>
const installKorp = (corpusId) =>
spin(
api.installCorpus(corpusId),
api.installKorp(corpusId),
t("job.installing"),
`corpus/${corpusId}/job`
);

const installStrix = (corpusId) =>
spin(
api.installStrix(corpusId),
t("job.installing"),
`corpus/${corpusId}/job`
);
Expand Down Expand Up @@ -134,7 +141,8 @@ export default function useMinkBackend() {
loadJob,
loadJobs,
runJob,
install,
installKorp,
installStrix,
abortJob,
loadExports,
downloadExports,
Expand Down
1 change: 1 addition & 0 deletions src/api/corpusConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export async function makeConfig(id, options) {
"<text>:readability.ovix",
"<text>:readability.nk",
"<text>:misc.source",
"<text>:misc.id as _id",
],
};

Expand Down
18 changes: 12 additions & 6 deletions src/corpus/corpusState.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useSources from "./sources/sources.composable";
export function useCorpusState(corpusId) {
const { sources } = useSources(corpusId);
const { config } = useConfig(corpusId);
const { sparvStatus, korpStatus } = useJob(corpusId);
const { sparvStatus, korpStatus, strixStatus } = useJob(corpusId);
const { t } = useI18n();

const corpusState = computed(() => {
Expand All @@ -19,14 +19,20 @@ export function useCorpusState(corpusId) {

if (sparvStatus.value.isReady) return CorpusState.READY;
if (sparvStatus.value.isError) return CorpusState.FAILED;
if (korpStatus.value.isRunning) return CorpusState.RUNNING_INSTALL;

// TODO Revise the CorpusState concept. The workflow can now branch in two. Ifs below questionable.
if (korpStatus.value.isRunning || strixStatus.value.isRunning)
return CorpusState.RUNNING_INSTALL;
if (sparvStatus.value.isRunning) return CorpusState.RUNNING;
if (korpStatus.value.isReady) return CorpusState.DONE;
if (korpStatus.value.isError) return CorpusState.FAILED_INSTALL;
if (korpStatus.value.isDone) return CorpusState.DONE_INSTALL;
if (korpStatus.value.isReady && strixStatus.value.isReady)
return CorpusState.DONE;
if (korpStatus.value.isError || strixStatus.value.isError)
return CorpusState.FAILED_INSTALL;
if (korpStatus.value.isDone || strixStatus.value.isDone)
return CorpusState.DONE_INSTALL;

throw RangeError(
`Invalid state, sparv=${sparvStatus.value}, korp=${korpStatus.value}`
`Invalid state, sparv=${sparvStatus.value.state}, korp=${korpStatus.value.state}, strix=${strixStatus.value.state}`
);
});

Expand Down
124 changes: 96 additions & 28 deletions src/corpus/exports/Exports.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,92 @@
class="grid grid-cols-2 gap-4"
>
<div>
<h3 class="text-lg uppercase">Korp</h3>
<p>{{ $t("exports.korp.help") }}</p>
<div class="flex flex-wrap gap-2 mb-1">
<ActionButton
:variant="canInstall ? 'primary' : null"
:disabled="!canInstall"
@click="canInstall ? korpInstall() : null"
>
{{
!korpStatus.isDone
? $t("exports.korp.install")
: $t("exports.korp.reinstall")
}}
</ActionButton>

<a
v-if="korpStatus.isDone"
:href="`${korpUrl}?mode=mink#?corpus=${corpusId}`"
target="_blank"
>
<ActionButton variant="primary">
{{ $t("exports.korp.view") }}
<h3 class="text-lg uppercase">
{{ $t("tools") }}
</h3>
<p>{{ $t("exports.tools.help") }}</p>

<div class="flex gap-2 my-2 justify-between items-baseline">
<div>
<h3 class="text-lg uppercase">Korp</h3>
<p class="text-sm text-gray-500 dark:text-gray-400">
{{ $t("exports.tools.help.korp") }}
<a :href="$t('exports.tools.help.korp.manual.url')">
<ActionButton class="slim mute">
{{ $t("exports.tools.help.korp.manual.text") }}
</ActionButton>
</a>
</p>
</div>

<div class="flex flex-wrap gap-2 justify-end">
<ActionButton
:variant="canInstall && !korpStatus.isDone ? 'primary' : null"
:disabled="!canInstall"
@click="canInstall ? korpInstall() : null"
class="whitespace-nowrap"
>
{{
$t(
!korpStatus.isDone
? "exports.tools.install"
: "exports.tools.reinstall"
)
}}
</ActionButton>

<a
v-if="korpStatus.isDone"
:href="`${korpUrl}?mode=mink#?corpus=${corpusId}`"
target="_blank"
>
<ActionButton variant="primary">
{{ $t("exports.tools.view") }}
</ActionButton>
</a>
<ActionButton v-else disabled>
{{ $t("exports.tools.view") }}
</ActionButton>
</a>
<ActionButton v-else disabled>
{{ $t("exports.korp.view") }}
</ActionButton>
</div>
</div>

<div class="flex gap-2 my-2 justify-between items-baseline">
<div>
<h3 class="text-lg uppercase">Strix</h3>
<p class="text-sm text-gray-500 dark:text-gray-400">
{{ $t("exports.tools.help.strix") }}
</p>
</div>

<div class="flex flex-wrap gap-2 justify-end">
<ActionButton
:variant="canInstall && !strixStatus.isDone ? 'primary' : null"
:disabled="!canInstall"
@click="canInstall ? strixInstall() : null"
class="whitespace-nowrap"
>
{{
$t(
!strixStatus.isDone
? "exports.tools.install"
: "exports.tools.reinstall"
)
}}
</ActionButton>

<a
v-if="strixStatus.isDone"
:href="`${strixUrl}?filters=corpus_id:${corpusId}&modeSelected=mink`"
target="_blank"
>
<ActionButton variant="primary">
{{ $t("exports.tools.view") }}
</ActionButton>
</a>
<ActionButton v-else disabled>
{{ $t("exports.tools.view") }}
</ActionButton>
</div>
</div>
</div>

Expand Down Expand Up @@ -76,21 +135,30 @@ const corpusId = useCorpusIdParam();
const { exports, loadExports, downloadResult, getDownloadFilename } =
useExports(corpusId);
const { isDone } = useCorpusState(corpusId);
const { install, sparvStatus, korpStatus } = useJob(corpusId);
const { installKorp, installStrix, sparvStatus, korpStatus, strixStatus } =
useJob(corpusId);
const korpUrl = ensureTrailingSlash(import.meta.env.VITE_KORP_URL);
const strixUrl = ensureTrailingSlash(import.meta.env.VITE_STRIX_URL);
const isInstallPending = ref(false);
const canInstall = computed(
() =>
sparvStatus.value.isDone &&
!korpStatus.value.isRunning &&
!strixStatus.value.isRunning &&
!isInstallPending.value
);
async function korpInstall() {
isInstallPending.value = true;
await install();
await installKorp();
isInstallPending.value = false;
}
async function strixInstall() {
isInstallPending.value = true;
await installStrix();
isInstallPending.value = false;
}
Expand Down
34 changes: 22 additions & 12 deletions src/corpus/job/job.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ export default function useJob(corpusId) {
corpus.value.status = await mink.runJob(corpusId).catch(alertError);
}

async function install() {
corpus.value.status = await mink.install(corpusId).catch(alertError);
async function installKorp() {
corpus.value.status = await mink.installKorp(corpusId).catch(alertError);
}

async function installStrix() {
corpus.value.status = await mink.installStrix(corpusId).catch(alertError);
}

async function abortJob() {
Expand All @@ -80,18 +84,22 @@ export default function useJob(corpusId) {
const korpStatus = computed(
() => new JobStatus(jobStatus.value?.job_status?.korp)
);
const currentStatus = computed(
() =>
({
sparv: sparvStatus.value,
korp: korpStatus.value,
}[jobStatus.value.current_process])
const strixStatus = computed(
() => new JobStatus(jobStatus.value?.job_status?.strix)
);
const currentStatus = computed(() => {
const process = jobStatus.value.current_process;
return new JobStatus(jobStatus.value?.job_status?.[process]);
});

// "Running" if any job is waiting/running.
const isJobRunning = computed(
() => sparvStatus.value.isRunning || korpStatus.value.isRunning
);
const isJobRunning = computed(() => {
const statuses = jobStatus.value?.job_status;
if (!statuses) return false;
return Object.keys(statuses).some(
(process) => new JobStatus(statuses[process]).isRunning
);
});

// "Done" if Sparv is done, and Korp is not running/error.
const isJobDone = computed(
Expand All @@ -114,10 +122,12 @@ export default function useJob(corpusId) {
loadJob,
runJob,
abortJob,
install,
installKorp,
installStrix,
jobStatus,
sparvStatus,
korpStatus,
strixStatus,
currentStatus,
isJobRunning,
isJobDone,
Expand Down
22 changes: 14 additions & 8 deletions src/i18n/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ home.features.sparv.title: Configurable language technology analysis
home.features.sparv.body: Your language data are analyzed by our language technology platform {sparv} according to your settings.
home.features.upload.title: Deposit your text
home.features.upload.body: Upload your word-processor documents, PDFs, plain text files or XML data. When using XML, the output of the analyses is added while keeping the input structure intact.
home.features.explore.title: Explore in Korp
home.features.explore.body: Export the resulting data, for search and statistical analysis, to {korp} and (soon) {strix}.
home.features.explore.title: Explore in Korp and Strix
home.features.explore.body: Export the resulting data, for search and statistical analysis, to {korp} and {strix}.
home.features.share.title: Share and collaborate
home.features.share.body: Invite fellow researchers to view your data in our research tools, protected by login. If you want to share your data with the research community, contact us to discuss publication.
home.features.share.upcoming: These features are scheduled for upcoming versions of Mink.
Expand Down Expand Up @@ -41,9 +41,9 @@ corpus.state.help.needing_config: This corpus needs you to change some settings
corpus.state.help.needing_meta: The corpus needs a name before it can be processed.
corpus.state.help.ready: Ready for annotation. You can also supply more source texts or edit the configuration.
corpus.state.help.running: Annotation is running in the background. Feel free to close the website, have some coffee and check back later!
corpus.state.help.done: Annotation done! You can download the results or install it to Korp.
corpus.state.help.done: Annotation done! You can download the results or install it to Korp or Strix.
corpus.state.help.running_install: Installation is running in the background. Feel free to close the website, have some coffee and check back later!
corpus.state.help.done_install: Successfully installed in Korp!
corpus.state.help.done_install: Successfully installed!
corpus.state.help.failed: An error occurred while processing your data. If you need help, please contact sb-info{'@'}svenska.gu.se
corpus.state.help.failed_install: An error occurred while installing your corpus. If you need help, please contact sb-info{'@'}svenska.gu.se
config.metadata.help: Metadata is information about the data, meant for assessment by interested users (if you release the data), and for categorization in data repositories.
Expand All @@ -64,6 +64,7 @@ job.last_run_ended: Last run ended
job.time_taken: Time taken
job.process.sparv: Annotation
job.process.korp: Installation to Korp
job.process.strix: Installation to Strix
source.deleting: Deleting text
source.downloading: Downloading text
source.downloading_plain: Downloading extracted text
Expand All @@ -79,11 +80,16 @@ source.upload.drop.empty: No file was dropped. Drag-and-drop may not be supporte
source.list.loading: Listing source texts
source.content: Content
jwt.refreshing: Refreshing account
tools: Explore
exports.loading: Listing result files
exports.korp.install: Add to Korp
exports.korp.reinstall: Re-add to Korp
exports.korp.view: View in Korp
exports.korp.help: Use this data in Språkbanken's corpus search tool. Your data will be available to you only, in a special Mink mode.
exports.tools.help: Use this data in Språkbanken's corpus tools. Your data will be available to you only, in a special Mink mode.
exports.tools.help.korp: Korp offers concordance search, detailed queries, frequency statistics and more.
exports.tools.help.korp.manual.url: https://spraakbanken.gu.se/en/tools/korp/user-manual
exports.tools.help.korp.manual.text: User manual
exports.tools.help.strix: In Strix, the enriched texts can be examined in full.
exports.tools.install: Install
exports.tools.reinstall: Reinstall
exports.tools.view: View
exports.download.help: Results can be downloaded as machine-readable files for processing in scripts or other specialized software.
exports.downloading: Downloading results
exports.help: The annotation process yields export files for each input file. You can download each single export file or all of them in a bundle. The exact structure of the files depends on the input files as well as the configuration. They are stored on the server indefinitely, but re-running the annotation will replace them with new ones.
Expand Down
Loading

0 comments on commit 2edc47a

Please sign in to comment.