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

[O2B-1427] Store trigger configuration per runs #1848

Merged
merged 4 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions cxx-client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ add_library(BookkeepingApi SHARED
include/BookkeepingApi/TriggerCountersServiceClient.h
src/grpc/services/GrpcTriggerCountersServiceClient.h
src/grpc/services/GrpcTriggerCountersServiceClient.cxx
include/BookkeepingApi/RunServiceClient.h
src/grpc/services/GrpcRunServiceClient.h
src/grpc/services/GrpcRunServiceClient.cxx
)

target_include_directories(BookkeepingApi
Expand Down
6 changes: 5 additions & 1 deletion cxx-client/example/exampleSpecificServices.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char** argv)
// Test QC flag creation
auto dataPassQcFlagIds = client->qcFlag()->createForDataPass(
55,
"LHC22b_apass2",
"skimming",
"FT0",
{ { 2, 1565280000000, 1565287200000, "FT0/Check" },
{ .flagTypeId = 11, .origin = "FT0/task" } });
Expand Down Expand Up @@ -65,6 +65,10 @@ int main(int argc, char** argv)
std::cout << "Successfully created trigger counters" << std::endl;
client->triggerCounters()->createOrUpdateForRun(108, "CLASS-NAME", 1234, 10, 20, 30, 40, 50, 60);
std::cout << "Successfully updated trigger counters" << std::endl;

// Test run update
client->run()->setRawTriggerConfiguration(1, "A\nnew raw\nconfiguration");
std::cout << "Successfully updated run raw configuration" << std::endl;
} catch (std::runtime_error& error) {
std::cerr << "An error occurred: " << error.what() << std::endl;
exit(2);
Expand Down
5 changes: 5 additions & 0 deletions cxx-client/include/BookkeepingApi/BkpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "DplProcessExecutionClient.h"
#include "QcFlagServiceClient.h"
#include "TriggerCountersServiceClient.h"
#include "RunServiceClient.h"

namespace o2::bkp::api
{
Expand All @@ -35,7 +36,11 @@ class BkpClient
/// Returns the client for QcFlag service
virtual const std::unique_ptr<QcFlagServiceClient>& qcFlag() const = 0;

/// Returns the client for trigger counters
virtual const std::unique_ptr<TriggerCountersServiceClient>& triggerCounters() const = 0;

/// Returns the client for runs
virtual const std::unique_ptr<RunServiceClient>& run() const = 0;
};
} // namespace o2::bkp::api

Expand Down
29 changes: 29 additions & 0 deletions cxx-client/include/BookkeepingApi/RunServiceClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//

#ifndef CXX_CLIENT_BOOKKEEPINGAPI_RUNSERVICECLIENT_H
#define CXX_CLIENT_BOOKKEEPINGAPI_RUNSERVICECLIENT_H

#include <string>

namespace o2::bkp::api
{
class RunServiceClient
{
public:
virtual ~RunServiceClient() = default;

virtual void setRawTriggerConfiguration(int runNumber, std::string rawTriggerConfiguration) = 0;
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
};
} // namespace o2::bkp::api

#endif // CXX_CLIENT_BOOKKEEPINGAPI_RUNSERVICECLIENT_H
7 changes: 7 additions & 0 deletions cxx-client/src/grpc/GrpcBkpClient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "grpc/services/GrpcDplProcessExecutionClient.h"
#include "grpc/services/GrpcQcFlagServiceClient.h"
#include "grpc/services/GrpcTriggerCountersServiceClient.h"
#include "grpc/services/GrpcRunServiceClient.h"

using grpc::Channel;

Expand All @@ -34,6 +35,7 @@ using services::GrpcDplProcessExecutionClient;
using services::GrpcFlpServiceClient;
using services::GrpcQcFlagServiceClient;
using services::GrpcTriggerCountersServiceClient;
using services::GrpcRunServiceClient;

