Allow forcing QCs.

QCs may be re-run for specific sequences or for a whole
project by defining an environment variable, as follows:

For an entire project:

* DOUGAL_FORCE_QC="project-id"

For specific sequences:

* DOUGAL_FORCE_QC="project-id sequence1 sequence2 … sequenceN"
This commit is contained in:
D. Berge
2022-03-17 20:10:26 +01:00
parent 49b7747ded
commit 913606e7f1

View File

@@ -10,6 +10,34 @@ const { projectHash, sequenceHash } = require('./last-modified');
const { runShotsQC, saveShotsQC } = require('./shots');
const { runSequenceQCs, saveSequenceQCs } = require('./sequences');
/** Return true if the user has requested force running
* a QC that would normally not be scheduled to be run.
*
* This is done via the DOUGAL_FORCE_QC environment
* variable. The format is as follows:
*
* DOUGAL_FORCE_QC="project-id [sequence1 sequence2 … sequenceN]"
*
* A value of "project-id" re-runs QCs for all sequences of that
* project, whereas specifying sequences to be run affects only
* those sequences.
*/
function forceQC (projectId, sequenceNumber) {
if (process.env.DOUGAL_FORCE_QC) {
const [force_projectID, ...force_sequences ] = process.env.DOUGAL_FORCE_QC.split(/\s+/);
if (projectId == force_projectID) {
if (!sequenceNumber) {
return true;
} else if (!force_sequences.length) {
return true;
} else {
return force_sequences.map(i => Number(i)).some(i => i == sequenceNumber);
}
}
}
return false;
}
async function getProjectQCConfig (projectId) {
console.log("getProjectQCConfig");
const qcConfig = await configuration.get(projectId, "qc");
@@ -41,7 +69,7 @@ async function main () {
console.log("projectHash", projectHash);
console.log("lastQCHash", lastQCHash);
if (currentQCHash != lastQCHash) {
if (currentQCHash != lastQCHash || forceQC(projectId)) {
console.log("currentQCHash != lastQCHash", projectId, currentQCHash, lastQCHash);
// Fetch definitions and parameters
@@ -64,7 +92,7 @@ async function main () {
console.log("sequenceCurrentHash", sequenceCurrentHash);
console.log("sequenceLastQCHash", sequenceLastQCHash);
if (sequenceCurrentHash != sequenceLastQCHash) {
if (sequenceCurrentHash != sequenceLastQCHash || forceQC(projectId, sequenceNumber)) {
const results = await runShotsQC(projectId, sequenceNumber, shotQCs, parameters);