Skip to content

Commit 7a4812b

Browse files
authored
[QC-428] Standalone Data Sampling executable (#4574)
1 parent 4549222 commit 7a4812b

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

Utilities/DataSampling/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ endforeach()
6161

6262
o2_data_file(COPY etc/exampleDataSamplingConfig.json DESTINATION etc)
6363

64+
o2_add_dpl_workflow(standalone
65+
SOURCES src/dataSamplingStandalone.cxx
66+
COMPONENT_NAME DataSampling
67+
PUBLIC_LINK_LIBRARIES O2::DataSampling)
68+
6469
o2_add_dpl_workflow(datasampling-pod-and-root
6570
SOURCES test/dataSamplingPodAndRoot.cxx
6671
COMPONENT_NAME DataSampling

Utilities/DataSampling/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ Data Sampling provides possibility to sample data in DPL workflows, basing on ce
2424

2525
### Usage
2626

27-
To use Data Sampling in a DPL workflow insert following lines to your code:
27+
One can use Data Sampling either by merging the standalone Data Sampling workflow with other DPL workflows:
28+
```bash
29+
o2-workflow-abc | o2-datasampling-standalone --config json://path/to/config.json | o2-workflow-xyz
30+
```
31+
...or by incorporating the code below into a DPL workflow which needs sampling:
2832
```cpp
2933
#include "DataSampling/DataSampling.h"
3034
using namespace o2::framework;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#include "Framework/ConfigParamSpec.h"
12+
#include "DataSampling/DataSampling.h"
13+
#include "Framework/CompletionPolicyHelpers.h"
14+
#include <vector>
15+
16+
using namespace o2::framework;
17+
using namespace o2::utilities;
18+
19+
void customize(std::vector<CompletionPolicy>& policies)
20+
{
21+
DataSampling::CustomizeInfrastructure(policies);
22+
}
23+
24+
void customize(std::vector<ChannelConfigurationPolicy>& policies)
25+
{
26+
DataSampling::CustomizeInfrastructure(policies);
27+
}
28+
29+
void customize(std::vector<ConfigParamSpec>& workflowOptions)
30+
{
31+
workflowOptions.push_back(ConfigParamSpec{"config", VariantType::String, "", {"path to the Data Sampling configuration file"}});
32+
workflowOptions.push_back(ConfigParamSpec{"dispatchers", VariantType::Int, 1, {"amount of parallel Dispatchers"}});
33+
}
34+
35+
#include "Framework/runDataProcessing.h"
36+
37+
WorkflowSpec defineDataProcessing(ConfigContext const& config)
38+
{
39+
auto configurationPath = config.options().get<std::string>("config");
40+
auto numberOfDispatchers = config.options().get<int>("dispatchers");
41+
42+
WorkflowSpec specs;
43+
DataSampling::GenerateInfrastructure(specs, configurationPath, numberOfDispatchers);
44+
return specs;
45+
}

0 commit comments

Comments
 (0)