GrpcBkpClient::GrpcBkpClient(const string& uri)
{
Expand All @@ -42,6 +44,7 @@ GrpcBkpClient::GrpcBkpClient(const string& uri)
mDplProcessExecutionClient = make_unique<GrpcDplProcessExecutionClient>(channel);
mQcFlagClient = make_unique<GrpcQcFlagServiceClient>(channel);
mTriggerCountersClient = make_unique<GrpcTriggerCountersServiceClient>(channel);
mRunClient = make_unique<GrpcRunServiceClient>(channel);
}

const unique_ptr<FlpServiceClient>& GrpcBkpClient::flp() const
Expand All @@ -63,4 +66,8 @@ const unique_ptr<TriggerCountersServiceClient>& GrpcBkpClient::triggerCounters()
{
return mTriggerCountersClient;
}

const unique_ptr<RunServiceClient>& GrpcBkpClient::run() const {
return mRunClient;
}
} // namespace o2::bkp::api::grpc
3 changes: 3 additions & 0 deletions cxx-client/src/grpc/GrpcBkpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ class GrpcBkpClient : public o2::bkp::api::BkpClient

const std::unique_ptr<TriggerCountersServiceClient>& triggerCounters() const override;

const std::unique_ptr<RunServiceClient>& run() const override;

private:
std::unique_ptr<::o2::bkp::api::FlpServiceClient> mFlpClient;
std::unique_ptr<::o2::bkp::api::DplProcessExecutionClient> mDplProcessExecutionClient;
std::unique_ptr<::o2::bkp::api::QcFlagServiceClient> mQcFlagClient;
std::unique_ptr<::o2::bkp::api::TriggerCountersServiceClient> mTriggerCountersClient;
std::unique_ptr<::o2::bkp::api::RunServiceClient> mRunClient;
};
} // namespace o2::bkp::api::grpc

Expand Down
3 changes: 0 additions & 3 deletions cxx-client/src/grpc/services/GrpcQcFlagServiceClient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//
// Created by mboulais on 27/05/24.
//

#include "GrpcQcFlagServiceClient.h"

Expand Down
41 changes: 41 additions & 0 deletions cxx-client/src/grpc/services/GrpcRunServiceClient.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//

#include "GrpcRunServiceClient.h"

#include <memory>

using grpc::ClientContext;

using o2::bookkeeping::RunUpdateRequest;
using o2::bookkeeping::Run;

namespace o2::bkp::api::grpc::services
{
GrpcRunServiceClient::GrpcRunServiceClient(const std::shared_ptr<::grpc::ChannelInterface>& channel)
{
mStub = o2::bookkeeping::RunService::NewStub(channel);
}
void GrpcRunServiceClient::setRawTriggerConfiguration(int runNumber, std::string rawTriggerConfiguration) {
ClientContext context{};
RunUpdateRequest updateRequest{};
Run updatedRun;

updateRequest.set_runnumber(runNumber);
updateRequest.set_triggerrawconfiguration(rawTriggerConfiguration);

auto status = mStub->Update(&context, updateRequest, &updatedRun);
if (!status.ok()) {
throw std::runtime_error(status.error_message());
}
}
} // namespace o2::bkp::api::grpc::services
38 changes: 38 additions & 0 deletions cxx-client/src/grpc/services/GrpcRunServiceClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//

#ifndef CXX_CLIENT_BOOKKEEPINGAPI_GRPCRUNERVICECLIENT_H
#define CXX_CLIENT_BOOKKEEPINGAPI_GRPCRUNERVICECLIENT_H

#include "run.grpc.pb.h"
#include "BookkeepingApi/RunServiceClient.h"

#include <memory>

namespace o2::bkp::api::grpc::services
{

class GrpcRunServiceClient : public RunServiceClient
{
public:
explicit GrpcRunServiceClient(const std::shared_ptr<::grpc::ChannelInterface>& channel);
~GrpcRunServiceClient() override = default;

void setRawTriggerConfiguration(int runNumber, std::string rawTriggerConfiguration) override;

private:
std::unique_ptr<o2::bookkeeping::RunService::Stub> mStub;
};

} // namespace o2::bkp::api::grpc::services

