Skip to content

Commit 5269f06

Browse files
committed
DPL: hide more stuff from runDataProcessing.h
This avoids having a large mainNoCatch duplicated in each executable.
1 parent 43223a4 commit 5269f06

File tree

2 files changed

+52
-23
lines changed

2 files changed

+52
-23
lines changed

Framework/Core/include/Framework/runDataProcessing.h

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define FRAMEWORK_RUN_DATA_PROCESSING_H
1313

1414
#include <fmt/format.h>
15+
#include "Framework/ConfigParamSpec.h"
1516
#include "Framework/ChannelConfigurationPolicy.h"
1617
#include "Framework/CallbacksPolicy.h"
1718
#include "Framework/CompletionPolicy.h"
@@ -22,17 +23,13 @@
2223
#include "Framework/SendingPolicy.h"
2324
#include "Framework/WorkflowSpec.h"
2425
#include "Framework/ConfigContext.h"
25-
#include "Framework/BoostOptionsRetriever.h"
2626
#include "Framework/CustomWorkflowTerminationHook.h"
2727
#include "Framework/CommonServices.h"
2828
#include "Framework/WorkflowCustomizationHelpers.h"
29-
#include "Framework/ResourcePolicyHelpers.h"
3029
#include "Framework/Logger.h"
3130
#include "Framework/CheckTypes.h"
3231
#include "Framework/StructToTuple.h"
33-
#include "Framework/ConfigParamDiscovery.h"
3432
#include "ResourcePolicy.h"
35-
#include "ServiceRegistryRef.h"
3633
#include <vector>
3734

3835
namespace o2::framework
@@ -120,7 +117,9 @@ struct UserCustomizationsHelper {
120117
namespace o2::framework
121118
{
122119
class ConfigContext;
123-
}
120+
class ConfigParamRegistry;
121+
class ConfigParamSpec;
122+
} // namespace o2::framework
124123
/// Helper used to customize a workflow pipelining options
125124
void overridePipeline(o2::framework::ConfigContext& ctx, std::vector<o2::framework::DataProcessorSpec>& workflow);
126125

@@ -155,10 +154,18 @@ std::vector<T> injectCustomizations()
155154
return policies;
156155
}
157156

