Skip to content

Commit

Permalink
add application name and module name to the file name
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanna Lehmann Miotto committed Aug 14, 2024
1 parent eab8ce9 commit c75738f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
10 changes: 6 additions & 4 deletions include/dfmodules/DataStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@
#define DEFINE_DUNE_DATA_STORE(klass) \
EXTERN_C_FUNC_DECLARE_START \
std::unique_ptr<dunedaq::dfmodules::DataStore> make(const std::string& name, \
std::shared_ptr<dunedaq::appfwk::ModuleConfiguration> mcfg) \
std::shared_ptr<dunedaq::appfwk::ModuleConfiguration> mcfg, \
const std::string& mod_name) \
{ \
return std::unique_ptr<dunedaq::dfmodules::DataStore>(new klass(name, mcfg)); \
return std::unique_ptr<dunedaq::dfmodules::DataStore>(new klass(name, mcfg, mod_name)); \
} \
}

Expand Down Expand Up @@ -149,13 +150,14 @@ class DataStore : public utilities::NamedObject
inline std::unique_ptr<DataStore>
make_data_store(const std::string& type,
const std::string& name,
std::shared_ptr<dunedaq::appfwk::ModuleConfiguration> mcfg)
std::shared_ptr<dunedaq::appfwk::ModuleConfiguration> mcfg,
const std::string& mod_name)
{
static cet::BasicPluginFactory bpf("duneDataStore", "make"); // NOLINT

std::unique_ptr<DataStore> ds;
try {
ds = bpf.makePlugin<std::unique_ptr<DataStore>>(type, name, mcfg);
ds = bpf.makePlugin<std::unique_ptr<DataStore>>(type, name, mcfg, mod_name);
} catch (const cet::exception& cexpt) {
throw DataStoreCreationFailed(ERS_HERE, type, name, cexpt);
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/DataWriterModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ DataWriterModule::do_conf(const data_t&)
try {
m_data_writer = make_data_store(m_data_writer_conf->get_data_store_params()->get_type(),
m_data_writer_conf->get_data_store_params()->UID(),
m_module_configuration);
m_module_configuration,
get_name());
} catch (const ers::Issue& excpt) {
throw UnableToConfigure(ERS_HERE, get_name(), excpt);
}
Expand Down
5 changes: 3 additions & 2 deletions plugins/HDF5DataStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "appmodel/FilenameParams.hpp"
#include "confmodel/DetectorConfig.hpp"
#include "confmodel/Session.hpp"
#include "confmodel/Application.hpp"

#include "appfwk/DAQModule.hpp"
#include "logging/Logging.hpp"
Expand Down Expand Up @@ -112,7 +113,7 @@ class HDF5DataStore : public DataStore
* @param name, path, filename, operationMode
*
*/
explicit HDF5DataStore(std::string const& name, std::shared_ptr<appfwk::ModuleConfiguration> mcfg)
explicit HDF5DataStore(std::string const& name, std::shared_ptr<appfwk::ModuleConfiguration> mcfg, std::string const& mod_name)
: DataStore(name)
, m_basic_name_of_open_file("")
, m_open_flags_of_open_file(0)
Expand All @@ -124,7 +125,7 @@ class HDF5DataStore : public DataStore
m_file_layout_params = m_config_params->get_file_layout_params();
m_session = mcfg->configuration_manager()->session();
m_operational_environment = mcfg->configuration_manager()->session()->get_detector_configuration()->get_op_env();
m_writer_identifier = name;
m_writer_identifier = mcfg->configuration_manager()->application()->UID() + "_" + mod_name;

m_operation_mode = m_config_params->get_mode();
m_path = m_config_params->get_directory_path();
Expand Down
3 changes: 2 additions & 1 deletion plugins/TPStreamWriterModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ TPStreamWriterModule::do_conf(const data_t& )
try {
m_data_writer = make_data_store(m_tp_writer_conf->get_data_store_params()->get_type(),
m_tp_writer_conf->get_data_store_params()->UID(),
m_module_configuration);
m_module_configuration,
get_name());
} catch (const ers::Issue& excpt) {
throw UnableToConfigure(ERS_HERE, get_name(), excpt);
}
Expand Down
4 changes: 2 additions & 2 deletions unittest/DataStoreFactory_test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BOOST_AUTO_TEST_CASE(invalid_request)
{

// we want to pass an invalid DataStore type and see if we get an exception
BOOST_CHECK_THROW(make_data_store("dummy", "dummy", nullptr), DataStoreCreationFailed);
BOOST_CHECK_THROW(make_data_store("dummy", "dummy", nullptr, "dummy_mod"), DataStoreCreationFailed);

}

Expand All @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(valid_request)
conf["name"] = "test" ;

// we want to ask for a valid Data Store type
auto ds = make_data_store( "TrashCanDataStore", conf ) ;
auto ds = make_data_store( "TrashCanDataStore", conf, "TestMod" ) ;

// and we want to check if we created something valid
BOOST_TEST( ds.get() ) ;
Expand Down
10 changes: 5 additions & 5 deletions unittest/HDF5Write_test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE(WriteEventFiles)
data_store_conf_obj.set_by_val<std::string>("mode", "one-event-per-file");

std::unique_ptr<DataStore> data_store_ptr;
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg);
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg, "dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number)
Expand Down Expand Up @@ -208,7 +208,7 @@ BOOST_AUTO_TEST_CASE(WriteOneFile)
data_store_conf_obj.set_by_val<std::string>("directory_path", file_path);

std::unique_ptr<DataStore> data_store_ptr;
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg);
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg, "dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number)
Expand Down Expand Up @@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(CheckWritingSuffix)
data_store_conf_obj.set_by_val<std::string>("directory_path", file_path);

std::unique_ptr<DataStore> data_store_ptr;
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg);
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg, "dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number) {
Expand Down Expand Up @@ -300,7 +300,7 @@ BOOST_AUTO_TEST_CASE(FileSizeLimitResultsInMultipleFiles)
data_store_conf_obj.set_by_val<int>("max_file_size", 3000000); // goal is 6 events per file

std::unique_ptr<DataStore> data_store_ptr;
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg);
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg, "dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number)
Expand Down Expand Up @@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(SmallFileSizeLimitDataBlockListWrite)
data_store_conf_obj.set_by_val<int>("max_file_size", 150000); // ~1.5 Fragment, ~0.3 TR

std::unique_ptr<DataStore> data_store_ptr;
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg);
data_store_ptr = make_data_store(data_store_conf->get_type(), data_store_conf->UID(), cfg.modCfg, "dwm-01");

// write several events, each with several fragments
for (int trigger_number = 1; trigger_number <= trigger_count; ++trigger_number)
Expand Down

0 comments on commit c75738f

Please sign in to comment.