598{
599 using namespace msgEventLoop;
602 {
604 {
605 const std::string jobELGDir =
data.submitDir +
"/elg";
606 const std::string runShFile = jobELGDir + "/runjob.sh";
607 const std::string mergeShFile = jobELGDir + "/elg_merge";
610
611 const std::string jobDefFile = jobELGDir + "/jobdef.root";
612
613 namespace fs = std::filesystem;
614 std::error_code ec;
615 fs::create_directories(jobELGDir, ec);
616 if (ec) {
617 ANA_MSG_ERROR(
"could not create directory " << jobELGDir <<
": " << ec.message());
618 return StatusCode::FAILURE;
619 }
620
621
622 const auto copyExecutable =
623 [&] (
const std::string& from,
const std::string&
to) ->
StatusCode {
624 std::error_code ec2;
625 fs::copy_file(from, to, fs::copy_options::overwrite_existing, ec2);
626 if (ec2) {
627 ANA_MSG_ERROR(
"could not copy " << from <<
" to " << to <<
": " << ec2.message());
628 return StatusCode::FAILURE;
629 }
630 fs::permissions(to, fs::perms::owner_exec | fs::perms::group_exec |
631 fs::perms::others_exec, fs::perm_options::add, ec2);
632 if (ec2) {
633 ANA_MSG_ERROR(
"could not make " << to <<
" executable: " << ec2.message());
634 return StatusCode::FAILURE;
635 }
636 return StatusCode::SUCCESS;
637 };
638 ANA_CHECK(copyExecutable(runShOrig, runShFile));
639 ANA_CHECK(copyExecutable(mergeShOrig, mergeShFile));
640
641
643
644 if (listToShipToGrid.size()){
646 "Creating symbolic links for additional files or directories to be sent to grid.\n"
647 "For root or heavy files you should also add their name (not the full path) to EL::Job::optUserFiles.\n"
648 "Otherwise prun ignores those files."
649 );
650
651 std::vector<std::string> vect_filesOrDirToShip;
652 for (
auto&& part : std::views::split(listToShipToGrid,
',')) vect_filesOrDirToShip.emplace_back(
part.begin(),
part.end());
653
654 for (const std::string & fileOrDirToShip: vect_filesOrDirToShip){
655 ANA_MSG_INFO ((
"Creating symbolic link for: " +fileOrDirToShip).c_str());
656 const fs::path linkPath =
657 fs::path(jobELGDir) / fs::path(fileOrDirToShip).filename();
658
659 fs::remove(linkPath, ec);
660 fs::create_symlink(fileOrDirToShip, linkPath, ec);
661 if (ec) {
662 ANA_MSG_ERROR(
"could not create symbolic link " << linkPath.string()
663 << " -> " << fileOrDirToShip << ": " << ec.message());
664 return StatusCode::FAILURE;
665 }
666 }
668 }
669
670 const SH::SampleHandler&
sh =
data.job->sampleHandler();
671
672 for (SH::Sample* const sample : sh) {
673 SH::MetaObject& meta = *
sample->meta();
677 std::string outputSampleName = meta.
castString(
"nc_outputSampleName");
678 if (outputSampleName.empty()) {
679 outputSampleName = "user.%nickname%.%in:name%";
680 }
683 meta.
setString(
"nc_writeInputToTxt",
"IN:input.txt");
685 const std::string execstr =
"runjob.sh " +
sample->name();
687 meta.
setString(
"nc_framework",
"EventLoopGrid");
688 }
689
691
693 out !=
data.job->outputEnd(); ++out) {
694 SH::SampleHandler shOut =
outputSH(sh,
out->label());
695 shOut.
save(
data.submitDir +
"/output-" +
out->label());
696 }
697 SH::SampleHandler shHist =
outputSH(sh,
"hist-output");
698 shHist.
save(
data.submitDir +
"/output-hist");
699
701
703
704 sh.save(
data.submitDir +
"/input");
705 data.submitted =
true;
706 }
707 break;
708
710 {
712 }
713 break;
714
715 default:
716 (void) true;
717 }
718 return ::StatusCode::SUCCESS;
719}
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
static SH::MetaObject defaultOpts()
static void processAllInState(const SH::SampleHandler &sh, JobState::Enum state, const size_t nThreads)
static std::string outputFileNames(const EL::Job &job)
static std::string formatOutputName(const SH::MetaObject &sampleMeta, const std::string &pattern)
static void saveJobDef(const std::string &fileName, const EL::Job &job, const SH::SampleHandler &sh)
static SH::SampleHandler outputSH(const SH::SampleHandler &in, const std::string &outputLabel)
virtual::StatusCode doManagerStep(Detail::ManagerData &data) const
const OutputStream * outputIter
static const std::string optGridPrunShipAdditionalFilesOrDirs
Enables to ship additional files to the tarbal sent to the grid Should be a list of comma separated p...
::StatusCode doRetrieve(Detail::ManagerData &data) const
void save(const std::string &directory) const
save the list of samples to the given directory
@ doRetrieve
call the actual doRetrieve method
@ submitJob
do the actual job submission
::StatusCode StatusCode
StatusCode definition for legacy code.