#endif // CXX_CLIENT_BOOKKEEPINGAPI_GRPCRUNERVICECLIENT_H
3 changes: 3 additions & 0 deletions lib/database/adapters/RunAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class RunAdapter {
crossSection,
triggerEfficiency,
triggerAcceptance,
triggerRawConfiguration,
phaseShiftAtStartBeam1,
phaseShiftAtStartBeam2,
phaseShiftAtEndBeam1,
Expand Down Expand Up @@ -230,6 +231,7 @@ class RunAdapter {
crossSection,
triggerEfficiency,
triggerAcceptance,
triggerRawConfiguration,
phaseShiftAtStartBeam1,
phaseShiftAtStartBeam2,
phaseShiftAtEndBeam1,
Expand Down Expand Up @@ -347,6 +349,7 @@ class RunAdapter {
crossSection: entityObject.crossSection,
triggerEfficiency: entityObject.triggerEfficiency,
triggerAcceptance: entityObject.triggerAcceptance,
triggerRawConfiguration: entityObject.triggerRawConfiguration,
phaseShiftAtStartBeam1: entityObject.phaseShiftAtStartBeam1,
phaseShiftAtStartBeam2: entityObject.phaseShiftAtStartBeam2,
phaseShiftAtEndBeam1: entityObject.phaseShiftAtEndBeam1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => await queryInterface.addColumn(
'runs',
'trigger_raw_configuration',
{
type: Sequelize.DataTypes.TEXT,
allowNull: true,
default: null,
after: 'trigger_acceptance',
},
),

down: async (queryInterface) => await queryInterface.removeColumn('runs', 'trigger_raw_configuration'),
};
5 changes: 5 additions & 0 deletions lib/database/models/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ module.exports = (sequelize) => {
allowNull: true,
default: null,
},
triggerRawConfiguration: {
type: Sequelize.TEXT,
allowNull: true,
default: null,
},
phaseShiftAtStartBeam1: {
type: Sequelize.DECIMAL,
allowNull: true,
Expand Down
1 change: 1 addition & 0 deletions lib/database/models/typedefs/SequelizeRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
* @property {number|null} crossSection
* @property {number|null} triggerEfficiency
* @property {number|null} triggerAcceptance
* @property {string|null} triggerRawConfiguration
* @property {number|null} phaseShiftAtEndBeam1
* @property {number|null} phaseShiftAtEndBeam2
* @property {number|null} phaseShiftAtStartBeam1
Expand Down
1 change: 1 addition & 0 deletions lib/database/seeders/20200713103855-runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module.exports = {
cross_section: 1.23,
trigger_efficiency: 2.34,
trigger_acceptance: 3.45,
trigger_raw_configuration: 'Raw\nTrigger\nConfiguration',
phase_shift_at_start_beam1: 4.56,
phase_shift_at_start_beam2: -1.23,
phase_shift_at_end_beam1: 5.67,
Expand Down
1 change: 1 addition & 0 deletions lib/domain/dtos/UpdateRunByRunNumberDto.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const BodyDto = Joi.object({
crossSection: Joi.number().optional(),
triggerEfficiency: Joi.number().optional(),
triggerAcceptance: Joi.number().optional(),
triggerRawConfiguration: Joi.string().optional(),
phaseShiftAtStart: PhaseShiftDto,
phaseShiftAtEnd: PhaseShiftDto,
});
Expand Down
1 change: 1 addition & 0 deletions lib/domain/entities/Run.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
* @property {number|null} crossSection
* @property {number|null} triggerEfficiency
* @property {number|null} triggerAcceptance
* @property {string|null} triggerRawConfiguration
* @property {number|null} phaseShiftAtStartBeam1
* @property {number|null} phaseShiftAtStartBeam2
* @property {number|null} phaseShiftAtEndBeam1
Expand Down
1 change: 1 addition & 0 deletions lib/public/views/Runs/Details/RunDetailsModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const RUN_DETAILS_PANELS_KEYS = {
FLPS: 'flps',
DPL_PROCESSES: 'dpl-processes',
TRIGGER_COUNTERS: 'trigger-counters',
TRIGGER_CONFIGURATION: 'trigger-configuration',
};

/**
Expand Down
16 changes: 16 additions & 0 deletions lib/public/views/Runs/Details/runDetailsComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
onclick: () => router.go('?page=run-overview'),
}, 'Return to Overview'),
]),

/**
* Run details display
* @param {Run} run run to be displayed
* @return {Component} the run details
*/
Success: (run) => {
if (!router.params.runNumber) {
const targetPanel = router.params.panel ?? runDetailsModel.tabbedPanelModel.currentPanelKey ?? 'logs';
Expand Down Expand Up @@ -510,6 +516,7 @@
[RUN_DETAILS_PANELS_KEYS.FLPS]: 'FLP statistics',
[RUN_DETAILS_PANELS_KEYS.DPL_PROCESSES]: 'QC/PDP tasks',
[RUN_DETAILS_PANELS_KEYS.TRIGGER_COUNTERS]: 'Trigger counters',
[RUN_DETAILS_PANELS_KEYS.TRIGGER_CONFIGURATION]: 'Trigger Config',
},
{
[RUN_DETAILS_PANELS_KEYS.LOGS]: (dataLogs) => table(dataLogs, logsActiveColumns, null, { profile: 'embeded' }),
Expand Down Expand Up @@ -593,6 +600,15 @@
},
{ classes: 'table-sm' },
),
[RUN_DETAILS_PANELS_KEYS.TRIGGER_CONFIGURATION]: () => h(

Check warning on line 603 in lib/public/views/Runs/Details/runDetailsComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Details/runDetailsComponent.js#L603

Added line #L603 was not covered by tests
PanelComponent,
h(
'.p2',
run.triggerRawConfiguration
.split('\n')
.map((row) => h('', row)),

Check warning on line 609 in lib/public/views/Runs/Details/runDetailsComponent.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Details/runDetailsComponent.js#L609

Added line #L609 was not covered by tests
),
),
},
)),
];
Expand Down
1 change: 1 addition & 0 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ message Run {
optional int64 timeTrgStart = 21;
// Trigger value
optional string triggerValue = 22;
optional string triggerRawConfiguration = 32;
// The full name or file location of the odcTopology
optional string odcTopologyFullName = 23;
optional bool ddFlp = 24;
Expand Down
2 changes: 2 additions & 0 deletions proto/run.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ message RunUpdateRequest {
optional int64 timeTrgStart = 5;
optional int64 timeTrgEnd = 6;
optional string triggerValue = 7;
optional string triggerRawConfiguration = 19;
optional string pdpConfigOption = 8;
optional string pdpTopologyDescriptionLibraryFile = 9;
optional string tfbDdMode = 10;
Expand All @@ -64,6 +65,7 @@ message RunUpdateRequest {
// Optional users that stopped or started the run (can also be undefined)
optional User userO2Start = 17;
optional User userO2Stop = 18;
// 19 is trigger raw configuration
}

// Enums
Expand Down
2 changes: 2 additions & 0 deletions test/api/runs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ module.exports = () => {
crossSection: 0.1,
triggerEfficiency: 0.2,
triggerAcceptance: 0.3,
triggerRawConfiguration: 'Trigger\nRaw\nConfiguration',
phaseShiftAtStart: {
beam1: 0.4,
beam2: -0.2,
Expand Down Expand Up @@ -1258,6 +1259,7 @@ module.exports = () => {
expect(data.nTfOrbits).to.equal(BIG_INT_NUMBER);
expect(data.triggerEfficiency).to.equal(0.2);
expect(data.triggerAcceptance).to.equal(0.3);
expect(data.triggerRawConfiguration).to.equal('Trigger\nRaw\nConfiguration');
expect(data.phaseShiftAtStartBeam1).to.equal(0.4);
expect(data.phaseShiftAtStartBeam2).to.equal(-0.2);
expect(data.phaseShiftAtEndBeam1).to.equal(0.5);
Expand Down
Loading