-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible bug in ldmx root #1169
Comments
To add some more context, as implied by the example input file, this is being run on SLAC SDF which uses I tried to replicate this error on my computer which uses // file test.C
int test(std::string path) {
std::cout << path << std::endl;
return 0;
} to check various things (the -l flag drops the root banner and the -q flag exits after running the macro)
Using the same test macro, I can confirm the bug on SDF:
|
In the meantime...While waiting for this bug to be patched, I have a quick alternative. Write a wrapper script to run root inside the container. This skips one of the levels of bash deduction so it makes things easier. #!/bin/bash
# This simple bash script is merely here to pass the root running into the container
# ldmx ./this-file.sh /path/to/file.root
# make sure to make this file executable with `chmod +x this-file.sh`
root "macro.C(\"$1\")" |
Unfortunately, this appears to be a
which I can confirm by running
|
hi @DhruvanshuSan , i don’t know what @tomeichlersmith and you discussed outside of this thread, but since I was a bit surprised by your quotation mark placement, I just tried your command from the original issue (using some random macro I had lying around) with my local install of root: $ root -l -q myTestMacro.C'\(\"/path/to/file.root\"\)'
Warning in <TApplication::GetOptions>: macro myTestMacro.C\ not found and without the $ root -l -q 'myTestMacro.C('"/path/to/file.root"')'
Processing myTestMacro.C(/path/to/file.root)...
input_line_21:2:14: error: expected expression
myTestMacro(/path/to/file.root) /* invoking function corresponding to '.x' */
^
input_line_21:2:15: error: use of undeclared identifier 'path'
myTestMacro(/path/to/file.root) /* invoking function corresponding to '.x' */
^
input_line_21:2:20: error: use of undeclared identifier 'to'
myTestMacro(/path/to/file.root) /* invoking function corresponding to '.x' */
^
input_line_21:2:23: error: use of undeclared identifier 'file'
myTestMacro(/path/to/file.root) /* invoking function corresponding to '.x' */
^ while if I use slashes and the placement I typically use (note: ` surrounds the whole file name and function arguments) , I see what I would expect: $ root -l -q 'myTestMacro.C('\"/path/to/file.root\"')'
Processing myTestMacro.C("/path/to/file.root")...
Error in <TFile::TFile>: file /path/to/file.root does not exist
... |
Thank you for the additional escape sequences to try @bryngemark - I did not think of those! |
Hi @bryngemark, thanks for the additional input. To be fair, yesterday @tomeichlersmith and I were just playing around with different escape sequences to get rid of the bash unexpected token error. I tried the suggestions which you gave and I am also able to run macro outside container with your last suggestion (approach 2) : Also, I was able to reproduce the same error (macro not found error) when I typed it this way (approach 1): So in a sense, it is something weird. When we go for approach 1 as we were trying yesterday, it accepts the command giving the error as described in the main bug report inside the container but gives the So @tomeichlersmith, I am not sure if root version also has something to do with it in addition to the singularity issue. My personal pc has root version 6.24/02 and docker and hence it runs smoothly on my pc. And I recall that you mentioned the container has root version 6.22/08 and singularity container configuration. @bryngemark, to give more context, I was trying to run SLURM job scripts on sdf machine to run the mip response macro on multiple files and it was unable to find root in SLURM. Hence the solution was to run it inside the container and that is where all this trouble started. |
hi both, so it looks like we need different sets of escape sequences for running locally, with docker, and with singularity, which in ROOT should translate to locally this works: with docker I have to do $ ldmx root -l -q 'myTestMacro.C\(\"/path/to/file.root\"\)'
Processing myTestMacro.C("/path/to/file.root")... and with singularity we need... @tomeichlersmith's patch wrapper? I have run root macros with singularity before, on SLAC LSBatch, for instance the gain extraction macro used earlier on in the processing chain that @DhruvanshuSan is working on. @DhruvanshuSan are you using that same set of bash scripts (perhaps modified) that I have shared in the repo? |
Hi @bryngemark , so I do am using slightly modified versions of the root macros which you shared in the repo. I am not using the bash scripts shared by you in the repo (I am assuming you talking about this one : https://github.com/DhruvanshuSan/TrigScint/blob/trunk/util/runReformatting.sh) I made a simple bash script to run the macro which has commands of the type Note the above bash script format is not yet tested on the escape sequences suggested here. Btw @bryngemark , did you try the escape sequences inside ldmx container on the sdf machine? |
yes that's the bash script i'm referring to. i ran it on the LS batch queues, so not with slurm on sdf, with singularity. running the command the way it's done that script might help us further to disentangle what's going on. |
Ok, I can try to run that bash script on sdf machine to check. So what nature of input does the script asks for? Is it like a text file with list of commands of the type |
@DhruvanshuSan it is this script: https://github.com/LDMX-Software/TrigScint/blob/56ceac8786421e2f4bbdabc5059d665af80cf002/util/runReformatting.sh The only non-optional argument is a .txt file that lists input files to run the reformatting on. However you don't need to execute the full chain. Take the command line used for ROOT macro running on e.g. root -l -b -q ''$configDir'/../util/extractPedsAndGains.C+("'${linearRootFile}'", '${deadChannel}', "conv", '${logVerbosity}')' that you can see here as inspiration and run just that line, or start from a reformatted .root file, or so. |
Hi @bryngemark & @tomeichlersmith , I figured out a way to get rid of the issues we facing so far. One can try the following bash script :
So the trick which worked is to run the macro inside the container in interactive mode and pass the argument to the macro via "here document" input redirection bash routine. I also modified my SLURM script to incorporate this :
where And this works as expected. I tested my SLURM job array script and it processed all the files as expected. Location of SLURM script on my device: /sdf/group/ldmx/users/dhparmar/TrySLURM.sh Please let me know if the above scripts are working for you guys as well. |
Thank you @DhruvanshuSan , I've added this solution to the FAQ on the website and linked back to this issue for anyone searching for more context. |
Describe the bug
When I try to run a root macro inside container, the root is unable to read the path of the input file properly. However, outside container it runs properly.
To Reproduce
Steps to reproduce the behavior:
source ldmx-env.sh
ldmx root -l -q extractResponse_v3.C'\(\"/path/to/file.root\"\)'
-bash-4.2$ ldmx root -l -q extractResponse_v3.C'\(\"/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root\"\)' INFO: /etc/singularity/ exists; cleanup by system administrator is not complete (see https://apptainer.org/docs/admin/latest/singularity_migration.html)
Processing extractResponse_v3.C(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root)... input_line_17:2:21: error: expected expression extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:22: error: use of undeclared identifier 'sdf' extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:26: error: use of undeclared identifier 'group' extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:32: error: use of undeclared identifier 'ldmx' extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:37: error: use of undeclared identifier 'users' extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:43: error: use of undeclared identifier 'dhparmar' extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:52: error: use of undeclared identifier 'datafiles' extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:62: error: use of undeclared identifier 'LDMX_RAWData' extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:75: error: use of undeclared identifier 'hits' extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:80: error: use of undeclared identifier 'unpacked_reprocessed_ldmx_captan_out_07' extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:127: error: no matching literal operator for call to 'operator""_12' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^ input_line_17:2:136: error: no matching literal operator for call to 'operator""__41_digi_linearize_hits.root' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template extractResponse_v3(/sdf/group/ldmx/users/dhparmar/datafiles/LDMX_RAWData/hits/unpacked_reprocessed_ldmx_captan_out_07-04-2022_12-22-00__41_digi_linearize_hits.root) /* '.x' tries to invoke a func... ^
Desired behavior
The macro is supposed to take the file as input and process it.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment:
ldmx-container-config
Additional context
We are giving the path in a different manner than what you would normally give because inside container it gives a bash error due to parentheses not recognized (it is a common unexpected token error). I discussed this issue with @tomeichlersmith on slack, he helped me to get rid of the bash error but we were not able to resolve the error of not able to read path properly.
The text was updated successfully, but these errors were encountered: