Load libFCCAnalysesFlavour package when running in batch

Hi,

I am trying to run my analysis code in batch mode. I can run it fine locally, but when I try it with condor, I get this error:

Warning in <TInterpreter::ReadRootmapFile>: class  edm4hep::ObjectID found in libedm4hepDict.so  is already in libedm4drDict.so 
Error in <TUnixSystem::FindDynamicLibrary>: libFCCAnalysesFlavour[.so | .dll | .dylib | .sl | .dl | .a] does not exist in /afs/cern.ch/user/h/helsens/FCCsoft/HEP-FCC/FCCeePhysicsPerformance/case-
studies/flavour/dataframe/install/lib:/cvmfs/sw.hsf.org/spackages5/py-awkward/1.4.0/x86_64-centos7-gcc11.2.0-opt/ee337/lib/python3.9/site-packages/awkward:/afs/cern.ch/user/h/helsens/FCCsoft/HEP-
FCC/FCCAnalyses/install/lib:/cvmfs/sw.hsf.org/spackages5/key4hep-stack/2022-03-30/x86_64-centos7-gcc11.2.0-opt/mrwoj/lib64:/cvmfs/sw.hsf.org/spackages5/key4hep-stack/2022-03-30/x86_64-centos7-gcc
11.2.0-opt/mrwoj/lib:/cvmfs/sw.hsf.org/spackages5/xgboost/1.5.2/x86_64-centos7-gcc11.2.0-opt/6ptqk/lib64:
... 
#not copying the whole path, but let me know if you need it
Traceback (most recent call last):
  File "/afs/cern.ch/work/j/jalimena/FCCeeLLP/FCCeePhysicsPerformance/case-studies/BSM/LLP/DisplacedHNL/analysis_general.py", line 21, in <module>
    _HNL   = ROOT.dummyLoaderFlavour #### Needed to fix undeclared selMC_leg()
  File "/cvmfs/sw.hsf.org/spackages5/root/6.26.00/x86_64-centos7-gcc11.2.0-opt/jx56q/lib/ROOT/_facade.py", line 195, in _fallback_getattr
    raise AttributeError("Failed to get attribute {} from ROOT".format(name))
AttributeError: Failed to get attribute dummyLoaderFlavour from ROOT

It seems to me that condor can’t find the libFCCAnalysesFlavour package, but when I run locally, it can find it just fine. How do I tell condor to load this package? Is there something I can do in my batch submission script?

My batch submission script is here:

And my analysis code is here:

Thanks for any suggestions.

Juliette

hello @jalimena ,

this is very timely as I have just re-written all the procedure. For this you will have to use my branch and this will help me if you can give it a try:

Please note that the preSel.py has gone and things have been re-arranged for ease of use (at least I believe that is the case :wink: )

I have started to change the instructions, but they are not yet finalised, but they should help you getting started.
Please try to run locally some test samples before going on batch. In principle the ENV is sent to batch, thus if the PATH are locally working fine, they should also with batch (I tested this with my local FCCAnalyses, but not including an extra package as you do, thus I would be interested to see if it works out of the box)
Clement

1 Like

Ok thanks, @clement.helsens ! So do you suggest I check out your branch of FCCAnalyses, link my FCCeePhysicsPerformance to it with

cmake .. -DCMAKE_INSTALL_PREFIX=../install -DFCCANALYSES_INCLUDE_PATH=<my_Complete_Path_to>/FCCAnalyses/install/include/FCCAnalyses/

and try to run my scripts locally and if that works, in batch as well? Just to make sure that’s the workflow you suggest I try? thanks again!

yes, this is correct.
Please let me know (maybe on mattermost as it has nothing to do with this post) if instructions are understandable

EDIT:
I replied too quickly, what you should do in addition to compile FCCeePP linking the new FCCAnalyses is to make sure you have the ENV var well setup like here:

1 Like

ah ha, I had

export ROOT_INCLUDE_PATH=$PWD/install/include/FCCAnalyses:$ROOT_INCLUDE_PATH

instead, maybe that was my mistake, let’s see

hi @clement.helsens , I think you have a mistake in your

I try/get:

$ cd FCCAnalyses/examples/FCCee/higgs/mH-recoil/mumu
$ python /afs/cern.ch/work/j/jalimena/FCCeeLLP/FCCAnalyses/config/FCCAnalysisRun.py  analysis_stage1_batch.py 
Warning in <TInterpreter::ReadRootmapFile>: class  edm4hep::ObjectID found in libedm4hepDict.so  is already in libedm4drDict.so 
----> Load cxx analyzers from libFCCAnalyses... 
----> yaml file /afs/cern.ch/work/h/helsens/public/FCCDicts/yaml/FCCee/spring2021/IDEA/p8_ee_ZZ_ecm240/merge.yaml succesfully opened
----> Running process p8_ee_ZZ_ecm240 with fraction=1, output=p8_ee_ZZ_ecm240, chunks=20
----> Running on Batch
Traceback (most recent call last):
  File "/afs/cern.ch/work/j/jalimena/FCCeeLLP/FCCAnalyses/config/FCCAnalysisRun.py", line 463, in <module>
    sendToBatch(foo, chunkList, process, analysisFile)
  File "/afs/cern.ch/work/j/jalimena/FCCeeLLP/FCCAnalyses/config/FCCAnalysisRun.py", line 230, in sendToBatch
    localDir = os.environ["LOCAL_DIR"]
  File "/cvmfs/sw.hsf.org/spackages5/python/3.9.10/x86_64-centos7-gcc11.2.0-opt/7j5vq/lib/python3.9/os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'LOCAL_DIR'

I guess you meant to define a localDir instead of an outputDir in this file?

hello @jalimena

no, this this an ENVVAR, see:

whoops yes i just saw this, my bad. your instructions are clear, I was just going too fast and missed this…

I was able to successfully convert my analysis.py into the new RDFanalysis version, ran it locally, and submitted it to batch. Batch jobs are idle now, I’ll let you know how it goes!

very good! no news good news I guess?

yeah, getting there. for some reason it didn’t quite work out of the box on my script, but it works when I explicitly set more of the event variables in the .sh scripts it generates. but I’ve got it a bit hard-coded now, I’m currently working on making it not hardcoded.

One thing I can say already:
These lines:

don’t work unless you are running your example.

Please let me know what is needed in addition as I was able to run just fine yesterday.

thanks, this was a leftover from my tests such that files are properly copied back from batch to home dir when the output path is not absolute. Will remove them.

Thanks @clement.helsens . I’ve now tried everything I can think of in order to simply and generically modify your FCCAnalysisRun.py such that it works with my local versions of the necessary packages, but I can’t get it to work. Here is how I needed to hard-code it so that it works for me:

         subprocess.getstatusoutput('chmod 777 %s'%(frunname))
         frun.write('#!/bin/bash\n')
+        frun.write('export RUN_DIR=$PWD\n')
+        frun.write('cd /afs/cern.ch/work/j/jalimena/FCCeeLLP/delphes\n')
         frun.write('source /cvmfs/sw.hsf.org/key4hep/setup.sh\n')
+        frun.write('export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH\n')
+        frun.write('export CMAKE_PREFIX_PATH=$PWD/install:$CMAKE_PREFIX_PATH\n')
+        frun.write('export DELPHES_DIR=$PWD/install\n')
+        frun.write('cd ../k4simdelphes\n')
+        frun.write('export LD_LIBRARY_PATH=$PWD/install/lib64:$LD_LIBRARY_PATH\n')
+        frun.write('export PATH=$PWD/install/bin:$PATH\n')
+
+        frun.write('cd /afs/cern.ch/work/j/jalimena/FCCeeLLP/FCCAnalyses\n')
+        frun.write('source ./setup.sh\n')
+        frun.write('cd ../FCCeePhysicsPerformance/case-studies/flavour/dataframe\n')
+        frun.write('source ./localSetup.sh\n')
+
         #frun.write('export PYTHONPATH=$LOCAL_DIR:$PYTHONPATH\n')
         #frun.write('export LD_LIBRARY_PATH=$LOCAL_DIR/install/lib:$LD_LIBRARY_PATH\n')
         #frun.write('export ROOT_INCLUDE_PATH=$LOCAL_DIR/install/include/FCCAnalyses:$ROOT_INCLUDE_PATH\n')
 
+        frun.write('cd $RUN_DIR\n')
         frun.write('mkdir job{}_chunk{}\n'.format(process,ch))

With this, I can successfully run batch jobs, submitting like this:

$ cd /afs/cern.ch/work/j/jalimena/FCCeeLLP/FCCAnalyses
$ source ./setup.sh
$ python config/FCCAnalysisRun.py ../FCCeePhysicsPerformance/case-studies/BSM/LLP/DisplacedHNL/rdfanalysis_general.py

My rdfanalysis_general.py is here:

Any ideas on how to make it work in a generic way? Let me know if I can provide you with anything else. If we can’t figure out how to make it work in a generic, then I guess maybe the best thing is to push your changes as you have them to the main branch, and I make these modifications locally for myself - better than nothing.

Thanks @jalimena , I think the only option we have is to have a set of base common commands in a config file and the possibility for users to pass a custom config file, such that the FCCAnalysisRun remains untouched by users.

1 Like

Yeah that sounds good, thanks. If you set up the machinery, I can test such a custom config file on my side.

thanks for all the work. with the latest changes to FCCAnalyses, particularly [1], my problems are solved. i think we can close this ticket

[1] New run analysis scheme by clementhelsens · Pull Request #140 · HEP-FCC/FCCAnalyses · GitHub