Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QC-1026] Separate source / target QCDB for postprocessing #2371

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Framework/include/QualityControl/PostProcessingRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ class PostProcessingRunner
core::Activity mActivity;
PostProcessingConfig mTaskConfig;
PostProcessingRunnerConfig mRunnerConfig;
std::shared_ptr<o2::quality_control::repository::DatabaseInterface> mDatabase;
std::shared_ptr<o2::quality_control::repository::DatabaseInterface> mSourceDatabase;
std::shared_ptr<o2::quality_control::repository::DatabaseInterface> mDestinationDatabase;
std::unique_ptr<repository::DatabaseInterface> configureDatabase(std::unordered_map<std::string, std::string>& dbConfig, const std::string& name);
};

MOCPublicationCallback publishToDPL(o2::framework::DataAllocator&, std::string outputBinding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ struct PostProcessingRunnerConfig {
std::string id;
std::string taskName;
std::string detectorName;
std::unordered_map<std::string, std::string> database;
std::unordered_map<std::string, std::string> sourceDatabase;
std::unordered_map<std::string, std::string> destinationDatabase;
std::string consulUrl{};
std::string bookkeepingUrl{};
core::LogDiscardParameters infologgerDiscardParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct PostProcessingTaskSpec {
std::string detectorName = "Invalid";
boost::property_tree::ptree tree = {};
core::CustomParameters customParameters;
std::unordered_map<std::string, std::string> sourceDatabase;
};

} // namespace o2::quality_control::core
Expand Down
5 changes: 5 additions & 0 deletions Framework/src/InfrastructureSpecReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ PostProcessingTaskSpec
ppts.active = ppTaskTree.get<bool>("active", ppts.active);
ppts.critical = ppTaskTree.get<bool>("critical", ppts.critical);
ppts.detectorName = ppTaskTree.get<std::string>("detectorName", ppts.detectorName);
if (ppTaskTree.count("sourceRepo") > 0) {
for (const auto& [key, value] : ppTaskTree.get_child("sourceRepo")) {
ppts.sourceDatabase.emplace(key, value.get_value<std::string>());
}
}
ppts.tree = wholeTree;

return ppts;
Expand Down
25 changes: 18 additions & 7 deletions Framework/src/PostProcessingRunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ void PostProcessingRunner::init(const boost::property_tree::ptree& config, core:
init(PostProcessingRunner::extractConfig(specs.common, *ppTaskSpec), PostProcessingConfig{ mID, config });
}

std::unique_ptr<DatabaseInterface> PostProcessingRunner::configureDatabase(std::unordered_map<std::string, std::string>& dbConfig, const std::string& name)
{
auto database = DatabaseFactory::create(dbConfig.at("implementation"));
database->connect(dbConfig);
ILOG(Info, Support) << name << " database that is going to be used > Implementation : " << dbConfig.at("implementation") << " / "
<< " Host : " << dbConfig.at("host") << ENDM;
return database;
}

void PostProcessingRunner::init(const PostProcessingRunnerConfig& runnerConfig, const PostProcessingConfig& taskConfig)
{
QcInfoLogger::init(("post/" + taskConfig.taskName).substr(0, QcInfoLogger::maxFacilityLength), runnerConfig.infologgerDiscardParameters);
Expand All @@ -82,16 +91,14 @@ void PostProcessingRunner::init(const PostProcessingRunnerConfig& runnerConfig,
}

// configuration of the database
mDatabase = DatabaseFactory::create(mRunnerConfig.database.at("implementation"));
mDatabase->connect(mRunnerConfig.database);
ILOG(Info, Support) << "Database that is going to be used > Implementation : " << mRunnerConfig.database.at("implementation") << " / "
<< " Host : " << mRunnerConfig.database.at("host") << ENDM;
mSourceDatabase = configureDatabase(mRunnerConfig.sourceDatabase, "Source");
mDestinationDatabase = configureDatabase(mRunnerConfig.destinationDatabase, "Destination");

mObjectManager = std::make_shared<ObjectsManager>(mTaskConfig.taskName, mTaskConfig.className, mTaskConfig.detectorName, mRunnerConfig.consulUrl);
mObjectManager->setActivity(mActivity);
mServices.registerService<DatabaseInterface>(mDatabase.get());
mServices.registerService<DatabaseInterface>(mSourceDatabase.get());
if (mPublicationCallback == nullptr) {
mPublicationCallback = publishToRepository(*mDatabase);
mPublicationCallback = publishToRepository(*mDestinationDatabase);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If done like this, it will only work in cases when a postprocessing task is ran with o2-qc-run-postprocessing, that is without DPL. When we run with DPL, this callback is set by PostProcessingDevice to publish objects into DPL, then CheckRunners receive them, apply Checks and store them to the database they use.

I think it will be very misleading if it works only for some cases.

How about getting rid of the destinationRepo parameter and using always the main repo as the destination?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we can do that for the destinatino repo. I did not think of this issue and thought that why not add both source and destination. I'll amend the PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed a commit

}
Bookkeeping::getInstance().init(runnerConfig.bookkeepingUrl);

Expand Down Expand Up @@ -232,7 +239,8 @@ void PostProcessingRunner::reset()
mTaskState = TaskState::INVALID;

mTask.reset();
mDatabase.reset();
mSourceDatabase.reset();
mDestinationDatabase.reset();
mServices = framework::ServiceRegistry();
mObjectManager.reset();

Expand Down Expand Up @@ -327,10 +335,13 @@ const std::string& PostProcessingRunner::getID() const

PostProcessingRunnerConfig PostProcessingRunner::extractConfig(const CommonSpec& commonSpec, const PostProcessingTaskSpec& ppTaskSpec)
{
auto sourceDatabase = ppTaskSpec.sourceDatabase.empty() ? commonSpec.database : ppTaskSpec.sourceDatabase;

return {
ppTaskSpec.id,
ppTaskSpec.taskName,
ppTaskSpec.detectorName,
sourceDatabase,
commonSpec.database,
commonSpec.consulUrl,
commonSpec.bookkeepingUrl,
Expand Down
26 changes: 25 additions & 1 deletion doc/PostProcessing.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Checks can be applied to the results of Post-processing Tasks just as for normal
...
```

## Definition and access of user-specific configuration
#### Definition and access of user-specific configuration

A postprocessing task can access custom parameters declared in the configuration file at `qc.postprocessing.<task_id>.extendedTaskParameters`. They are stored inside an object of type `CustomParameters` named `mCustomParameters`, which is a protected member of `TaskInterface`.

Expand All @@ -165,6 +165,30 @@ Each of the three methods can be invoked by one or more triggers. Below are list
* `"once"` - Once - triggers only first time it is checked
* `"always"` - Always - triggers each time it is checked

#### Using different databases

It might happen that one wants to get data and store data in different databases. Typically if you want to test with
production data but store the object in test.

This can be achieved by setting the extra parameter `sourceRepo` in the task. You have to add it to all your tasks as this is not a global
parameter. It is optional.

The destination repository is always the global one defined in the global configuration under `qc.config.database`.

```
"postprocessing": {
"MyPostProcessingTaskID": {
...
"sourceRepo": {
"implementation": "CCDB",
"host": "another-test.cern.ch:8080"
},
...
}
...
}
```

### Running it

The post-processing tasks can be run in three ways. First uses the usual `o2-qc` executable which relies on DPL and
Expand Down
Loading