Skip to content

Commit

Permalink
parameter to explicitly allow parent access (AliceO2Group#9954)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrosseo authored Sep 30, 2022
1 parent 74a5553 commit fa1c93b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
7 changes: 6 additions & 1 deletion Framework/AnalysisSupport/src/AODJAlienReaderHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,13 @@ AlgorithmSpec AODJAlienReaderHelpers::rootFileReaderCallback()
parentFileReplacement = options.get<std::string>("aod-parent-base-path-replacement");
}

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, parentFileReplacement);
auto didir = std::make_shared<DataInputDirector>(filename, &monitoring, parentAccessLevel, parentFileReplacement);
if (options.isSet("aod-reader-json")) {
auto jsonFile = options.get<std::string>("aod-reader-json");
if (!didir->readJson(jsonFile)) {
Expand Down
23 changes: 14 additions & 9 deletions Framework/AnalysisSupport/src/DataInputDirector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ FileNameHolder* makeFileNameHolder(std::string fileName)
return fileNameHolder;
}

DataInputDescriptor::DataInputDescriptor(bool alienSupport, int level, o2::monitoring::Monitoring* monitoring, std::string parentFileReplacement) : mAlienSupport(alienSupport),
mMonitoring(monitoring),
mParentFileReplacement(parentFileReplacement),
mLevel(level)
DataInputDescriptor::DataInputDescriptor(bool alienSupport, int level, o2::monitoring::Monitoring* monitoring, int allowedParentLevel, std::string parentFileReplacement) : mAlienSupport(alienSupport),
mMonitoring(monitoring),
mAllowedParentLevel(allowedParentLevel),
mParentFileReplacement(parentFileReplacement),
mLevel(level)
{
}

Expand Down Expand Up @@ -245,8 +246,12 @@ DataInputDescriptor* DataInputDescriptor::getParentFile(int counter, int numTF)
}
}

if (mLevel == mAllowedParentLevel) {
throw std::runtime_error(fmt::format(R"(parent file requested but we are already at level {} of maximal allowed level {} for DF "{}" in file "{}")", mLevel, mAllowedParentLevel, folderName.c_str(), mcurrentFile->GetName()));
}

LOGP(info, "Opening parent file {} for DF {}", parentFileName->GetString().Data(), folderName.c_str());
mParentFile = new DataInputDescriptor(mAlienSupport, mLevel + 1, mMonitoring, mParentFileReplacement);
mParentFile = new DataInputDescriptor(mAlienSupport, mLevel + 1, mMonitoring, mAllowedParentLevel, mParentFileReplacement);
mParentFile->mdefaultFilenamesPtr = new std::vector<FileNameHolder*>;
mParentFile->mdefaultFilenamesPtr->emplace_back(makeFileNameHolder(parentFileName->GetString().Data()));
mParentFile->fillInputfiles();
Expand Down Expand Up @@ -414,7 +419,7 @@ DataInputDirector::DataInputDirector()
createDefaultDataInputDescriptor();
}

