ganga-devs / ganga

Ganga is an easy-to-use frontend for job definition and management
GNU General Public License v3.0
98 stars 159 forks source link

Root() application doesn't handle arguments correctly #37

Closed olupton closed 4 years ago

olupton commented 8 years ago

Since 6.1.13 I can't use the Root() application, as the generated command does not seem to escape the arguments properly.

In [455]:n.submit()
Ganga.GPIDev.Lib.Job               : INFO     submitting job 531
Ganga.GPIDev.Lib.Job               : INFO     job 531 status changed to "submitting"
Ganga.Lib.Root                     : INFO     Created shared directory: conf-135d3b33-2af2-4db8-b832-bcd2357f6c4b
Ganga.GPIDev.Adapters              : INFO     Sending file object /home/lupton/Kshh_svn/proctuples/makechain.cpp to shared directory
Ganga.GPIDev.Lib.Job               : INFO     Preparing subjobs
Ganga.Lib.Root                     : INFO     rootsys: /cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_79/ROOT/6.04.02/x86_64-slc6-gcc48-opt
Ganga.GPIDev.Adapters              : INFO     submitting job 531 to Interactive backend
Ganga.Lib.Interactive              : INFO     Starting job 531
Ganga.GPIDev.Lib.Job               : INFO     job 531 status changed to "submitted"
   ------------------------------------------------------------
  | Welcome to ROOT 6.04/02                http://root.cern.ch |
  |                               (c) 1995-2014, The ROOT Team |
  | Built for linuxx8664gcc                                    |
  | From tag v6-04-02, 14 July 2015                            |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------
root [0]
Processing makechain.cpp(task-ddfix-MC.txt,D2KSHH_merged_PPLL-task-ddfix-MC,PPLL,/data/lhcb/users/lupton/akepahome/olupton/gangadir61/workspace/olupton/LocalXML/)...
input_line_15:2:12: error: use of undeclared identifier 'task'
 makechain(task-ddfix-MC.txt,D2KSHH_merged_PPLL-task-ddfix-MC,PPLL,/data/lhcb/users/lupton/akepahome/olupton/gangadir61/workspace/olupton/LocalXML/) /* invoking function corresponding to '.x' */
           ^
input_line_15:2:17: error: use of undeclared identifier 'ddfix'
 makechain(task-ddfix-MC.txt,D2KSHH_merged_PPLL-task-ddfix-MC,PPLL,/data/lhcb/users/lupton/akepahome/olupton/gangadir61/workspace/olupton/LocalXML/) /* invoking function corresponding to '.x' */
                ^

....this carries on for many lines. Clearly the (string) argument is being interpreted as C++.

This test used the Interactive backend, and:

In [456]:n.application
Out[456]: Root (
 is_prepared = ShareDir(name='conf-135d3b33-2af2-4db8-b832-bcd2357f6c4b',subdir='.') ,
 args = [task-ddfix-MC.txt, D2KSHH_merged_PPLL-task-ddfix-MC, PPLL, /data/lhcb/users/lupton/akepahome/olupton/gangadir61/workspace/olupton/LocalXML/]  ,
 version = '6.04.02' ,
 usepython = False ,
 script = File (
    name = '/home/lupton/Kshh_svn/proctuples/makechain.cpp' ,
    subdir = '.'
    )
 )

As a related question, it is not clear how to pick between compiled (i.e. root script.C+) and interpreted (i.e. root script.C) running. Is this possible?

Thanks, Olli

rob-c commented 8 years ago

@olupton ROOT is a slightly difficult to support Application for a few different reasons. Mostly this is to do with sourcing the environment correctly for the version of ROOT to be requested.

With this in mind. Can you either share what backend you're running or run a report(jobs(xx)) to share the full job configuration so that we can work out what's likely going wrong.

ROOT Dirac support for LHCb is a special case which has had some work done recently and I need to work on adding proper LHCb ROOT support to the other backends such as Batch, Local, etc. We should be making use of SetupProject ROOT v604r2 to get our LHCb ROOT environment but this is incompatible with the experiment neutral Core of Ganga which just wants $ROOTSYS to be defined. We use the SetupProject method with LHCbDirac only so far.

Now for the details:

The ROOT application supports PyROOT and classic CINT(CLANG) scripts. These are always executed in the fashion of:

root.exe myScript.ext(someScriptArgs)

Where the myScript.ext is either a python script or an uncompiled 'interactive' CINT(CLANG) script. The difficulty is in passing the script arguments in a way which captures everything including user strings to the someScriptArgs part of the script. i.e. If the user wants to send the arguments 5 and "foo" passed to the script myScript.C then we have to construct: myScript.C(5, "foo") (Note the use of " here I remember this being important at some stage) The arguments here are assembled and put into a templated script later which means that they're a little fragile atm and are on my long todo list of applications to take a look at.

If you run a report on the job we will hopefully get the script that is trying to be executed it is possible your script either can't be run interactively as an argument to the ROOT executable or that some argument is being mangled in a way that ROOT no longer likes it at runtime

NB: You can make use of ROOT commands from a short wrapper script to execute pre-compiled programs within the ROOT environment when submitting jobs and I've made a lot of use of this approach in the past.

rob-c commented 8 years ago

@olupton As a quick fix defining your arguments as strings should help this, I'm surprised in the application that they're not wrapped in " tags... this may be enough to continue what your doing.

Ganga cannot sensibly auto-add these parentheses to strings as there is a difference between passing 5 and "5" to ROOT scripts which has meant we try to avoid doing anything which could conflict with the users requirements here.

olupton commented 8 years ago

Hi Rob,

I was using the Interactive backend to debug, but the original job used PBS. No Dirac here.

I'm confused by your comment about the types, as python is type-aware. Isn't it trivial to implement j.application.args = [ 5, "name" ] (in python/ganga script) --> root script.C(5, "name") j.application.args = [ "5", "name" ] (in python/ganga script) --> root script.C("5", "name") ?

I did report(), which spat out:

In [486]:report(n)

* Ganga Tasks: Short Introduction and 'Cheat Sheet' *

Definitions: 'Partition' - A unit of processing, for example processing a file or processing some events from a file 'Transform' - A group of partitions that have a common Ganga Application and Backend. 'Task' - A group of one or more 'Transforms' that can have dependencies on each other

Possible status values for partitions:

Important commands: Get a quick overview : tasks Get a detailed view : tasks.table() Access an existing task : t = tasks(id) Remove a Task : tasks(id).remove() Create a new (MC) Task : t = MCTask() Copy a Task : nt = t.copy() Show task configuration : t.info() Show processing status : t.overview() Set the float of a Task : t.float = 100 Set the name of a task : t.name = 'My Own Task v1' Start processing : t.run() Pause processing : t.pause() Access Transform id N : tf = t.transforms[N] Pause processing of tf : tf.pause() # This command is reverted by using t.run() Transform Application : tf.application Transform Backend : tf.backend

Set parameter in all applications : t.setParameter(my_software_version='1.42.0') Set backend for all transforms : t.setBackend(backend) , p.e. t.setBackend(LCG()) Limit on how often jobs are resubmitted : tf.run_limit = 4 Manually change the status of partitions: tf.setPartitionStatus(partition, 'status')

For an ATLAS Monte Carlo Production Example and specific help type: MCTask? For an ATLAS Analysis Example and help type: AnaTask?

To show this help message again, type 'tasks.help()'.

The following is the output of tasks.table() Ganga.Utility : ERROR Ganga.Utility : ERROR An error occured while collecting report information : [Errno 2] No such file or directory: '/data/lhcb/users/lupton/akepahome/olupton/gangadir61/repository/lupton/LocalXML/6.0/jobs/0xxx/531'

Ganga.Utility : ERROR Ganga.Utility : INFO Your error report was uploaded to ganga developers with the following URL. Ganga.Utility : INFO You may include this URL and the following summary information in your bug report or in the support email to the developers. Ganga.Utility : INFO Ganga.Utility : INFO _http://ganga-ai-02.cern.ch/django/errorreports/download/416_ Ganga.Utility : INFO Ganga.Utility : INFO Ganga Version : 6.1.13 Ganga.Utility : INFO Python Version : 2.7.9 Ganga.Utility : INFO Operation System Version : Linux-2.6.32-504.8.1.el6.x86_64-x86_64-with-redhat-6.7-Carbon Ganga.Utility : INFO Application Name : Root Ganga.Utility : INFO Backend Name : Interactive Ganga.Utility : INFO Python Path : /cvmfs/lhcb.cern.ch/lib/lhcb/GANGA/GANGA_v601r13/external/ipython/0.6.13_ganga_patch1/noarch/lib/python:/cvmfs/lhcb.cern.ch/lib/lhcb/GANGA/GANGA_v601r13/external/httplib2/0.8/noarch/python2:/cvmfs/lhcb.cern.ch/lib/lhcb/GANGA/GANGA_v601r13/external/python-gflags/2.0/noarch/python:/cvmfs/lhcb.cern.ch/lib/lhcb/GANGA/GANGA_v601r13/external/google-api-python-client/1.1/noarch/python:/cvmfs/lhcb.cern.ch/lib/lhcb/GANGA/GANGA_v601r13/external/ipython/0.6.13_ganga_patch1/noarch/lib/python:/cvmfs/lhcb.cern.ch/lib/lhcb/GANGA/GANGA_v601r13/external/paramiko/1.7.3/noarch/lib/python2.5/site-packages:/cvmfs/lhcb.cern.ch/lib/lhcb/GANGA/GANGA_v601r13/external/stomputil/2.4/noarch/python:/cvmfs/lhcb.cern.ch/lib/lhcb/GANGA/GANGA_v601r13/external/pycrypto/2.0.1/x86_64-slc6-gcc48-opt/lib/python2.7/site-packages:/cvmfs/lhcb.cern.ch/lib/lcg/releases/LCG_79/ROOT/6.04.02/x86_64-slc6-gcc48-opt/lib:/cvmfs/lhcb.cern.ch/lib/lhcb/LBSCRIPTS/LBSCRIPTS_v8r4p2/InstallArea/python Ganga.Utility : INFO

I'm not sure why the Tasks stuff appeared, and if the upload succeeded given the error message.

Note that the script arguments are strings, ganga just isn't printing them for some reason: In [488]:n.application.args Out[488]: [task-ddfix-MC.txt, D2KSHH_merged_PPLL-task-ddfix-MC, PPLL, /data/lhcb/users/lupton/akepahome/olupton/gangadir61/workspace/olupton/LocalXML/]

In [489]:n.application.args[0] Out[489]: task-ddfix-MC.txt

In [490]:type(n.application.args[0]) Out[490]: <type 'str'>

rob-c commented 8 years ago

@olupton In principle yes it's trivial but it requires some work. The string arguments will need to be protected as they are passed as part of a string object in python so getting the correct and matching quotation marks becomes a bit non-trivial.

I'm very surprised that your args list isn't displaying with " quotation marks, this could be an bug in the presentation of the application within ganga or could be a bug in your code that you've somehow assigned a non-string object somehow (I suspect the latter)

If you suspect that you're arguments are being stripped of their quotation marks then can you try adding in an additional set around the objects at the moment? This could be that we're using a string equivalent rather than a representation of the object.

Are you able to run a ROOT script without arguments on the interactive backend? I'll look into fixing this as part of 6.1.14 as it should be relatively trivial to fix the arguments not being passed correctly if that is the case. As for fixing the environment so that we use SetupProject ROOT correctly this could be a bit more time consuming so I'll look into it but that may get delayed beyond 6.1.14

olupton commented 8 years ago

Hi Rob,

OK, I'll trust you re: how easy it is to keep track of what's a str/int/float.

re: printing quotation marks, this looks like it's just to do with how GangaList renders itself:

In [515]:type(n.application.args) Out[515]: <class 'Ganga.GPIDev.Base.Proxy.GangaList'>

In [516]:list(n.application.args) Out[516]: ['task-ddfix-MC.txt', 'D2KSHH_merged_PPLL-task-ddfix-MC', 'PPLL', '/data/lhcb/users/lupton/akepahome/olupton/gangadir61/workspace/olupton/LocalXML/']

In [517]:n.application.args Out[517]: [task-ddfix-MC.txt, D2KSHH_merged_PPLL-task-ddfix-MC, PPLL, /data/lhcb/users/lupton/akepahome/olupton/gangadir61/workspace/olupton/LocalXML/]

In [518]:[type(x) for x in n.application.args] Out[518]: [<type 'str'>, <type 'str'>, <type 'str'>, <type 'str'>]

I don't think there's any doubt that the args are strings.

I tried: In [521]:nn=n.copy(unprepare=True) In [524]:nn.application.args = ['"%s"'%(x) for x in n.application.args]

But this fails in the same way as before. I did report(nn) and got the URL http://ganga-ai-02.cern.ch/django/errorreports/download/417

It seems to successfully run a script with no arguments.

rob-c commented 8 years ago

This is going to have to be pushed back until 6.1.15 due to the large amount of other changes in 6.1.14 and wanting to push this release out sooner rather than later. Rob

rob-c commented 8 years ago

possibly related to #170