157+
void overrideAll(o2::framework::ConfigContext& ctx, std::vector<o2::framework::DataProcessorSpec>& workflow);
158+
159+
o2::framework::ConfigContext createConfigContext(std::unique_ptr<o2::framework::ConfigParamRegistry>& workflowOptionsRegistry,
160+
o2::framework::ServiceRegistry& configRegistry,
161+
std::vector<o2::framework::ConfigParamSpec>& workflowOptions,
162+
std::vector<o2::framework::ConfigParamSpec>& extraOptions, int argc, char** argv);
163+
164+
std::unique_ptr<o2::framework::ServiceRegistry> createRegistry();
165+
158166
int mainNoCatch(int argc, char** argv)
159167
{
160168
using namespace o2::framework;
161-
using namespace boost::program_options;
162169

163170
std::vector<o2::framework::ConfigParamSpec> workflowOptions;
164171
UserCustomizationsHelper::userDefinedCustomization(workflowOptions);
@@ -171,24 +178,13 @@ int mainNoCatch(int argc, char** argv)
171178
std::vector<CallbacksPolicy> callbacksPolicies = injectCustomizations<CallbacksPolicy>();
172179
std::vector<SendingPolicy> sendingPolicies = injectCustomizations<SendingPolicy>();
173180

174-
std::vector<std::unique_ptr<ParamRetriever>> retrievers;
175-
std::unique_ptr<ParamRetriever> retriever{new BoostOptionsRetriever(true, argc, argv)};
176-
retrievers.emplace_back(std::move(retriever));
177-
auto workflowOptionsStore = std::make_unique<ConfigParamStore>(workflowOptions, std::move(retrievers));
178-
workflowOptionsStore->preload();
179-
workflowOptionsStore->activate();
180-
ConfigParamRegistry workflowOptionsRegistry(std::move(workflowOptionsStore));
181-
auto extraOptions = o2::framework::ConfigParamDiscovery::discover(workflowOptionsRegistry, argc, argv);
182-
for (auto& extra : extraOptions) {
183-
workflowOptions.push_back(extra);
184-
}
181+
std::unique_ptr<ServiceRegistry> configRegistry = createRegistry();
182+
std::vector<ConfigParamSpec> extraOptions;
183+
std::unique_ptr<ConfigParamRegistry> workflowOptionsRegistry{nullptr};
184+
auto configContext = createConfigContext(workflowOptionsRegistry, *configRegistry, workflowOptions, extraOptions, argc, argv);
185185

186-
ServiceRegistry configRegistry;
187-
ConfigContext configContext(workflowOptionsRegistry, ServiceRegistryRef{configRegistry}, argc, argv);
188186
o2::framework::WorkflowSpec specs = defineDataProcessing(configContext);
189-
overrideCloning(configContext, specs);
190-
overridePipeline(configContext, specs);
191-
overrideLabels(configContext, specs);
187+
overrideAll(configContext, specs);
192188
for (auto& spec : specs) {
193189
UserCustomizationsHelper::userDefinedCustomization(spec.requiredServices);
194190
}
@@ -207,7 +203,6 @@ char* getIdString(int argc, char** argv);
207203
int main(int argc, char** argv)
208204
{
209205
using namespace o2::framework;
210-
using namespace boost::program_options;
211206

212207
int result = callMain(argc, argv, mainNoCatch);
213208

Framework/Core/src/runDataProcessing.cxx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11+
#include <memory>
1112
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
1213
#include <stdexcept>
1314
#include "Framework/BoostOptionsRetriever.h"
@@ -69,6 +70,7 @@
6970
#include "HTTPParser.h"
7071
#include "DPLWebSocket.h"
7172
#include "ArrowSupport.h"
73+
#include "Framework/ConfigParamDiscovery.h"
7274

7375
#include "ComputingResourceHelpers.h"
7476
#include "DataProcessingStatus.h"
@@ -2806,6 +2808,38 @@ void enableSignposts(std::string const& signpostsToEnable)
28062808
}
28072809
}
28082810

2811+
void overrideAll(o2::framework::ConfigContext& ctx, std::vector<o2::framework::DataProcessorSpec>& workflow)
2812+
{
2813+
overrideCloning(ctx, workflow);
2814+
overridePipeline(ctx, workflow);
2815+
overrideLabels(ctx, workflow);
2816+
}
2817+
2818+
o2::framework::ConfigContext createConfigContext(std::unique_ptr<ConfigParamRegistry>& workflowOptionsRegistry,
2819+
o2::framework::ServiceRegistry& configRegistry,
2820+
std::vector<o2::framework::ConfigParamSpec>& workflowOptions,
2821+
std::vector<o2::framework::ConfigParamSpec>& extraOptions, int argc, char** argv)
2822+
{
2823+
std::vector<std::unique_ptr<o2::framework::ParamRetriever>> retrievers;
2824+
std::unique_ptr<o2::framework::ParamRetriever> retriever{new o2::framework::BoostOptionsRetriever(true, argc, argv)};
2825+
retrievers.emplace_back(std::move(retriever));
2826+
auto workflowOptionsStore = std::make_unique<o2::framework::ConfigParamStore>(workflowOptions, std::move(retrievers));
2827+
workflowOptionsStore->preload();
2828+
workflowOptionsStore->activate();
2829+
workflowOptionsRegistry = std::make_unique<ConfigParamRegistry>(std::move(workflowOptionsStore));
2830+
extraOptions = o2::framework::ConfigParamDiscovery::discover(*workflowOptionsRegistry, argc, argv);
2831+
for (auto& extra : extraOptions) {
2832+
workflowOptions.push_back(extra);
2833+
}
2834+
2835+
return o2::framework::ConfigContext(*workflowOptionsRegistry, o2::framework::ServiceRegistryRef{configRegistry}, argc, argv);
2836+
}
2837+
2838+
std::unique_ptr<o2::framework::ServiceRegistry> createRegistry()
2839+
{
2840+
return std::make_unique<o2::framework::ServiceRegistry>();
2841+
}
2842+
28092843
// This is a toy executor for the workflow spec
28102844
// What it needs to do is:
28112845
//

0 commit comments

Comments
 (0)