Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add placeholder info for LS that OMS API does not have #37

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,25 @@ exports.get_OMS_lumisections = handleErrors(async (run_number) => {
let oms_lumisections = oms_lumisection_response.data.data;
// Deconstruct attributes inside oms_lumisections:
oms_lumisections = oms_lumisections.map(({ attributes }) => attributes);

// If lumisections are missing, we calculate an offset to offset the missing lumisections
// while processing them one by one.
let lumi_offset = 0;
// Create dummy lumisection objects to replace the missing ones. This is an array of arrays, each one
// being a subarray of missing lumisections. E.g. [[missing range 25-30], [missing range 54-60]]
let missing_lumi_objects_ranges = [];
// We add luminosity information
oms_lumisections = oms_lumisections.map(
({ recorded_lumi, delivered_lumi, lumisection_number }, index, oms_lumisections) => {
// Check that the index matches the LS number
if (index + 1 !== lumisection_number) {
// Check that the index matches the LS number (including the offset, in case of missing LS).
// If they're not matching, we update the missing lumisection ranges with dummy ones, and
// adjust the offset.
if (index + 1 + lumi_offset !== lumisection_number) {
console.warn(`Inconsistency in Run ${run_number}: Lumisection ${index} does not match OMS lumisection_number (${lumisection_number})`)
lumi_offset = lumisection_number - index - 1;
missing_lumi_objects_ranges.push(Array.from(new Array(lumisection_number - index - 1), (x, i) => { return { 'lumisection_number': i + index + 1 } }))
console.log(`Missing LS offset: ${lumi_offset}`)
}

// If any of them is null, then the per_lumi are all null
if (recorded_lumi === null || delivered_lumi === null) {
return {
Expand Down Expand Up @@ -97,7 +108,10 @@ exports.get_OMS_lumisections = handleErrors(async (run_number) => {
};
}
);

// If there are missing lumisections, insert them into the lumisection array.
missing_lumi_objects_ranges.forEach(range => {
oms_lumisections.splice(range[0].lumisection_number - 1, 0, ...range)
})
return oms_lumisections;
}, 'runregistry_backend/cron/saving_updating_runs_lumisections_utils.js # get_OMS_lumisections(): Error getting lumisection attributes for the run'
);
Expand Down