DataInputDirector::DataInputDirector(std::string inputFile, o2::monitoring::Monitoring* monitoring, std::string parentFileReplacement) : mMonitoring(monitoring), mParentFileReplacement(parentFileReplacement)
DataInputDirector::DataInputDirector(std::string inputFile, o2::monitoring::Monitoring* monitoring, int allowedParentLevel, std::string parentFileReplacement) : mMonitoring(monitoring), mAllowedParentLevel(allowedParentLevel), mParentFileReplacement(parentFileReplacement)
{
if (inputFile.size() && inputFile[0] == '@') {
inputFile.erase(0, 1);
Expand All @@ -426,7 +431,7 @@ DataInputDirector::DataInputDirector(std::string inputFile, o2::monitoring::Moni
createDefaultDataInputDescriptor();
}

DataInputDirector::DataInputDirector(std::vector<std::string> inputFiles, o2::monitoring::Monitoring* monitoring, std::string parentFileReplacement) : mMonitoring(monitoring), mParentFileReplacement(parentFileReplacement)
DataInputDirector::DataInputDirector(std::vector<std::string> inputFiles, o2::monitoring::Monitoring* monitoring, int allowedParentLevel, std::string parentFileReplacement) : mMonitoring(monitoring), mAllowedParentLevel(allowedParentLevel), mParentFileReplacement(parentFileReplacement)
{
for (auto inputFile : inputFiles) {
mdefaultInputFiles.emplace_back(makeFileNameHolder(inputFile));
Expand Down Expand Up @@ -461,7 +466,7 @@ void DataInputDirector::createDefaultDataInputDescriptor()
if (mdefaultDataInputDescriptor) {
delete mdefaultDataInputDescriptor;
}
mdefaultDataInputDescriptor = new DataInputDescriptor(mAlienSupport, 0, mMonitoring, mParentFileReplacement);
mdefaultDataInputDescriptor = new DataInputDescriptor(mAlienSupport, 0, mMonitoring, mAllowedParentLevel, mParentFileReplacement);

mdefaultDataInputDescriptor->setInputfilesFile(minputfilesFile);
mdefaultDataInputDescriptor->setFilenamesRegex(mFilenameRegex);
Expand Down Expand Up @@ -586,7 +591,7 @@ bool DataInputDirector::readJsonDocument(Document* jsonDoc)
return false;
}
// create a new dataInputDescriptor
auto didesc = new DataInputDescriptor(mAlienSupport, 0, mMonitoring, mParentFileReplacement);
auto didesc = new DataInputDescriptor(mAlienSupport, 0, mMonitoring, mAllowedParentLevel, mParentFileReplacement);
didesc->setDefaultInputfiles(&mdefaultInputFiles);

itemName = "table";
Expand Down
8 changes: 5 additions & 3 deletions Framework/AnalysisSupport/src/DataInputDirector.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DataInputDescriptor
std::unique_ptr<data_matcher::DataDescriptorMatcher> matcher;

DataInputDescriptor() = default;
DataInputDescriptor(bool alienSupport, int level, o2::monitoring::Monitoring* monitoring = nullptr, std::string parentFileReplacement = "");
DataInputDescriptor(bool alienSupport, int level, o2::monitoring::Monitoring* monitoring = nullptr, int allowedParentLevel = 0, std::string parentFileReplacement = "");

void printOut();

Expand Down Expand Up @@ -91,6 +91,7 @@ class DataInputDescriptor
std::string* minputfilesFilePtr = nullptr;
std::string mFilenameRegex = "";
std::string* mFilenameRegexPtr = nullptr;
int mAllowedParentLevel = 0;
std::string mParentFileReplacement;
std::vector<FileNameHolder*> mfilenames;
std::vector<FileNameHolder*>* mdefaultFilenamesPtr = nullptr;
Expand Down Expand Up @@ -118,8 +119,8 @@ class DataInputDirector

public:
DataInputDirector();
DataInputDirector(std::string inputFile, o2::monitoring::Monitoring* monitoring = nullptr, std::string parentFileReplacement = "");
DataInputDirector(std::vector<std::string> inputFiles, o2::monitoring::Monitoring* monitoring = nullptr, std::string parentFileReplacement = "");
DataInputDirector(std::string inputFile, o2::monitoring::Monitoring* monitoring = nullptr, int allowedParentLevel = 0, std::string parentFileReplacement = "");
DataInputDirector(std::vector<std::string> inputFiles, o2::monitoring::Monitoring* monitoring = nullptr, int allowedParentLevel = 0, std::string parentFileReplacement = "");
~DataInputDirector();

void reset();
Expand Down Expand Up @@ -150,6 +151,7 @@ class DataInputDirector
std::string minputfilesFile;
std::string* const minputfilesFilePtr = &minputfilesFile;
std::string mFilenameRegex;
int mAllowedParentLevel = 0;
std::string mParentFileReplacement;
std::string* const mFilenameRegexPtr = &mFilenameRegex;
DataInputDescriptor* mdefaultDataInputDescriptor = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion Framework/Core/include/Framework/AnalysisDataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ DECLARE_SOA_COLUMN(NpartProj, npartProj, int);
DECLARE_SOA_COLUMN(NpartTarg, npartTarg, int); //! Number of target participants
DECLARE_SOA_COLUMN(Ncoll, ncoll, int); //! Number of NN (nucleon-nucleon) collisions
DECLARE_SOA_COLUMN(NNwoundedCollisions, nNwoundedCollisions, int); //! Number of N-Nwounded collisions
DECLARE_SOA_COLUMN(NwoundedNCollisions, nwoundedNCollisions, int); //! Number of Nwounded-N collisons
DECLARE_SOA_COLUMN(NwoundedNCollisions, nwoundedNCollisions, int); //! Number of Nwounded-N collisions
DECLARE_SOA_COLUMN(NwoundedNwoundedCollisions, nwoundedNwoundedCollisions, int); //! Number of Nwounded-Nwounded collisions
DECLARE_SOA_COLUMN(SpectatorNeutrons, spectatorNeutrons, int); //! Number of spectator neutrons
DECLARE_SOA_COLUMN(SpectatorProtons, spectatorProtons, int); //! Number of spectator protons
Expand Down
1 change: 1 addition & 0 deletions Framework/Core/src/WorkflowHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ void WorkflowHelpers::injectServiceDevices(WorkflowSpec& workflow, ConfigContext
AlgorithmSpec::dummyAlgorithm(),
{ConfigParamSpec{"aod-file", VariantType::String, {"Input AOD file"}},
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{"aod-parent-base-path-replacement", VariantType::String, {R"(Replace base path of parent files. Syntax: FROM;TO. E.g. "alien:///path/in/alien;/local/path". Enclose in "" on the command line.)"}},
ConfigParamSpec{"time-limit", VariantType::Int64, 0ll, {"Maximum run time limit in seconds"}},
ConfigParamSpec{"orbit-offset-enumeration", VariantType::Int64, 0ll, {"initial value for the orbit"}},
Expand Down
1 change: 1 addition & 0 deletions Framework/Core/src/runDataProcessing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,7 @@ int runStateMachine(DataProcessorSpecs const& workflow,
"--aod-writer-resfile",
"--aod-writer-resmode",
"--aod-writer-keep",
"--aod-parent-access-level",
"--aod-parent-base-path-replacement",
"--driver-client-backend",
"--fairmq-ipc-prefix",
Expand Down

0 comments on commit fa1c93b

Please sign in to comment.