Skip to content

Commit

Permalink
DPL: account for aod-parent-access-level == 0
Browse files Browse the repository at this point in the history
In the case of self contained derived data, it is ok not to look in the parents
for missing metadata.
  • Loading branch information
ktf committed Nov 8, 2024
1 parent b345d0f commit 53c801a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
23 changes: 11 additions & 12 deletions Framework/AnalysisSupport/src/AODJAlienReaderHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,23 @@ static inline auto extractOriginalsTuple(framework::pack<Os...>, ProcessingConte
return std::make_tuple(extractTypedOriginal<Os>(pc)...);
}

AlgorithmSpec AODJAlienReaderHelpers::rootFileReaderCallback(ConfigContext const& config)
AlgorithmSpec AODJAlienReaderHelpers::rootFileReaderCallback(ConfigContext const& ctx)
{
// aod-parent-base-path-replacement is now a workflow option, so it needs to be
// retrieved from the ConfigContext. This is because we do not allow workflow options
// to change over start-stop-start because they can affect the topology generation.
std::string parentFileReplacement;
if (config.options().isSet("aod-parent-base-path-replacement")) {
parentFileReplacement = config.options().get<std::string>("aod-parent-base-path-replacement");
if (ctx.options().isSet("aod-parent-base-path-replacement")) {
parentFileReplacement = ctx.options().get<std::string>("aod-parent-base-path-replacement");
}
auto callback = AlgorithmSpec{adaptStateful([parentFileReplacement](ConfigParamRegistry const& options,
DeviceSpec const& spec,
Monitoring& monitoring,
DataProcessingStats& stats) {
int parentAccessLevel = 0;
if (ctx.options().isSet("aod-parent-access-level")) {
parentAccessLevel = ctx.options().get<int>("aod-parent-access-level");
}
auto callback = AlgorithmSpec{adaptStateful([parentFileReplacement, parentAccessLevel](ConfigParamRegistry const& options,
DeviceSpec const& spec,
Monitoring& monitoring,
DataProcessingStats& stats) {
// FIXME: not actually needed, since data processing stats can specify that we should
// send the initial value.
stats.updateStats({static_cast<short>(ProcessingStatsId::ARROW_BYTES_CREATED), DataProcessingStats::Op::Set, 0});
Expand All @@ -148,11 +152,6 @@ AlgorithmSpec AODJAlienReaderHelpers::rootFileReaderCallback(ConfigContext const

auto maxRate = options.get<float>("aod-max-io-rate");

int parentAccessLevel = 0;
if (options.isSet("aod-parent-access-level")) {
parentAccessLevel = options.get<int>("aod-parent-access-level");
}

// create a DataInputDirector
auto didir = std::make_shared<DataInputDirector>(filename, &monitoring, parentAccessLevel, parentFileReplacement);
if (options.isSet("aod-reader-json")) {
Expand Down
9 changes: 8 additions & 1 deletion Framework/AnalysisSupport/src/Plugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,20 @@ struct DiscoverMetadataInAOD : o2::framework::ConfigDiscoveryPlugin {
return results;
}

// Lets try in parent files
if (!registry.isSet("aod-parent-access-level") || registry.get<int>("aod-parent-access-level") == 0) {
LOGP(info, "No metadata found in file \"{}\" and parent level 0 prevents further lookup.", filename);
results.push_back(ConfigParamSpec{"aod-metadata-disable", VariantType::String, "1", {"Metadata not found in AOD"}});
return results;
}

// Lets try in parent file.
auto parentFiles = (TMap*)currentFile->Get("parentFiles");
if (!parentFiles) {
LOGP(info, "No metadata found in file \"{}\"", filename);
results.push_back(ConfigParamSpec{"aod-metadata-disable", VariantType::String, "1", {"Metadata not found in AOD"}});
return results;
}
LOGP(info, "No metadata found in file \"{}\", checking in its parents.", filename);
for (auto* p : *parentFiles) {
std::string parentFilename = ((TPair*)p)->Value()->GetName();
// Do the replacement. Notice this will require changing aod-parent-base-path-replacement to be
Expand Down
5 changes: 4 additions & 1 deletion Framework/Core/src/Plugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct DiscoverAODOptionsInCommandLine : o2::framework::ConfigDiscoveryPlugin {
bool injectOption = true;
for (size_t i = 0; i < argc; i++) {
std::string_view arg = argv[i];
if (!arg.starts_with("--aod-writer-") && arg != "--aod-parent-base-path-replacement") {
if (!arg.starts_with("--aod-writer-") && !arg.starts_with("--aod-parent-")) {
continue;
}
std::string key = arg.data() + 2;
Expand All @@ -156,6 +156,9 @@ struct DiscoverAODOptionsInCommandLine : o2::framework::ConfigDiscoveryPlugin {
if (key == "aod-parent-base-path-replacement") {
results.push_back(ConfigParamSpec{"aod-parent-base-path-replacement", VariantType::String, value, {R"(Replace base path of parent files. Syntax: FROM;TO. E.g. "alien:///path/in/alien;/local/path". Enclose in "" on the command line.)"}});
}
if (key == "aod-parent-access-level") {
results.push_back(ConfigParamSpec{"aod-parent-access-level", VariantType::String, value, {"Allow parent file access up to specified level. Default: no (0)"}});
}
}
if (injectOption) {
results.push_back(ConfigParamSpec{"aod-writer-compression", VariantType::Int, 505, {"AOD Compression options"}});
Expand Down
1 change: 0 additions & 1 deletion Framework/Core/src/WorkflowHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ void WorkflowHelpers::injectServiceDevices(WorkflowSpec& workflow, ConfigContext
.options = {ConfigParamSpec{"aod-file-private", VariantType::String, ctx.options().get<std::string>("aod-file"), {"AOD file"}},
ConfigParamSpec{"aod-max-io-rate", VariantType::Float, 0.f, {"Maximum I/O rate in MB/s"}},
ConfigParamSpec{"aod-reader-json", VariantType::String, {"json configuration file"}},
ConfigParamSpec{"aod-parent-access-level", VariantType::String, {"Allow parent file access up to specified level. Default: no (0)"}},
ConfigParamSpec{"time-limit", VariantType::Int64, 0ll, {"Maximum run time limit in seconds"}},
ConfigParamSpec{"orbit-offset-enumeration", VariantType::Int64, 0ll, {"initial value for the orbit"}},
ConfigParamSpec{"orbit-multiplier-enumeration", VariantType::Int64, 0ll, {"multiplier to get the orbit from the counter"}},
Expand Down

0 comments on commit 53c801a

Please sign in to comment.