Merge lp:~maddevelopers/mg5amcnlo/launch_madevent into lp:~maddevelopers/mg5amcnlo/combine_070

Proposed by Olivier Mattelaer
Status: Merged
Merged at revision: 91
Proposed branch: lp:~maddevelopers/mg5amcnlo/launch_madevent
Merge into: lp:~maddevelopers/mg5amcnlo/combine_070
Diff against target: 67 lines (+16/-1) (has conflicts)
3 files modified
madgraph/interface/cmd_interface.py (+6/-0)
madgraph/interface/launch_ext_program.py (+7/-1)
madgraph/iolibs/misc.py (+3/-0)
Text conflict in madgraph/interface/cmd_interface.py
To merge this branch: bzr merge lp:~maddevelopers/mg5amcnlo/launch_madevent
Reviewer Review Type Date Requested Status
Johan Alwall (community) Needs Fixing
Review via email: mp+53434@code.launchpad.net

Description of the change

add the launch command in order to run madevent/standalone from the mg5 command line interface.

To post a comment you must log in.
Revision history for this message
Johan Alwall (johan-alwall) wrote :

Hello Olivier,

At the moment, this doesn't seem to work at all:

mg5>launch PROC_sm_0
Command "launch PROC_sm_0" interrupted with error:
KeyError : 'EDITOR'
Please report this bug on https://bugs.launchpad.net/madgraph5
Traceback (most recent call last):
  File "/Users/alwall/MadGraph/launch_madevent/madgraph/interface/extended_cmd.py", line 151, in onecmd
    return cmd.Cmd.onecmd(self, line)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/cmd.py", line 219, in onecmd
    return func(arg)
  File "/Users/alwall/MadGraph/launch_madevent/madgraph/interface/cmd_interface.py", line 2215, in do_launch
    ext_program = launch_ext.MELauncher(args[1], self.timeout, **options)
  File "/Users/alwall/MadGraph/launch_madevent/madgraph/interface/launch_ext_program.py", line 177, in __init__
    ExtLauncher.__init__(self, running_dir, './Cards', timeout, **option)
  File "/Users/alwall/MadGraph/launch_madevent/madgraph/interface/launch_ext_program.py", line 44, in __init__
    self.found_editor()
  File "/Users/alwall/MadGraph/launch_madevent/madgraph/interface/launch_ext_program.py", line 57, in found_editor
    if os.environ['EDITOR']:
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/UserDict.py", line 22, in __getitem__
    raise KeyError(key)
KeyError: 'EDITOR'

Also, after this error, it's impossible to exit MG5 (except by pressing Ctrl-c)

Johan

review: Needs Fixing
Revision history for this message
Johan Alwall (johan-alwall) wrote :

In fact, it's not possible to exit mg5 even before this error is thrown, with quit, exit, or Ctrl-d (only Ctrl-c works).

Revision history for this message
Johan Alwall (johan-alwall) wrote :

By setting the environment variable EDITOR, I got it to work. Very nice implementation!
Very cool that it asks for the number of cores when running with multicore.
I haven't tested with cluster running, but I'm sure it also works just fine.

Suggestion:
- If EDITOR is not set, ask for user preference, and store this somewhere so you don't need to ask again (e.g. in a $HOME/.mg5preferences file)

Other comments:
The only other major problem I have found is that it's impossible to exit from MG5, as I mentioned above. Also of course path completion doesn't work, but I assume that's just because this branch doesn't have that fixed yet.

Cheers,
Johan

review: Needs Fixing
86. By Olivier Mattelaer

fix problem if EDITOR is not define.
fix the Ctr-D problem

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote :

I Johan,

Thanks a lot for finding this problem (EDITOR was always define on my computer)

Suggestion:
- If EDITOR is not set, ask for user preference, and store this somewhere so you don't need to ask again (e.g. in a $HOME/.mg5preferences file)

If EDITOR is not set, I prefer to do this:
1) print a message:
INFO: You can choose your prefered editor by defining the shell variable EDITOR
2) use the first program defined in the following list:
['vi', 'emacs', 'vim', 'gedit', 'nano']

The second bug was in fact already fix in the combine_070 branches, but I put the modification here.

Revision history for this message
Johan Alwall (johan-alwall) wrote :

Very nice, now it seems to work great! Just a very minor detail - could the default run names correspond to those on the web, i.e., run_01, run_02 etc?

Great, include this in the combine_0_7_0 branch, and then we'll have a final overall review of the branch.

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote :

It's run1, run2,...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'madgraph/interface/cmd_interface.py'
2--- madgraph/interface/cmd_interface.py 2011-03-15 12:57:11 +0000
3+++ madgraph/interface/cmd_interface.py 2011-03-16 09:18:32 +0000
4@@ -199,9 +199,15 @@
5 logger_tuto.info(getattr(tutorial_text, args[0]).replace('\n','\n\t'))
6 except:
7 pass
8+<<<<<<< TREE
9
10 return stop
11
12+=======
13+
14+ return stop
15+
16+>>>>>>> MERGE-SOURCE
17 def timed_input(self, question, default, timeout=None):
18 """ a question with a maximal time to answer take default otherwise"""
19
20
21=== modified file 'madgraph/interface/launch_ext_program.py'
22--- madgraph/interface/launch_ext_program.py 2011-03-15 09:38:24 +0000
23+++ madgraph/interface/launch_ext_program.py 2011-03-16 09:18:32 +0000
24@@ -54,15 +54,20 @@
25 # let first try to use the prefer editor (if EDITOR is define)
26 # if not define use the first define in a pre-define list
27
28- if os.environ['EDITOR']:
29+ if os.environ.has_key('EDITOR') and misc.which(os.environ['EDITOR']):
30 self.editor = os.environ['EDITOR']
31 return
32
33+ logger.info('INFO: You can choose your prefered editor by defining the shell variable EDITOR')
34+
35 possibility = ['vi', 'emacs', 'vim', 'gedit', 'nano']
36 for editor in possibility:
37 if misc.which(editor):
38 self.editor = editor
39 return
40+
41+ logger.warning(
42+ 'No valid editor detected. Please configure the shell variable EDITOR')
43
44 def run(self):
45 """ execute the main code """
46@@ -86,6 +91,7 @@
47 """edit a file"""
48
49 path = os.path.realpath(path)
50+ print [self.editor, path], os.getcwd()
51 subprocess.call([self.editor, path], cwd=os.getcwd())
52
53 def ask(self, question, default):
54
55=== modified file 'madgraph/iolibs/misc.py'
56--- madgraph/iolibs/misc.py 2011-03-10 13:12:33 +0000
57+++ madgraph/iolibs/misc.py 2011-03-16 09:18:32 +0000
58@@ -86,6 +86,9 @@
59 def is_exe(fpath):
60 return os.path.exists(fpath) and os.access(fpath, os.X_OK)
61
62+ if not program:
63+ return None
64+
65 fpath, fname = os.path.split(program)
66 if fpath:
67 if is_exe(program):

Subscribers

People subscribed via source and target branches

to all changes: