LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::FileCatalogOptionsHandler Class Reference

#include "FileCatalogOptionsHandler.h"

Inheritance diagram for art::FileCatalogOptionsHandler:
art::OptionsHandler

Public Member Functions

 FileCatalogOptionsHandler (bpo::options_description &desc)
 
int checkOptions (bpo::variables_map const &vm)
 
int processOptions (bpo::variables_map const &vm, fhicl::intermediate_table &raw_config)
 

Private Member Functions

int doCheckOptions (bpo::variables_map const &vm) override
 
int doProcessOptions (bpo::variables_map const &vm, fhicl::intermediate_table &raw_config) override
 

Private Attributes

std::string appFamily_
 
std::string appVersion_
 

Detailed Description

Definition at line 14 of file FileCatalogOptionsHandler.h.

Constructor & Destructor Documentation

art::FileCatalogOptionsHandler::FileCatalogOptionsHandler ( bpo::options_description &  desc)
explicit

Definition at line 179 of file FileCatalogOptionsHandler.cc.

References art::add_opt(), appFamily_, appVersion_, and fhicl::detail::atom::value().

181  : appFamily_{}, appVersion_{}
182 {
183  bpo::options_description sam_options{"SAM options"};
184  auto options = sam_options.add_options();
185  add_opt(
186  options, "sam-web-uri", bpo::value<string>(), "URI for SAM web service.");
187  add_opt(options, "sam-process-id", bpo::value<string>(), "SAM process ID.");
188  add_opt(options,
189  "sam-application-family",
190  bpo::value<string>(&appFamily_),
191  "SAM application family.");
192  add_opt(options,
193  "sam-app-family",
194  bpo::value<string>(&appFamily_),
195  "SAM application family.");
196  add_opt(options,
197  "sam-application-version",
198  bpo::value<string>(&appVersion_),
199  "SAM application version.");
200  add_opt(options,
201  "sam-app-version",
202  bpo::value<string>(&appVersion_),
203  "SAM application version.");
204  add_opt(options, "sam-group", bpo::value<string>(), "SAM group.");
205  add_opt(options,
206  "sam-file-type",
207  bpo::value<string>(),
208  "File type for SAM metadata.");
209  add_opt(options,
210  "sam-data-tier",
211  bpo::value<vector<string>>(),
212  "SAM data tier (<spec-label>:<tier-spec>).");
213  add_opt(options,
214  "sam-run-type",
215  bpo::value<string>(),
216  "Global run-type for SAM metadata.");
217  add_opt(options,
218  "sam-stream-name",
219  bpo::value<vector<string>>(),
220  "SAM stream name (<module-label>:<stream-name>).");
221  add_opt(options,
222  "sam-inherit-metadata",
223  "Input file provides the file type and run type.");
224  add_opt(
225  options, "sam-inherit-file-type", "Input file provides the file type.");
226  add_opt(options, "sam-inherit-run-type", "Input file provides the run type.");
227  desc.add(sam_options);
228 }
void add_opt(T &t, Args &&...args)
std::string value(boost::any const &)

Member Function Documentation

int art::OptionsHandler::checkOptions ( bpo::variables_map const &  vm)
inherited

Definition at line 51 of file OptionsHandler.cc.

52 {
53  std::string const thisClass(cet::demangle_symbol(typeid(*this).name()));
54  return exceptionCatcher([&vm, this] { return doCheckOptions(vm); },
55  thisClass + "::doCheckOptions()",
56  89);
57 }
virtual int doCheckOptions(bpo::variables_map const &vm)=0
int art::FileCatalogOptionsHandler::doCheckOptions ( bpo::variables_map const &  vm)
overrideprivatevirtual

Implements art::OptionsHandler.

Definition at line 231 of file FileCatalogOptionsHandler.cc.

232 {
233  // Checks can't be done until after post-processing.
234  return 0;
235 }
int art::FileCatalogOptionsHandler::doProcessOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
overrideprivatevirtual

Implements art::OptionsHandler.

Definition at line 238 of file FileCatalogOptionsHandler.cc.

References appFamily_, appVersion_, art::errors::Configuration, art::ensureTable(), fhicl::intermediate_table::erase(), art::detail::exists_outside_prolog(), art::detail::fhicl_key(), fhicl::intermediate_table::get(), and fhicl::intermediate_table::put().

241 {
242  std::string const services{"services"};
243  auto const& ciLocation = fhicl_key(services, "CatalogInterface");
244  auto const& ftLocation = fhicl_key(services, "FileTransfer");
245  auto const& fcmdLocation = fhicl_key(services, "FileCatalogMetadata");
246 
248  // Load up the configuration with command-line options.
249  //
250  // sam-web-uri and sam-process-id.
251  if (vm.count("sam-web-uri") > 0) {
252  raw_config.put(fhicl_key(ciLocation, "webURI"),
253  vm["sam-web-uri"].as<string>());
254  }
255  if (vm.count("sam-process-id") > 0) {
256  // Sequence.
257  raw_config.put("source.fileNames",
258  vector<string>{vm["sam-process-id"].as<string>()});
259  // Atom.
260  raw_config.put(fhicl_key(fcmdLocation, "processID"),
261  vm["sam-process-id"].as<string>());
262  }
263  if (exists_outside_prolog(raw_config, fhicl_key(ciLocation, "webURI")) !=
265  raw_config, fhicl_key(fcmdLocation, "processID"))) { // Inconsistent.
267  << "configurations " << fhicl_key(ciLocation, "webURI")
268  << " (--sam-web-uri) and\n"
269  << fhicl_key(fcmdLocation, "processID")
270  << " (--sam-process-id) must be specified\n"
271  << "together or not at all.\n";
272  }
273  bool const wantSAMweb{
274  exists_outside_prolog(raw_config, fhicl_key(ciLocation, "webURI")) &&
275  exists_outside_prolog(raw_config, "source.fileNames")};
276  // Other metadata items.
277  if (!appFamily_.empty()) {
278  raw_config.put(fhicl_key(fcmdLocation, "applicationFamily"), appFamily_);
279  }
280  if (vm.count("sam-group") > 0) {
281  raw_config.put(fhicl_key(fcmdLocation, "group"),
282  vm["sam-group"].as<string>());
283  }
284  if (!appVersion_.empty()) {
285  raw_config.put(fhicl_key(fcmdLocation, "applicationVersion"), appVersion_);
286  }
287 
288  check_metadata_options(vm);
289 
290  string const mdFromInput{"metadataFromInput"};
291  bool specifyDataTier{false}; // The output module needs a
292  // 'dataTier' if "fileType" is
293  // provided either by the input file
294  // or as a configuration parameter.
295  if (vm.count("sam-inherit-metadata") > 0) {
296  raw_config.put(fhicl_key(fcmdLocation, mdFromInput),
297  vector<string>{"fileType", "runType"});
298  specifyDataTier = true;
299  raw_config.erase(fhicl_key(fcmdLocation, "fileType"));
300  raw_config.erase(fhicl_key(fcmdLocation, "runType"));
301  } else {
302  vector<string> md;
303  if (vm.count("sam-inherit-file-type") > 0) {
304  md.emplace_back("fileType");
305  specifyDataTier = true;
306  raw_config.erase(fhicl_key(fcmdLocation, "fileType"));
307  }
308  if (vm.count("sam-inherit-run-type") > 0) {
309  md.emplace_back("runType");
310  raw_config.erase(fhicl_key(fcmdLocation, "runType"));
311  }
312  if (!md.empty()) {
313  raw_config.put(fhicl_key(fcmdLocation, mdFromInput), md);
314  }
315  }
316 
317  if (vm.count("sam-run-type") > 0) {
318  raw_config.put(fhicl_key(fcmdLocation, "runType"),
319  vm["sam-run-type"].as<string>());
320  }
321  if (vm.count("sam-file-type") > 0) {
322  raw_config.put(fhicl_key(fcmdLocation, "fileType"),
323  vm["sam-file-type"].as<string>());
324  }
325  bool const requireMetadata =
326  have_outputs(raw_config) &&
327  (wantSAMweb ||
328  exists_outside_prolog(raw_config,
329  fhicl_key(fcmdLocation, "applicationFamily")) ||
330  exists_outside_prolog(raw_config,
331  fhicl_key(fcmdLocation, "applicationVersion")) ||
332  exists_outside_prolog(raw_config, fhicl_key(fcmdLocation, "group")) ||
333  exists_outside_prolog(raw_config, fhicl_key(fcmdLocation, "fileType")) ||
334  specifyDataTier);
335 
336  if (requireMetadata) {
337  fill_tiers_streams(vm, raw_config);
338  maybeThrowOnMissingMetadata(raw_config);
339  }
340 
341  string process_name;
342  if (exists_outside_prolog(raw_config, "process_name")) {
343  process_name = raw_config.get<string>("process_name");
344  }
345  if (requireMetadata && process_name.empty()) {
347  << "Non-empty / default process_name required for SAM metadata.\n";
348  }
349  if (wantSAMweb) {
350  raw_config.put(fhicl_key(ciLocation, "service_provider"),
351  "IFCatalogInterface");
352  raw_config.put(fhicl_key(ftLocation, "service_provider"), "IFFileTransfer");
353  art::ensureTable(raw_config, fhicl_key(services, "IFDH"));
354  }
355  return 0;
356 }
bool exists_outside_prolog(fhicl::intermediate_table const &config, std::string const &key)
void erase(std::string const &name, bool in_prolog=false)
void ensureTable(fhicl::intermediate_table &table, std::string const &fhicl_spec)
Definition: ensureTable.cc:6
bool put(std::string const &name, std::string const &value, bool in_prolog=false)
std::enable_if_t< std::is_convertible< T, std::string >::value, std::string > fhicl_key(T const &name)
Definition: fhicl_key.h:13
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
T get(std::string const &name)
int art::OptionsHandler::processOptions ( bpo::variables_map const &  vm,
fhicl::intermediate_table raw_config 
)
inherited

Definition at line 60 of file OptionsHandler.cc.

Referenced by art::run_art_string_config().

62 {
63  std::string const thisClass(cet::demangle_symbol(typeid(*this).name()));
64  return exceptionCatcher(
65  [&, this] { return doProcessOptions(vm, raw_config); },
66  thisClass + "::doProcessOptions()",
67  90);
68 }
virtual int doProcessOptions(bpo::variables_map const &vm, fhicl::intermediate_table &raw_config)=0

Member Data Documentation

std::string art::FileCatalogOptionsHandler::appFamily_
private

Definition at line 26 of file FileCatalogOptionsHandler.h.

Referenced by doProcessOptions(), and FileCatalogOptionsHandler().

std::string art::FileCatalogOptionsHandler::appVersion_
private

Definition at line 27 of file FileCatalogOptionsHandler.h.

Referenced by doProcessOptions(), and FileCatalogOptionsHandler().


The documentation for this class was generated from the following files: