Bug #24003
Python2 Print Syntax in project.py
0%
Description
I just built icaruscode v08_41_00 and I can no longer use project.py to launch grid jobs. The errors are related to the print statements in project.py that have the ancient python2 syntax (no parenthesis). I have tried importing future.print_function and that didn't help. I also tried using the usual python updating software like futurize and 2to3, neither worked for me.
History
#1 Updated by Lynn Garren about 1 year ago
In most cases, editing by hand works.
See this from Chris Green.
With the possible exception of automatic handling of the change to use the Python 3-style print function, I concur. Personally, I use six where appropriate to allow my Python code to work with Python 2.6 all the way through Python 3.7, which is what contributions to Spack must support.
#2 Updated by Ryan Lazur about 1 year ago
I tried fixing it by hand but there are > 200 print statements. Also when I try to run with Python2.7 I get an error related to not being able to find the 'os' library. Also I do not get this issue when I am on the SBND gpvms running sbndcode. Am I doing something incorrectly when setting up new icaruscode?
#3 Updated by Lynn Garren about 1 year ago
From Herb:
I'm working on updating larbatch. If you want to try updating your checked out version, try running the following command. $ cd $MRB_SOURCE/larbatch $ find . -name \*.py -exec 2to3 -w {} \; Note that there are many issues besides just print statements.
#4 Updated by Herbert Greenlee about 1 year ago
Updates for python 3 have been merged to master branch. Now, project.py and other python utilities in larbatch are supposed to be compatible with either python 2 or python 3.
#5 Updated by Marc Mengel about 1 year ago
Updated by Ryan Lazur 5 days ago
Thank you, Herb! That's great.
I pulled the newest branch and am no longer having issues with the code in project.py, but I am running into another (similar) issue:
File "/cvmfs/icarus.opensciencegrid.org/products/icarus/icarusutil/v08_41_00/python/experiment_utilities.py", line 51
raise RuntimeError, 'Missing or invalid metadata for file %s.' % filename
I can run your helpful updating script on the files in icarusutil, but this should probably be fixed upstream.
#6 Updated by Lynn Garren about 1 year ago
- Assignee set to Herbert Greenlee
- Status changed from New to Resolved
Ryan, see Herb's talk at the LArSoft Coordination meeting this morning for more information.
I am resolving this issue.