Skip to content

Commit

Permalink
Merge branch 'release/v3_11_01'
Browse files Browse the repository at this point in the history
  • Loading branch information
knoepfel committed Mar 25, 2022
2 parents c186cc5 + f9a9cff commit fe3131d
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

find_package(cetmodules 2.13.00 REQUIRED)
project(art VERSION 3.11.00 LANGUAGES CXX C)
project(art VERSION 3.11.01 LANGUAGES CXX C)

include(CetCMakeEnv)
cet_cmake_env()
Expand Down
29 changes: 22 additions & 7 deletions art/Framework/IO/Sources/SourceHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,31 @@ art::SourceHelper::throwIfProductsNotRegistered_() const
}

art::ProcessHistoryID
art::SourceHelper::processHistoryID_(BranchType const bt,
ProcessConfiguration const& pc) const
art::SourceHelper::updatedProcessHistoryID_(
ProcessHistoryID const& processHistoryID,
BranchType const bt,
ProcessConfiguration const& pc) const
{
art::ProcessHistory processHistory{};
// If no products are present for this branch type, we do not
// register the process history.
// update the process history.
if (presentProducts_->descriptions(bt).empty()) {
return processHistory.id();
return processHistoryID;
}

art::ProcessHistory processHistory{};
if (processHistoryID.isValid()) {
bool const found =
ProcessHistoryRegistry::get(processHistoryID, processHistory);
if (!found) {
throw Exception(
errors::LogicError,
"Error while attempting to create principal from SourceHelper.\n")
<< "The provided process-history ID\n"
<< " " << processHistory << '\n'
<< "does not correspond to a known process history.\n"
"Please contact [email protected] for guidance.";
}
}
processHistory.push_back(pc);
auto const phid = processHistory.id();
art::ProcessHistoryRegistry::emplace(phid, processHistory);
Expand All @@ -60,8 +75,8 @@ art::SourceHelper::makePrincipal_(typename T::Auxiliary aux) const
{
throwIfProductsNotRegistered_();
constexpr auto branch_type = T::branch_type;
aux.setProcessHistoryID(
processHistoryID_(branch_type, md_.processConfiguration()));
aux.setProcessHistoryID(updatedProcessHistoryID_(
aux.processHistoryID(), branch_type, md_.processConfiguration()));
auto principal =
new T{aux, md_.processConfiguration(), &presentProducts_->get(branch_type)};
if (aux.processHistoryID().isValid()) {
Expand Down
5 changes: 3 additions & 2 deletions art/Framework/IO/Sources/SourceHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class art::SourceHelper {
template <typename T>
T* makePrincipal_(typename T::Auxiliary aux) const;
void throwIfProductsNotRegistered_() const;
ProcessHistoryID processHistoryID_(BranchType,
ProcessConfiguration const&) const;
ProcessHistoryID updatedProcessHistoryID_(ProcessHistoryID const&,
BranchType,
ProcessConfiguration const&) const;
void setPresentProducts(cet::exempt_ptr<ProductTables const> presentProducts);
cet::exempt_ptr<ProductTables const> presentProducts_{nullptr};
ModuleDescription md_;
Expand Down
5 changes: 3 additions & 2 deletions art/Framework/Principal/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ namespace art {
using ProductRetriever::getValidHandle;
using ProductRetriever::getView;

using ProductRetriever::getProcessParameterSet;
using ProductRetriever::getProductDescription;
using ProductRetriever::getProductID;
using ProductRetriever::getProductProvenance;

using ProductRetriever::getProcessParameterSet;
using ProductRetriever::getProductID;
using ProductRetriever::productGetter;

// Obsolete interface (will be deprecated)
Expand Down
5 changes: 2 additions & 3 deletions art/Framework/Principal/Principal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ namespace art {
string const& processName = processConfiguration_.processName();
for (auto const& val : processHistory_) {
if (processName == val.processName()) {
throw art::Exception(errors::Configuration)
throw Exception(errors::Configuration)
<< "The process name " << processName
<< " was previously used on these products.\n"
<< "Please modify the configuration file to use a "
Expand Down Expand Up @@ -726,8 +726,7 @@ namespace art {
auto group = getGroupLocal(bd.productID());
assert(group);
if (group->anyProduct() != nullptr) {
throw art::Exception(art::errors::ProductRegistrationFailure,
"Principal::put:")
throw Exception(errors::ProductRegistrationFailure, "Principal::put:")
<< "Problem found during put of " << branchType_
<< " product: product already put for " << bd.branchName() << '\n';
}
Expand Down
19 changes: 18 additions & 1 deletion art/Framework/Principal/ProductRetriever.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace art {
return principal_.productGetter(pid);
}

std::optional<fhicl::ParameterSet>
std::optional<fhicl::ParameterSet const>
ProductRetriever::getProcessParameterSet(std::string const& processName) const
{
std::lock_guard lock{mutex_};
Expand All @@ -74,6 +74,23 @@ namespace art {
end(retrievedProducts_));
}

std::optional<Provenance const>
ProductRetriever::getProductProvenance(ProductID const pid) const
{
auto gqr = principal_.getByProductID(pid);
if (gqr.failed()) {
return std::nullopt;
}

auto group = gqr.result();
if (!group->productProvenance()) {
// This can happen if someone tries to access the provenance
// before the product has been produced.
return std::nullopt;
}
return std::make_optional<Provenance const>(group);
}

cet::exempt_ptr<BranchDescription const>
ProductRetriever::getProductDescription(ProductID const pid) const
{
Expand Down
18 changes: 9 additions & 9 deletions art/Framework/Principal/ProductRetriever.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "art/Framework/Principal/Group.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/ProcessTag.h"
#include "art/Framework/Principal/Provenance.h"
#include "art/Framework/Principal/Selector.h"
#include "art/Framework/Principal/fwd.h"
#include "art/Persistency/Common/GroupQueryResult.h"
Expand Down Expand Up @@ -57,11 +58,6 @@ namespace art {
ProductRetriever& operator=(ProductRetriever const&) = delete;
ProductRetriever& operator=(ProductRetriever&) = delete;

// Miscellaneous functionality
EDProductGetter const* productGetter(ProductID const pid) const;
std::optional<fhicl::ParameterSet> getProcessParameterSet(
std::string const& process) const;

// Product retrieval
template <typename PROD>
PROD const& getProduct(InputTag const& tag) const;
Expand Down Expand Up @@ -156,13 +152,17 @@ namespace art {

std::vector<ProductID> retrievedPIDs() const;

// Product ID and description
template <typename T>
ProductID getProductID(std::string const& instance_name = "") const;

// Miscellaneous functionality
std::optional<Provenance const> getProductProvenance(ProductID) const;
std::optional<fhicl::ParameterSet const> getProcessParameterSet(
std::string const& process) const;
cet::exempt_ptr<BranchDescription const> getProductDescription(
ProductID) const;

EDProductGetter const* productGetter(ProductID const pid) const;
template <typename T>
ProductID getProductID(std::string const& instance_name = "") const;

private:
void recordAsParent_(cet::exempt_ptr<Group const> grp) const;
cet::exempt_ptr<Group const> getContainerForView_(
Expand Down
3 changes: 3 additions & 0 deletions art/Framework/Principal/Results.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ namespace art {
using ProductRetriever::getValidHandle;
using ProductRetriever::getView;

using ProductRetriever::getProcessParameterSet;
using ProductRetriever::getProductDescription;
using ProductRetriever::getProductProvenance;

using ProductRetriever::getProductID;
using ProductRetriever::productGetter;

Expand Down
5 changes: 3 additions & 2 deletions art/Framework/Principal/Run.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ namespace art {
using ProductRetriever::getValidHandle;
using ProductRetriever::getView;

using ProductRetriever::getProcessParameterSet;
using ProductRetriever::getProductDescription;
using ProductRetriever::getProductID;
using ProductRetriever::getProductProvenance;

using ProductRetriever::getProcessParameterSet;
using ProductRetriever::getProductID;
using ProductRetriever::productGetter;

// Obsolete interface (will be deprecated)
Expand Down
4 changes: 3 additions & 1 deletion art/Framework/Principal/SubRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ namespace art {
using ProductRetriever::getView;

Run const& getRun() const;
using ProductRetriever::getProcessParameterSet;
using ProductRetriever::getProductDescription;
using ProductRetriever::getProductID;
using ProductRetriever::getProductProvenance;

using ProductRetriever::getProductID;
using ProductRetriever::productGetter;

// Obsolete interface (will be deprecated)
Expand Down
12 changes: 11 additions & 1 deletion art/test/Framework/Principal/Event_t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,21 @@ BOOST_AUTO_TEST_CASE(getByProductID)
BOOST_TEST(h.isValid());
BOOST_TEST(h.id() == wanted);
BOOST_TEST(h->value == 1);
{
auto prov = currentEvent_.getProductProvenance(wanted);
BOOST_TEST(prov.has_value());
BOOST_TEST(*h.provenance() == *prov);
}

ProductID const notpresent{};
BOOST_TEST_REQUIRE(!currentEvent_.get(notpresent, h));
BOOST_TEST(!h.isValid());
BOOST_TEST(h.failedToGet());
BOOST_CHECK_THROW(*h, cet::exception);
{
auto prov = currentEvent_.getProductProvenance(notpresent);
BOOST_TEST(!prov.has_value());
}
}

BOOST_AUTO_TEST_CASE(transaction)
Expand All @@ -469,7 +478,8 @@ BOOST_AUTO_TEST_CASE(transaction)
// commitProducts, there is no product in the EventPrincipal
// afterwards.
BOOST_TEST(principal_->size() == 6u);
currentEvent_.put(product_with_value(3), "int1");
auto pH = currentEvent_.put(product_with_value(3), "int1");
BOOST_TEST(!currentEvent_.getProductProvenance(pH.id()));
BOOST_TEST(principal_->size() == 6u);
}

Expand Down
4 changes: 2 additions & 2 deletions ups/product_deps
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ perllib product_dir
#
####################################
product version qual flags <table_format=2>
canvas v3_13_00 -
canvas v3_13_01 -
catch v2_13_7 - only_for_build
cetmodules v3_07_00 - only_for_build
cetmodules v3_08_00 - only_for_build
range v3_0_11_0b - only_for_build
end_product_list
####################################
Expand Down

0 comments on commit fe3131d

Please sign in to comment.