CJVT updates August and September 2026

This commit is contained in:
Luka Romih
2026-10-01 00:49:26 +02:00
parent fd02e25719
commit 83f73aeb58
135 changed files with 6146 additions and 1970 deletions
+67 -39
View File
@@ -14,6 +14,9 @@ const {
} = require('./helpers/extraction')
const { extractionApiOrigin } = require('../config/keys')
// Upper limit for each concordancer status-polling loop in Extraction.processOwn.
const CONCORDANCER_POLL_TIMEOUT_SECONDS = 5 * 60
const Extraction = {}
// Fetch all extractions for a specific user.
@@ -434,19 +437,12 @@ Extraction.processOwn = async function (extractionId, extractionName) {
])
// Wait for creation of corpus.
while (true) {
console.log('SLEEP FOR 5 SECS')
await sleep(5)
const {
data: { status }
} = await axios.get(
`http://concordancer:5000/dashboard/corpus/${corpusId}`
)
if (status === 'Creating') continue
if (status === 'Active') break
throw Error('Error creating concorcander corpus')
}
await pollConcordancerStatus({
url: `http://concordancer:5000/dashboard/corpus/${corpusId}`,
inProgressStatuses: ['Creating'],
label: `corpus ${corpusId}`,
errorMessage: 'Error creating concorcander corpus'
})
console.log('CORPUS CREATED')
const inProgressStatusList = [
@@ -471,19 +467,12 @@ Extraction.processOwn = async function (extractionId, extractionName) {
)
// Wait for text ingestion.
while (true) {
console.log('SLEEP FOR 5 SECS')
await sleep(5)
const {
data: { status }
} = await axios.get(
`http://concordancer:5000/dashboard/corpus/${corpusId}/text/${textId}`
)
if (inProgressStatusList.includes(status)) continue
if (status === 'Active') break
throw Error('Error importing concorcander text')
}
await pollConcordancerStatus({
url: `http://concordancer:5000/dashboard/corpus/${corpusId}/text/${textId}`,
inProgressStatuses: inProgressStatusList,
label: `text ${textId}`,
errorMessage: 'Error importing concorcander text'
})
console.log('TEXT ADDED')
}
@@ -501,19 +490,12 @@ Extraction.processOwn = async function (extractionId, extractionName) {
)
// Wait for term list ingestion.
while (true) {
console.log('SLEEP FOR 5 SECS')
await sleep(5)
const {
data: { status }
} = await axios.get(
`http://concordancer:5000/dashboard/corpus/${corpusId}/termList/${termListId}`
)
if (inProgressStatusList.includes(status)) continue
if (status === 'Active') break
throw Error('Error importing concorcander text')
}
await pollConcordancerStatus({
url: `http://concordancer:5000/dashboard/corpus/${corpusId}/termList/${termListId}`,
inProgressStatuses: inProgressStatusList,
label: `termList ${termListId}`,
errorMessage: 'Error importing concorcander term list'
})
console.log('TERMS ADDED')
await db.query(
@@ -654,6 +636,52 @@ function sleep(seconds) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000))
}
// Polls a concordancer status endpoint every 5 seconds until it reports
// 'Active', up to CONCORDANCER_POLL_TIMEOUT_SECONDS in total. The
// concordancer can return HTTP 500 (XForbiddenException, thrown by its
// CurrentContextInitializationDecorator) from these GET endpoints while
// the entity isn't 'Active' yet, which is indistinguishable from "still
// in progress", so a 500 is treated as such and the loop keeps retrying
// until either the entity becomes 'Active' or the upper time limit is
// reached.
async function pollConcordancerStatus({
url,
inProgressStatuses,
label,
errorMessage
}) {
const startTime = Date.now()
let attempt = 0
/* eslint-disable no-console */
while (true) {
const elapsedSeconds = Math.floor((Date.now() - startTime) / 1000)
const remainingSeconds = CONCORDANCER_POLL_TIMEOUT_SECONDS - elapsedSeconds
if (remainingSeconds <= 0) {
throw Error(
`Timed out polling ${label} after ${attempt} attempt(s) and ${elapsedSeconds}s (limit: ${CONCORDANCER_POLL_TIMEOUT_SECONDS}s)`
)
}
attempt++
console.log(
`Polling ${label}: attempt ${attempt}, ${remainingSeconds}s left until timeout`
)
await sleep(5)
let status
try {
;({
data: { status }
} = await axios.get(url))
} catch (error) {
if (error.response?.status === 500) continue
throw error
}
if (inProgressStatuses.includes(status)) continue
if (status === 'Active') return
throw Error(errorMessage)
}
/* eslint-enable no-console */
}
function logExtractionError(error, extractionId, jobType, filename) {
// eslint-disable-next-line no-console
console.error(