Comment 0 for bug 2025182

Revision history for this message
Nick Smith (ncsmith-cern) wrote : Error in reweighting with v3.5.2

When trying to run a reweighting of a SMEFTsim model in v3.4.2, I get the error
```
reweight -from_cards
INFO: Extracting the banner ...
INFO: process: u u~ > h u u~ NP<=1
INFO: options: SMHLOOP=0
INFO: Running Reweighting
change rwgt_dir rwgt
launch --rwgt_name=rw_sm
INFO: detected model: SMEFTsim_topU3l_MwScheme_UFO. Loading...
CRITICAL: Model with non QCD emission of gluon (found 14 of those).
  This type of model is not fully supported within MG5aMC.
  Restriction on LO dynamical scale and MLM matching/merging can occur for some processes.
  Use such features with care.
CRITICAL: Model with non QCD emission of gluon (found 14 of those).
  This type of model is not fully supported within MG5aMC.
  Restriction on LO dynamical scale and MLM matching/merging can occur for some processes.
  Use such features with care.
INFO: generating the square matrix element for reweighting
INFO: generate u u~ > h u u~ NP<=1 SMHLOOP=0 ;
INFO: Done 12.39
Command "launch" interrupted with error:
AttributeError : 'int' object has no attribute 'decode'
Please report this bug on https://bugs.launchpad.net/mg5amcnlo
More information is found in '/root/data/uuhuu/run_01_tag_1_debug.log'.
Please attach this file to your report.
```

Looking at run_01_tag_1_debug.log I see the following traceback:
```
Traceback (most recent call last):
  File "/root/data/uuhuu/bin/internal/extended_cmd.py", line 1544, in onecmd
    return self.onecmd_orig(line, **opt)
  File "/root/data/uuhuu/bin/internal/extended_cmd.py", line 1493, in onecmd_orig
    return func(arg, **opt)
  File "/root/data/uuhuu/bin/internal/madevent_interface.py", line 2763, in do_launch
    self.do_generate_events(line, *args, **opt)
  File "/root/data/uuhuu/bin/internal/madevent_interface.py", line 2404, in do_generate_events
    self.run_generate_events(switch_mode, args)
  File "/root/data/uuhuu/bin/internal/common_run_interface.py", line 7634, in new_fct
    original_fct(obj, *args, **opts)
  File "/root/data/uuhuu/bin/internal/madevent_interface.py", line 2657, in run_generate_events
    self.exec_cmd('reweight -from_cards', postcmd=False)
  File "/root/data/uuhuu/bin/internal/extended_cmd.py", line 1573, in exec_cmd
    stop = Cmd.onecmd_orig(current_interface, line, **opt)
  File "/root/data/uuhuu/bin/internal/extended_cmd.py", line 1493, in onecmd_orig
    return func(arg, **opt)
  File "/root/data/uuhuu/bin/internal/common_run_interface.py", line 2238, in do_reweight
    reweight_cmd.import_command_file(path)
  File "/usr/local/venv/MG5_aMC/madgraph/interface/extended_cmd.py", line 1692, in import_command_file
    self.exec_cmd(line, precmd=True)
  File "/usr/local/venv/MG5_aMC/madgraph/interface/extended_cmd.py", line 1573, in exec_cmd
    stop = Cmd.onecmd_orig(current_interface, line, **opt)
  File "/usr/local/venv/MG5_aMC/madgraph/interface/extended_cmd.py", line 1493, in onecmd_orig
    return func(arg, **opt)
  File "/usr/local/venv/MG5_aMC/madgraph/various/misc.py", line 111, in f_with_no_logger
    out = f(self, *args, **opt)
  File "/usr/local/venv/MG5_aMC/madgraph/interface/reweight_interface.py", line 507, in do_launch
    self.load_module()
  File "/usr/local/venv/MG5_aMC/madgraph/interface/reweight_interface.py", line 1901, in load_module
    all_prefix = [''.join([i.decode(errors='ignore') for i in j]).strip().lower() for j in mymod.get_prefix()]
  File "/usr/local/venv/MG5_aMC/madgraph/interface/reweight_interface.py", line 1901, in <listcomp>
    all_prefix = [''.join([i.decode(errors='ignore') for i in j]).strip().lower() for j in mymod.get_prefix()]
  File "/usr/local/venv/MG5_aMC/madgraph/interface/reweight_interface.py", line 1901, in <listcomp>
    all_prefix = [''.join([i.decode(errors='ignore') for i in j]).strip().lower() for j in mymod.get_prefix()]
AttributeError: 'int' object has no attribute 'decode'
```

After adding a printout, I see that `mymod` is `rwgt/rw_me/SubProcesses/allmatrix3py.py` inside the process directory.
The issue seems to be some environment-dependent change in numpy type for the return value of `mymod.get_prefix()`, it is in my enviornment:
```
root@aa2494a3bde8:~/data/uuhuu# python3 -i rwgt/rw_me/SubProcesses/allmatrix3py.py
>>> get_prefix()
array([b'M0_ '], dtype='|S20')
```
whereas in a working environment it is
```
array([[b'M', b'0', b'_', b' ', b' ', b' ', b' ', b' ', b' ', b' ', b' ',
        b' ', b' ', b' ', b' ', b' ', b' ', b' ', b' ', b' ']],
      dtype='|S1')
```
Changing the line to
```
all_prefix = [bytes(j).decode(errors="ignore").strip().lower() for j in get_prefix()]
```
seems to allow both types to be processed. Does this make sense?