Skip to content

Commit 5b25acc

Browse files
authored
[QC-988] Bk insert process (#1856)
* [QC-988] Register the task in the BK at start of run * [QC-988] * format * add missing stuff PP * remove unused include * format * fix
1 parent 0db0521 commit 5b25acc

7 files changed

Lines changed: 45 additions & 0 deletions

File tree

Framework/include/QualityControl/Bookkeeping.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Bookkeeping
3838

3939
void init(const std::string& url);
4040
void populateActivity(Activity& activity, size_t runNumber);
41+
void registerProcess(int runNumber, const std::string& name, const std::string& detector, bookkeeping::DplProcessType type, const std::string& args);
4142

4243
private:
4344
Bookkeeping() = default;

Framework/include/QualityControl/PostProcessingRunnerConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct PostProcessingRunnerConfig {
3131
std::string detectorName;
3232
std::unordered_map<std::string, std::string> database;
3333
std::string consulUrl{};
34+
std::string bookkeepingUrl{};
3435
core::DiscardFileParameters infologgerDiscardParameters;
3536
double periodSeconds = 10.0;
3637
std::string configKeyValues; // These are for ConfigurableParams, not for override-values!

Framework/src/AggregatorRunner.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ void AggregatorRunner::start(ServiceRegistryRef services)
413413
QcInfoLogger::setRun(mActivity.mId);
414414
QcInfoLogger::setPartition(mActivity.mPartitionName);
415415
ILOG(Info, Support) << "Starting run " << mActivity.mId << ENDM;
416+
417+
// register ourselves to the BK
418+
if (gSystem->Getenv("O2_QC_REGISTER_IN_BK")) { // until we are sure it works, we have to turn it on
419+
Bookkeeping::getInstance().registerProcess(mActivity.mId, mDeviceName, AggregatorRunner::getDetectorName(mAggregators), bookkeeping::DPL_PROCESS_TYPE_QC_AGGREGATOR, "");
420+
}
416421
}
417422

418423
void AggregatorRunner::stop()

Framework/src/Bookkeeping.cxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "QualityControl/Activity.h"
2020
#include "BookkeepingApi/BkpProtoClientFactory.h"
2121
#include "BookkeepingApi/BkpProtoClient.h"
22+
#include <unistd.h>
2223

2324
using namespace o2::bkp::api::proto;
2425

@@ -76,4 +77,22 @@ void Bookkeeping::populateActivity(Activity& activity, size_t runNumber)
7677
ILOG(Warning, Support) << "Error retrieving run info from Bookkeeping: " << error.what() << ENDM;
7778
}
7879
}
80+
81+
std::string getHostName()
82+
{
83+
char hostname[256];
84+
if (gethostname(hostname, sizeof(hostname)) == 0) {
85+
return { hostname };
86+
} else {
87+
return "";
88+
}
89+
}
90+
91+
void Bookkeeping::registerProcess(int runNumber, const std::string& name, const std::string& detector, bookkeeping::DplProcessType type, const std::string& args)
92+
{
93+
if (!mInitialized) {
94+
return;
95+
}
96+
mClient->dplProcessExecution()->registerProcessExecution(runNumber, type, getHostName(), name, args, detector);
97+
}
7998
} // namespace o2::quality_control::core

Framework/src/CheckRunner.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ void CheckRunner::start(ServiceRegistryRef services)
527527
for (auto& [checkName, check] : mChecks) {
528528
check.setActivity(mActivity);
529529
}
530+
531+
// register ourselves to the BK
532+
if (gSystem->Getenv("O2_QC_REGISTER_IN_BK")) { // until we are sure it works, we have to turn it on
533+
Bookkeeping::getInstance().registerProcess(mActivity->mId, mDeviceName, mDetectorName, bookkeeping::DPL_PROCESS_TYPE_QC_CHECKER, "");
534+
}
530535
}
531536

532537
void CheckRunner::stop()

Framework/src/PostProcessingRunner.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
#include "QualityControl/runnerUtils.h"
2626
#include "QualityControl/ConfigParamGlo.h"
2727
#include "QualityControl/MonitorObjectCollection.h"
28+
#include "QualityControl/Bookkeeping.h"
2829

2930
#include <utility>
3031
#include <Framework/DataAllocator.h>
3132
#include <Framework/DataTakingContext.h>
3233
#include <CommonUtils/ConfigurableParam.h>
34+
#include <TSystem.h>
3335

3436
using namespace o2::quality_control::core;
3537
using namespace o2::quality_control::repository;
@@ -89,6 +91,7 @@ void PostProcessingRunner::init(const PostProcessingRunnerConfig& runnerConfig,
8991
if (mPublicationCallback == nullptr) {
9092
mPublicationCallback = publishToRepository(*mDatabase);
9193
}
94+
Bookkeeping::getInstance().init(runnerConfig.bookkeepingUrl);
9295

9396
// setup user's task
9497
ILOG(Debug, Devel) << "Creating a user task '" << mTaskConfig.taskName << "'" << ENDM;
@@ -167,6 +170,11 @@ void PostProcessingRunner::start(framework::ServiceRegistryRef dplServices)
167170
}
168171
QcInfoLogger::setRun(mTaskConfig.activity.mId);
169172

173+
// register ourselves to the BK
174+
if (gSystem->Getenv("O2_QC_REGISTER_IN_BK")) { // until we are sure it works, we have to turn it on
175+
Bookkeeping::getInstance().registerProcess(mTaskConfig.activity.mId, mRunnerConfig.taskName, mRunnerConfig.detectorName, bookkeeping::DPL_PROCESS_TYPE_QC_POSTPROCESSING, "");
176+
}
177+
170178
if (mTaskState == TaskState::Created || mTaskState == TaskState::Finished) {
171179
mInitTriggers = trigger_helpers::createTriggers(mTaskConfig.initTriggers, mTaskConfig);
172180
if (trigger_helpers::hasUserOrControlTrigger(mTaskConfig.initTriggers)) {
@@ -256,6 +264,7 @@ PostProcessingRunnerConfig PostProcessingRunner::extractConfig(const CommonSpec&
256264
ppTaskSpec.detectorName,
257265
commonSpec.database,
258266
commonSpec.consulUrl,
267+
commonSpec.bookkeepingUrl,
259268
commonSpec.infologgerDiscardParameters,
260269
commonSpec.postprocessingPeriod,
261270
"",

Framework/src/TaskRunner.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,11 @@ void TaskRunner::startOfActivity()
463463
mCollector->setRunNumber(mActivity.mId);
464464
mTask->startOfActivity(mActivity);
465465
mObjectsManager->updateServiceDiscovery();
466+
467+
// register ourselves to the BK
468+
if (gSystem->Getenv("O2_QC_REGISTER_IN_BK")) { // until we are sure it works, we have to turn it on
469+
Bookkeeping::getInstance().registerProcess(mActivity.mId, mTaskConfig.taskName, mTaskConfig.detectorName, bookkeeping::DPL_PROCESS_TYPE_QC_TASK, "");
470+
}
466471
}
467472

468473
void TaskRunner::endOfActivity()

0 commit comments

Comments
 (0)