Skip to content

Commit 13d61ab

Browse files
committed
Adopt standard user I/O spec helpers
1 parent 4124e26 commit 13d61ab

18 files changed

Lines changed: 53 additions & 225 deletions

Framework/include/QualityControl/Aggregator.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ struct AggregatorSpec;
5151
class Aggregator
5252
{
5353
public:
54-
/// \brief Number of bytes in data description used for hashing of AggregatorRunner names. See HashDataDescription.h for details
55-
static constexpr size_t descriptionHashLength = 4;
56-
static_assert(descriptionHashLength <= o2::header::DataDescription::size);
57-
5854
/// Constructor
5955
/**
6056
* \brief Aggregator constructor
@@ -84,7 +80,6 @@ class Aggregator
8480
void endOfActivity(const core::Activity& activity);
8581

8682
static AggregatorConfig extractConfig(const core::CommonSpec&, const AggregatorSpec&);
87-
static framework::OutputSpec createOutputSpec(const std::string& detector, const std::string& aggregatorName);
8883

8984
private:
9085
/**

Framework/include/QualityControl/AggregatorRunner.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ struct AggregatorSource;
7979
/// \author Barthélémy von Haller
8080
class AggregatorRunner : public framework::Task
8181
{
82-
/// \brief Number of bytes in data description used for hashing of AggregatorRunner names. See HashDataDescription.h for details
83-
static constexpr size_t descriptionHashLength = 4;
84-
static_assert(descriptionHashLength <= o2::header::DataDescription::size);
85-
8682
public:
8783
/// Constructor
8884
/**
@@ -111,7 +107,6 @@ class AggregatorRunner : public framework::Task
111107
static framework::DataProcessorLabel getLabel() { return { "qc-aggregator" }; }
112108
static std::string createAggregatorRunnerIdString() { return "qc-aggregator"; };
113109
static std::string createAggregatorRunnerName();
114-
static header::DataDescription createAggregatorRunnerDataDescription(const std::string& aggregatorName);
115110

116111
/// \brief Compute the detector name to be used in the infologger for this runner.
117112
/// Compute the detector name to be used in the infologger for this runner.

Framework/include/QualityControl/Check.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ struct CheckSpec;
4545
/// \author Rafal Pacholek
4646
class Check
4747
{
48-
/// \brief Number of bytes in data description used for hashing of Check descrition names. See HashDataDescription.h for details
49-
static constexpr size_t descriptionHashLength = 4;
50-
static_assert(descriptionHashLength <= o2::header::DataDescription::size);
51-
5248
public:
5349
/// Constructor
5450
/**
@@ -78,21 +74,12 @@ class Check
7874
void startOfActivity(const core::Activity& activity);
7975
void endOfActivity(const core::Activity& activity);
8076

81-
// TODO: Unique Input string
82-
static o2::header::DataDescription createCheckDataDescription(const std::string& checkName);
83-
84-
/// \brief creates DataOrigin for Check task in form CDET
85-
///
86-
/// \param detector Name of the detector to be used. If longer than 3B it will be truncated
87-
static o2::header::DataOrigin createCheckDataOrigin(const std::string& detector);
88-
8977
UpdatePolicyType getUpdatePolicyType() const;
9078
std::vector<std::string> getObjectsNames() const;
9179
bool getAllObjectsOption() const;
9280

9381
// todo: probably make CheckFactory
9482
static CheckConfig extractConfig(const core::CommonSpec&, const CheckSpec&);
95-
static framework::OutputSpec createOutputSpec(const std::string& detector, const std::string& checkName);
9683

9784
private:
9885
void beautify(std::map<std::string, std::shared_ptr<core::MonitorObject>>& moMap, const core::Quality& quality);

Framework/include/QualityControl/PostProcessingDevice.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ struct PostProcessingRunnerConfig;
3636
/// \author Piotr Konopka
3737
class PostProcessingDevice : public framework::Task
3838
{
39-
/// \brief Number of bytes in data description used for hashing DataDescription. See HashDataDescription.h for details
40-
static constexpr size_t descriptionHashLength = 4;
41-
static_assert(descriptionHashLength <= o2::header::DataDescription::size);
42-
4339
public:
4440
/// \brief Constructor
4541
///
@@ -61,10 +57,6 @@ class PostProcessingDevice : public framework::Task
6157
/// \brief Data Processor Label to identify all Task Runners
6258
static framework::DataProcessorLabel getLabel() { return { "qc-pp-task-runner" }; }
6359
static std::string createPostProcessingDeviceName(const std::string& taskName, const std::string& detectorName);
64-
/// \brief Unified DataOrigin for Post-processing tasks
65-
static header::DataOrigin createPostProcessingDataOrigin(const std::string& detectorCode);
66-
/// \brief Unified DataDescription naming scheme for all Post-processing tasks
67-
static header::DataDescription createPostProcessingDataDescription(const std::string& taskName);
6860

6961
private:
7062
/// \brief Callback for CallbackService::Id::Start (DPL) a.k.a. RUN transition (FairMQ)

Framework/include/QualityControl/TaskRunner.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ class ObjectsManager;
7777
/// \author Barthelemy von Haller
7878
class TaskRunner : public framework::Task
7979
{
80-
/// \brief Number of bytes in data description used for hashing of Task names. See HashDataDescription.h for details
81-
static constexpr size_t taskDescriptionHashLength = 4;
82-
static_assert(taskDescriptionHashLength <= o2::header::DataDescription::size);
83-
8480
public:
8581
/// \brief Constructor
8682
///
@@ -109,10 +105,6 @@ class TaskRunner : public framework::Task
109105
static framework::DataProcessorLabel getTaskRunnerLabel() { return { "qc-task" }; }
110106
/// \brief ID string for all TaskRunner devices
111107
static std::string createTaskRunnerIdString();
112-
/// \brief Unified DataOrigin for Quality Control tasks
113-
static header::DataOrigin createTaskDataOrigin(const std::string& detectorCode, bool movingWindows = false);
114-
/// \brief Unified DataDescription naming scheme for all tasks
115-
static header::DataDescription createTaskDataDescription(const std::string& taskName);
116108
/// \brief Unified DataDescription naming scheme for all timers
117109
static header::DataDescription createTimerDataDescription(const std::string& taskName);
118110

Framework/src/Aggregator.cxx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "QualityControl/Activity.h"
2727
#include <Common/Exceptions.h>
2828
#include "QualityControl/CommonSpec.h"
29-
#include "QualityControl/DataHeaderHelpers.h"
29+
#include "QualityControl/UserInputOutput.h"
3030

3131
#include <utility>
3232
#include <algorithm>
@@ -253,33 +253,11 @@ AggregatorConfig Aggregator::extractConfig(const core::CommonSpec& commonSpec, c
253253
std::move(objectNames),
254254
checkAllObjects,
255255
std::move(inputs),
256-
createOutputSpec(aggregatorSpec.detectorName, aggregatorSpec.aggregatorName),
256+
createUserOutputSpec(DataSourceType::Aggregator, aggregatorSpec.detectorName, aggregatorSpec.aggregatorName),
257257
sources
258258
};
259259
}
260260

261-
o2::header::DataOrigin createAggregatorDataOrigin(const std::string& detector)
262-
{
263-
using Origin = o2::header::DataOrigin;
264-
Origin header;
265-
header.runtimeInit(std::string{ "A" }.append(detector.substr(0, Origin::size - 1)).c_str());
266-
return header;
267-
}
268-
269-
o2::header::DataDescription createAggregatorDataDescription(const std::string& aggregatorName)
270-
{
271-
if (aggregatorName.empty()) {
272-
BOOST_THROW_EXCEPTION(FatalException() << AliceO2::Common::errinfo_details("Empty aggregatorName for aggregator's data description"));
273-
}
274-
275-
return quality_control::core::createDataDescription(aggregatorName, Aggregator::descriptionHashLength);
276-
}
277-
278-
framework::OutputSpec Aggregator::createOutputSpec(const std::string& detector, const std::string& aggregatorName)
279-
{
280-
return { createAggregatorDataOrigin(detector), createAggregatorDataDescription(aggregatorName), 0, framework::Lifetime::Sporadic };
281-
}
282-
283261
void Aggregator::startOfActivity(const core::Activity& activity)
284262
{
285263
if (mAggregatorInterface) {

Framework/src/AggregatorRunner.cxx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,6 @@ void AggregatorRunner::prepareOutputs()
9696
}
9797
}
9898

99-
header::DataDescription AggregatorRunner::createAggregatorRunnerDataDescription(const std::string& aggregatorName)
100-
{
101-
if (aggregatorName.empty()) {
102-
BOOST_THROW_EXCEPTION(FatalException() << errinfo_details("Empty taskName for task's data description"));
103-
}
104-
return quality_control::core::createDataDescription(aggregatorName, AggregatorRunner::descriptionHashLength);
105-
}
106-
10799
std::string AggregatorRunner::createAggregatorRunnerName()
108100
{
109101
return AggregatorRunner::createAggregatorRunnerIdString(); // there is only one thus we can just take the idString

Framework/src/Check.cxx

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "QualityControl/RootClassFactory.h"
3030
#include "QualityControl/QcInfoLogger.h"
3131
#include "QualityControl/Quality.h"
32-
#include "QualityControl/DataHeaderHelpers.h"
32+
#include "QualityControl/UserInputOutput.h"
3333
#include "QualityControl/ObjectMetadataHelpers.h"
3434

3535
#include <QualityControl/AggregatorRunner.h>
@@ -44,24 +44,6 @@ using namespace std;
4444
namespace o2::quality_control::checker
4545
{
4646

47-
/// Static functions
48-
o2::header::DataDescription Check::createCheckDataDescription(const std::string& checkName)
49-
{
50-
if (checkName.empty()) {
51-
BOOST_THROW_EXCEPTION(FatalException() << errinfo_details("Empty checkName for check's data description"));
52-
}
53-
54-
return quality_control::core::createDataDescription(checkName, Check::descriptionHashLength);
55-
}
56-
57-
o2::header::DataOrigin Check::createCheckDataOrigin(const std::string& detector)
58-
{
59-
using Origin = o2::header::DataOrigin;
60-
Origin header;
61-
header.runtimeInit(std::string{ "C" }.append(detector.substr(0, Origin::size - 1)).c_str());
62-
return header;
63-
}
64-
6547
/// Members
6648
Check::Check(CheckConfig config)
6749
: mCheckConfig(std::move(config))
@@ -281,15 +263,10 @@ CheckConfig Check::extractConfig(const CommonSpec& commonSpec, const CheckSpec&
281263
checkAllObjects,
282264
allowBeautify,
283265
std::move(inputs),
284-
createOutputSpec(checkSpec.detectorName, checkSpec.checkName),
266+
createUserOutputSpec(DataSourceType::Check, checkSpec.detectorName, checkSpec.checkName),
285267
};
286268
}
287269

288-
framework::OutputSpec Check::createOutputSpec(const std::string& detector, const std::string& checkName)
289-
{
290-
return { createCheckDataOrigin(detector), createCheckDataDescription(checkName), 0, framework::Lifetime::Sporadic };
291-
}
292-
293270
void Check::startOfActivity(const core::Activity& activity)
294271
{
295272
if (mCheckInterface) {

Framework/src/InfrastructureGenerator.cxx

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ framework::WorkflowSpec InfrastructureGenerator::generateLocalBatchInfrastructur
337337
auto taskConfig = TaskRunnerFactory::extractConfig(infrastructureSpec.common, taskSpec, 0, 1);
338338
workflow.emplace_back(TaskRunnerFactory::create(taskConfig));
339339

340-
fileSinkInputs.emplace_back(taskSpec.taskName, TaskRunner::createTaskDataOrigin(taskSpec.detectorName), TaskRunner::createTaskDataDescription(taskSpec.taskName), Lifetime::Sporadic);
340+
fileSinkInputs.emplace_back(createUserInputSpec(DataSourceType::Task, taskSpec.detectorName, taskSpec.taskName));
341341
}
342342

343343
if (!fileSinkInputs.empty()) {
@@ -377,9 +377,8 @@ framework::WorkflowSpec InfrastructureGenerator::generateRemoteBatchInfrastructu
377377
// We create an OutputSpec for moving windows for this task only if they are expected.
378378
if (!taskConfig.movingWindows.empty()) {
379379
fileSourceOutputs.push_back(
380-
{ RootFileSource::outputBinding(taskSpec.detectorName, taskSpec.taskName, true),
381-
TaskRunner::createTaskDataOrigin(taskSpec.detectorName, true),
382-
TaskRunner::createTaskDataDescription(taskSpec.taskName), 0, Lifetime::Sporadic });
380+
createUserOutputSpec(DataSourceType::TaskMovingWindow, taskSpec.detectorName, taskSpec.taskName, 0,
381+
RootFileSource::outputBinding(taskSpec.detectorName, taskSpec.taskName, true)));
383382
}
384383
}
385384
if (!fileSourceOutputs.empty()) {
@@ -530,7 +529,7 @@ void InfrastructureGenerator::generateLocalTaskLocalProxy(framework::WorkflowSpe
530529
std::string remotePort = std::to_string(taskSpec.remotePort);
531530
std::string proxyName = taskSpec.detectorName + "-" + taskName + "-proxy";
532531
std::string channelName = taskSpec.detectorName + "-" + taskName + "-proxy";
533-
InputSpec proxyInput{ channelName, TaskRunner::createTaskDataOrigin(taskSpec.detectorName, false), TaskRunner::createTaskDataDescription(taskName), static_cast<SubSpec>(id), Lifetime::Sporadic };
532+
InputSpec proxyInput = createUserInputSpec(DataSourceType::Task, taskSpec.detectorName, taskName, static_cast<SubSpec>(id), channelName);
534533
std::string channelConfig = "name=" + channelName + ",type=pub,method=connect,address=tcp://" +
535534
taskSpec.remoteMachine + ":" + remotePort + ",rateLogging=60,transport=zeromq,sndBufSize=4";
536535

@@ -554,7 +553,7 @@ void InfrastructureGenerator::generateLocalTaskRemoteProxy(framework::WorkflowSp
554553
Outputs proxyOutputs;
555554
for (size_t id = 1; id <= numberOfLocalMachines; id++) {
556555
proxyOutputs.emplace_back(
557-
OutputSpec{ { channelName }, TaskRunner::createTaskDataOrigin(taskSpec.detectorName, false), TaskRunner::createTaskDataDescription(taskName), static_cast<SubSpec>(id), Lifetime::Sporadic });
556+
createUserOutputSpec(DataSourceType::Task, taskSpec.detectorName, taskName, static_cast<SubSpec>(id), { channelName }));
558557
}
559558

560559
std::string channelConfig = "name=" + channelName + ",type=sub,method=bind,address=tcp://*:" + remotePort +
@@ -586,20 +585,14 @@ void InfrastructureGenerator::generateMergers(framework::WorkflowSpec& workflow,
586585
Inputs mergerInputs;
587586
for (size_t id = 1; id <= numberOfLocalMachines; id++) {
588587
mergerInputs.emplace_back(
589-
InputSpec{ { taskName + std::to_string(id) },
590-
TaskRunner::createTaskDataOrigin(detectorName, false),
591-
TaskRunner::createTaskDataDescription(taskName),
592-
static_cast<SubSpec>(id),
593-
Lifetime::Sporadic });
588+
createUserInputSpec(DataSourceType::Task, detectorName, taskName, static_cast<SubSpec>(id), taskName + std::to_string(id)));
594589
}
595590

596591
MergerInfrastructureBuilder mergersBuilder;
597592
mergersBuilder.setInfrastructureName(taskName);
598593
mergersBuilder.setInputSpecs(mergerInputs);
599-
mergersBuilder.setOutputSpec(
600-
{ { "main" }, TaskRunner::createTaskDataOrigin(detectorName, false), TaskRunner::createTaskDataDescription(taskName), 0, Lifetime::Sporadic });
601-
mergersBuilder.setOutputSpecMovingWindow(
602-
{ { "main_mw" }, TaskRunner::createTaskDataOrigin(detectorName, true), TaskRunner::createTaskDataDescription(taskName), 0, Lifetime::Sporadic });
594+
mergersBuilder.setOutputSpec(createUserOutputSpec(DataSourceType::Task, detectorName, taskName, 0, { "main" }));
595+
mergersBuilder.setOutputSpecMovingWindow(createUserOutputSpec(DataSourceType::TaskMovingWindow, detectorName, taskName, 0, { "main_mw" }));
603596
MergerConfig mergerConfig;
604597
// if we are to change the mode to Full, disable reseting tasks after each cycle.
605598
mergerConfig.inputObjectTimespan = { (mergingMode.empty() || mergingMode == "delta") ? InputObjectsTimespan::LastDifference : InputObjectsTimespan::FullHistory };
@@ -630,23 +623,20 @@ void InfrastructureGenerator::generateCheckRunners(framework::WorkflowSpec& work
630623

631624
// todo: avoid code repetition
632625
for (const auto& taskSpec : infrastructureSpec.tasks | std::views::filter(&TaskSpec::active)) {
633-
InputSpec taskOutput{ taskSpec.taskName, TaskRunner::createTaskDataOrigin(taskSpec.detectorName), TaskRunner::createTaskDataDescription(taskSpec.taskName), Lifetime::Sporadic };
626+
InputSpec taskOutput{ createUserInputSpec(DataSourceType::Task, taskSpec.detectorName, taskSpec.taskName) };
634627
tasksOutputMap.insert({ DataSpecUtils::label(taskOutput), taskOutput });
635628

636629
bool movingWindowsEnabled = !taskSpec.movingWindows.empty();
637630
bool synchronousRemote = taskSpec.location == TaskLocationSpec::Local && (infrastructureSpec.workflowType == WorkflowType::Remote || infrastructureSpec.workflowType == WorkflowType::FullChain);
638631
bool asynchronousRemote = infrastructureSpec.workflowType == WorkflowType::RemoteBatch;
639632
if (movingWindowsEnabled && (synchronousRemote || asynchronousRemote)) {
640-
InputSpec taskMovingWindowOutput{ taskSpec.taskName, TaskRunner::createTaskDataOrigin(taskSpec.detectorName, true), TaskRunner::createTaskDataDescription(taskSpec.taskName), Lifetime::Sporadic };
633+
InputSpec taskMovingWindowOutput{ createUserInputSpec(DataSourceType::TaskMovingWindow, taskSpec.detectorName, taskSpec.taskName) };
641634
tasksOutputMap.insert({ DataSpecUtils::label(taskMovingWindowOutput), taskMovingWindowOutput });
642635
}
643636
}
644637

645638
for (const auto& ppTaskSpec : infrastructureSpec.postProcessingTasks | std::views::filter(&PostProcessingTaskSpec::active)) {
646-
InputSpec ppTaskOutput{ ppTaskSpec.taskName,
647-
PostProcessingDevice::createPostProcessingDataOrigin(ppTaskSpec.detectorName),
648-
PostProcessingDevice::createPostProcessingDataDescription(ppTaskSpec.taskName),
649-
Lifetime::Sporadic };
639+
InputSpec ppTaskOutput{ createUserInputSpec(DataSourceType::PostProcessingTask, ppTaskSpec.detectorName, ppTaskSpec.taskName) };
650640
tasksOutputMap.insert({ DataSpecUtils::label(ppTaskOutput), ppTaskOutput });
651641
}
652642

@@ -779,27 +769,18 @@ void InfrastructureGenerator::generatePostProcessing(WorkflowSpec& workflow, con
779769
}
780770
}
781771

782-
template <typename Type>
783-
auto createSinkInput(const std::string& detectorName, const std::string& name) -> framework::InputSpec
784-
{
785-
const auto outputSpec = Type::createOutputSpec(detectorName, name);
786-
auto input = DataSpecUtils::matchingInput(outputSpec);
787-
input.binding = name;
788-
return input;
789-
}
790-
791772
void InfrastructureGenerator::generateBookkeepingQualitySink(WorkflowSpec& workflow, const InfrastructureSpec& infrastructureSpec)
792773
{
793774
framework::Inputs sinkInputs{};
794775

795776
for (const auto& checkSpec : infrastructureSpec.checks | std::views::filter(&CheckSpec::active) | std::views::filter(&CheckSpec::exportToBookkeeping)) {
796777
ILOG(Debug, Support) << "Adding input to BookkeepingSink from check " << checkSpec.checkName << " and detector: " << checkSpec.detectorName << ENDM;
797-
sinkInputs.emplace_back(createSinkInput<Check>(checkSpec.detectorName, checkSpec.checkName));
778+
sinkInputs.emplace_back(createUserInputSpec(DataSourceType::Check, checkSpec.detectorName, checkSpec.checkName));
798779
}
799780

800781
for (const auto& aggregatorSpec : infrastructureSpec.aggregators | std::views::filter(&AggregatorSpec::active) | std::views::filter(&AggregatorSpec::exportToBookkeeping)) {
801782
ILOG(Debug, Support) << "Adding input to BookkeepingSink from aggregator " << aggregatorSpec.aggregatorName << " and detector: " << aggregatorSpec.detectorName << ENDM;
802-
sinkInputs.emplace_back(createSinkInput<Aggregator>(aggregatorSpec.detectorName, aggregatorSpec.aggregatorName));
783+
sinkInputs.emplace_back(createUserInputSpec(DataSourceType::Aggregator, aggregatorSpec.detectorName, aggregatorSpec.aggregatorName));
803784
}
804785

805786
if (sinkInputs.empty()) {

0 commit comments

Comments
 (0)