-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make pipeline version per Organism (#3534)
* Add stubs and TODOs * WIP (things start up fine it seems; but I think version isn't upgraded correctly yet) * make more changes * Update schema documentation based on migration changes * format * minor changes * Add initialization of the table for all organisms * Update schema documentation based on migration changes * version cannot be null anymore after previous change * progress in fixing tests * Update schema documentation based on migration changes * remove todos * 21 * format * Fixed some tests * Update schema documentation based on migration changes * Move table init to flyway init * Fixed one test * make mock bean primary -- one failing test remaining * fixed last test * adress review * Add some docs * Some logic changes (still needs testing) * Update schema documentation based on migration changes * docs * docs * foo * Add test * Add another test * Add some documentation * Update values.yaml to test non-identical prepro versions * Versions must be integers * improve documentation * clarify * Simplify table definitions * Make test description more descriptive and override linter error for that line * Add missing and * fix typo * Update schema documentation based on migration changes * left join -> join * Update schema documentation based on migration changes * maybe fix? * Fix constraint issue * ... * Disable PSQL reset * Bump ebola sudan version to 2 * Undo test changes --------- Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Cornelius Roemer <[email protected]>
- Loading branch information
1 parent
f582615
commit 7166188
Showing
18 changed files
with
433 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../src/main/kotlin/org/loculus/backend/service/submission/CurrentProcessingPipelineTable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,53 @@ | ||
package org.loculus.backend.service.submission | ||
|
||
import kotlinx.datetime.LocalDateTime | ||
import org.jetbrains.exposed.sql.Table | ||
import org.jetbrains.exposed.sql.andWhere | ||
import org.jetbrains.exposed.sql.batchInsert | ||
import org.jetbrains.exposed.sql.kotlin.datetime.datetime | ||
import org.jetbrains.exposed.sql.selectAll | ||
import org.jetbrains.exposed.sql.update | ||
|
||
const val CURRENT_PROCESSING_PIPELINE_TABLE_NAME = "current_processing_pipeline" | ||
|
||
object CurrentProcessingPipelineTable : Table(CURRENT_PROCESSING_PIPELINE_TABLE_NAME) { | ||
val organismColumn = varchar("organism", 255) | ||
val versionColumn = long("version") | ||
val startedUsingAtColumn = datetime("started_using_at") | ||
|
||
/** | ||
* Every organism needs to have a current pipeline version in the CurrentProcessingPipelineTable. | ||
* This function sets V1 for all given organisms, if no version is defined yet. | ||
*/ | ||
fun setV1ForOrganismsIfNotExist(organisms: Collection<String>, now: LocalDateTime) = | ||
CurrentProcessingPipelineTable.batchInsert(organisms, ignore = true) { organism -> | ||
this[organismColumn] = organism | ||
this[versionColumn] = 1 | ||
this[startedUsingAtColumn] = now | ||
} | ||
|
||
/** | ||
* Given a version that was found that is potentially newer than the current once, check if the currently stored | ||
* 'current' pipeline version for this organism is less than the one that was found? | ||
* If so, the pipeline needs to 'update' i.e. reprocess older entries. | ||
*/ | ||
fun pipelineNeedsUpdate(maybeNewerVersion: Long, organism: String) = CurrentProcessingPipelineTable | ||
.selectAll() | ||
.where { versionColumn less maybeNewerVersion } | ||
.andWhere { organismColumn eq organism } | ||
.empty() | ||
.not() | ||
|
||
/** | ||
* Set the pipeline version for the given organism to newVersion. | ||
*/ | ||
fun updatePipelineVersion(organism: String, newVersion: Long, startedUsingAt: LocalDateTime) = | ||
CurrentProcessingPipelineTable.update( | ||
where = { | ||
organismColumn eq organism | ||
}, | ||
) { | ||
it[versionColumn] = newVersion | ||
it[startedUsingAtColumn] = startedUsingAt | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.