Then this depend of the madspin_card that you use, since the linearisation of that dictionary can sometimes lead to crash and that was the reason of such patch.
The real question is why "decay_struct" is not a string when set like one...
Are you using the spinmode only mode of madspin?
Cheers,
Olivier
> On 23 Dec 2021, at 08:04, Sitian Qian <email address hidden> wrote:
>
> Public bug reported:
>
> When we use the recent MG5v33x versions, we find Madspin cannot run
> properly from a pickle file. The error reads
>
> Traceback (most recent call last):
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/bin/test_ttbar/Events/run_01/../../../../MadSpin/madspin", line 139, in <module>
> cmd_line.import_command_file(input_file)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/madgraph/interface/extended_cmd.py", line 1692, in import_command_file
> self.exec_cmd(line, precmd=True)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/madgraph/interface/extended_cmd.py", line 1573, in exec_cmd
> stop = Cmd.onecmd_orig(current_interface, line, **opt)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/madgraph/interface/extended_cmd.py", line 1493, in onecmd_orig
> return func(arg, **opt)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/madgraph/various/misc.py", line 110, in f_with_no_logger
> out = f(self, *args, **opt)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/MadSpin/interface_madspin.py", line 621, in do_launch
> return self.run_from_pickle()
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/MadSpin/interface_madspin.py", line 718, in run_from_pickle
> d['decay_struct'] = eval(d['decay_struct'])
> TypeError: eval() arg 1 must be a string, bytes or code object
>
> However, it runs successfully with on-the-fly usages. After looking into
> the codes, we find out that this bug comes from the improper treatment
> for pickle save and load part. In which the 'decay_struct' dictionaries
> are converted to strings when saving pickle file and convert back when
> loading. This leads to the bug mentioned above.
>
> Now after commenting out the corresponding lines MadSpin works properly
> with saved pickle files. Changes are listed below:
>
> --- a/MadSpin/decay.py
> +++ b/MadSpin/decay.py
> @@ -2181,9 +2181,9 @@ class decay_all_events(object):
> #self.all_ME, bkp2 = None , self.all_ME
> #self.width_estimator, bkp3 = self.width_estimator, self.width_estimator
> modelpath = model.get('modelpath')
> - for me in self.all_ME:
> - for d in self.all_ME[me]['decays']:
> - d['decay_struct'] = str(d['decay_struct'])
> + #for me in self.all_ME:
> + # for d in self.all_ME[me]['decays']:
> + # d['decay_struct'] = str(d['decay_struct'])
> self.modelpath = modelpath
>
>
> --- a/MadSpin/interface_madspin.py
> +++ b/MadSpin/interface_madspin.py
> @@ -713,9 +713,9 @@ class MadSpinInterface(extended_cmd.Cmd):
>
> #restore data passed to string to help pickle
> generate_all.all_decay = eval(generate_all.all_decay)
> - for me in generate_all.all_ME:
> - for d in generate_all.all_ME[me]['decays']:
> - d['decay_struct'] = eval(d['decay_struct'])
> + #for me in generate_all.all_ME:
> + # for d in generate_all.all_ME[me]['decays']:
> + # d['decay_struct'] = eval(d['decay_struct'])
>
>
> # Re-create information which are not save in the pickle.
>
> ** Affects: mg5amcnlo
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to
> MadGraph5_aMC@NLO.
> https://bugs.launchpad.net/bugs/1955614
>
> Title:
> Madspin doesn't save and load pickle file properly for recent MG5v3
>
> Status in MadGraph5_aMC@NLO:
> New
>
> Bug description:
> When we use the recent MG5v33x versions, we find Madspin cannot run
> properly from a pickle file. The error reads
>
> Traceback (most recent call last):
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/bin/test_ttbar/Events/run_01/../../../../MadSpin/madspin", line 139, in <module>
> cmd_line.import_command_file(input_file)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/madgraph/interface/extended_cmd.py", line 1692, in import_command_file
> self.exec_cmd(line, precmd=True)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/madgraph/interface/extended_cmd.py", line 1573, in exec_cmd
> stop = Cmd.onecmd_orig(current_interface, line, **opt)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/madgraph/interface/extended_cmd.py", line 1493, in onecmd_orig
> return func(arg, **opt)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/madgraph/various/misc.py", line 110, in f_with_no_logger
> out = f(self, *args, **opt)
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/MadSpin/interface_madspin.py", line 621, in do_launch
> return self.run_from_pickle()
> File "/data/bond/stqian/reproduce_MG5331/MG5_aMC_v3_3_1/MadSpin/interface_madspin.py", line 718, in run_from_pickle
> d['decay_struct'] = eval(d['decay_struct'])
> TypeError: eval() arg 1 must be a string, bytes or code object
>
> However, it runs successfully with on-the-fly usages. After looking
> into the codes, we find out that this bug comes from the improper
> treatment for pickle save and load part. In which the 'decay_struct'
> dictionaries are converted to strings when saving pickle file and
> convert back when loading. This leads to the bug mentioned above.
>
> Now after commenting out the corresponding lines MadSpin works
> properly with saved pickle files. Changes are listed below:
>
> --- a/MadSpin/decay.py
> +++ b/MadSpin/decay.py
> @@ -2181,9 +2181,9 @@ class decay_all_events(object):
> #self.all_ME, bkp2 = None , self.all_ME
> #self.width_estimator, bkp3 = self.width_estimator, self.width_estimator
> modelpath = model.get('modelpath')
> - for me in self.all_ME:
> - for d in self.all_ME[me]['decays']:
> - d['decay_struct'] = str(d['decay_struct'])
> + #for me in self.all_ME:
> + # for d in self.all_ME[me]['decays']:
> + # d['decay_struct'] = str(d['decay_struct'])
> self.modelpath = modelpath
>
>
> --- a/MadSpin/interface_madspin.py
> +++ b/MadSpin/interface_madspin.py
> @@ -713,9 +713,9 @@ class MadSpinInterface(extended_cmd.Cmd):
>
> #restore data passed to string to help pickle
> generate_all.all_decay = eval(generate_all.all_decay)
> - for me in generate_all.all_ME:
> - for d in generate_all.all_ME[me]['decays']:
> - d['decay_struct'] = eval(d['decay_struct'])
> + #for me in generate_all.all_ME:
> + # for d in generate_all.all_ME[me]['decays']:
> + # d['decay_struct'] = eval(d['decay_struct'])
>
>
> # Re-create information which are not save in the pickle.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mg5amcnlo/+bug/1955614/+subscriptions
>
Then this depend of the madspin_card that you use, since the linearisation of that dictionary can sometimes lead to crash and that was the reason of such patch.
The real question is why "decay_struct" is not a string when set like one...
Are you using the spinmode only mode of madspin?
Cheers,
Olivier
> On 23 Dec 2021, at 08:04, Sitian Qian <email address hidden> wrote: bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ bin/test_ ttbar/Events/ run_01/ ../../. ./../MadSpin/ madspin" , line 139, in <module> import_ command_ file(input_ file) bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ madgraph/ interface/ extended_ cmd.py" , line 1692, in import_command_file bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ madgraph/ interface/ extended_ cmd.py" , line 1573, in exec_cmd orig(current_ interface, line, **opt) bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ madgraph/ interface/ extended_ cmd.py" , line 1493, in onecmd_orig bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ madgraph/ various/ misc.py" , line 110, in f_with_no_logger bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ MadSpin/ interface_ madspin. py", line 621, in do_launch from_pickle( ) bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ MadSpin/ interface_ madspin. py", line 718, in run_from_pickle 'decay_ struct' ]) events( object) : estimator, bkp3 = self.width_ estimator, self.width_ estimator 'modelpath' ) ME[me][ 'decays' ]: decay_struct' ]) ME[me][ 'decays' ]: decay_struct' ]) interface_ madspin. py interface_ madspin. py e(extended_ cmd.Cmd) : all.all_ decay = eval(generate_ all.all_ decay) all.all_ ME: all.all_ ME[me][ 'decays' ]: 'decay_ struct' ]) all.all_ ME: all.all_ ME[me][ 'decays' ]: 'decay_ struct' ]) /bugs.launchpad .net/bugs/ 1955614 bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ bin/test_ ttbar/Events/ run_01/ ../../. ./../MadSpin/ madspin" , line 139, in <module> import_ command_ file(input_ file) bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ madgraph/ interface/ extended_ cmd.py" , line 1692, in import_command_file bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ madgraph/ interface/ extended_ cmd.py" , line 1573, in exec_cmd orig(current_ interface, line, **opt) bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ madgraph/ interface/ extended_ cmd.py" , line 1493, in onecmd_orig bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ madgraph/ various/ misc.py" , line 110, in f_with_no_logger bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ MadSpin/ interface_ madspin. py", line 621, in do_launch from_pickle( ) bond/stqian/ reproduce_ MG5331/ MG5_aMC_ v3_3_1/ MadSpin/ interface_ madspin. py", line 718, in run_from_pickle 'decay_ struct' ]) events( object) : estimator, bkp3 = self.width_ estimator, self.width_ estimator 'modelpath' ) ME[me][ 'decays' ]: decay_struct' ]) ME[me][ 'decays' ]: decay_struct' ]) interface_ madspin. py interface_ madspin. py e(extended_ cmd.Cmd) : all.all_ decay = eval(generate_ all.all_ decay) all.all_ ME: all.all_ ME[me][ 'decays' ]: 'decay_ struct' ]) all.all_ ME: all.all_ ME[me][ 'decays' ]: 'decay_ struct' ]) /bugs.launchpad .net/mg5amcnlo/ +bug/1955614/ +subscriptions
>
> Public bug reported:
>
> When we use the recent MG5v33x versions, we find Madspin cannot run
> properly from a pickle file. The error reads
>
> Traceback (most recent call last):
> File "/data/
> cmd_line.
> File "/data/
> self.exec_cmd(line, precmd=True)
> File "/data/
> stop = Cmd.onecmd_
> File "/data/
> return func(arg, **opt)
> File "/data/
> out = f(self, *args, **opt)
> File "/data/
> return self.run_
> File "/data/
> d['decay_struct'] = eval(d[
> TypeError: eval() arg 1 must be a string, bytes or code object
>
> However, it runs successfully with on-the-fly usages. After looking into
> the codes, we find out that this bug comes from the improper treatment
> for pickle save and load part. In which the 'decay_struct' dictionaries
> are converted to strings when saving pickle file and convert back when
> loading. This leads to the bug mentioned above.
>
> Now after commenting out the corresponding lines MadSpin works properly
> with saved pickle files. Changes are listed below:
>
> --- a/MadSpin/decay.py
> +++ b/MadSpin/decay.py
> @@ -2181,9 +2181,9 @@ class decay_all_
> #self.all_ME, bkp2 = None , self.all_ME
> #self.width_
> modelpath = model.get(
> - for me in self.all_ME:
> - for d in self.all_
> - d['decay_struct'] = str(d['
> + #for me in self.all_ME:
> + # for d in self.all_
> + # d['decay_struct'] = str(d['
> self.modelpath = modelpath
>
>
> --- a/MadSpin/
> +++ b/MadSpin/
> @@ -713,9 +713,9 @@ class MadSpinInterfac
>
> #restore data passed to string to help pickle
> generate_
> - for me in generate_
> - for d in generate_
> - d['decay_struct'] = eval(d[
> + #for me in generate_
> + # for d in generate_
> + # d['decay_struct'] = eval(d[
>
>
> # Re-create information which are not save in the pickle.
>
> ** Affects: mg5amcnlo
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are subscribed to
> MadGraph5_aMC@NLO.
> https:/
>
> Title:
> Madspin doesn't save and load pickle file properly for recent MG5v3
>
> Status in MadGraph5_aMC@NLO:
> New
>
> Bug description:
> When we use the recent MG5v33x versions, we find Madspin cannot run
> properly from a pickle file. The error reads
>
> Traceback (most recent call last):
> File "/data/
> cmd_line.
> File "/data/
> self.exec_cmd(line, precmd=True)
> File "/data/
> stop = Cmd.onecmd_
> File "/data/
> return func(arg, **opt)
> File "/data/
> out = f(self, *args, **opt)
> File "/data/
> return self.run_
> File "/data/
> d['decay_struct'] = eval(d[
> TypeError: eval() arg 1 must be a string, bytes or code object
>
> However, it runs successfully with on-the-fly usages. After looking
> into the codes, we find out that this bug comes from the improper
> treatment for pickle save and load part. In which the 'decay_struct'
> dictionaries are converted to strings when saving pickle file and
> convert back when loading. This leads to the bug mentioned above.
>
> Now after commenting out the corresponding lines MadSpin works
> properly with saved pickle files. Changes are listed below:
>
> --- a/MadSpin/decay.py
> +++ b/MadSpin/decay.py
> @@ -2181,9 +2181,9 @@ class decay_all_
> #self.all_ME, bkp2 = None , self.all_ME
> #self.width_
> modelpath = model.get(
> - for me in self.all_ME:
> - for d in self.all_
> - d['decay_struct'] = str(d['
> + #for me in self.all_ME:
> + # for d in self.all_
> + # d['decay_struct'] = str(d['
> self.modelpath = modelpath
>
>
> --- a/MadSpin/
> +++ b/MadSpin/
> @@ -713,9 +713,9 @@ class MadSpinInterfac
>
> #restore data passed to string to help pickle
> generate_
> - for me in generate_
> - for d in generate_
> - d['decay_struct'] = eval(d[
> + #for me in generate_
> + # for d in generate_
> + # d['decay_struct'] = eval(d[
>
>
> # Re-create information which are not save in the pickle.
>
> To manage notifications about this bug go to:
> https:/
>