PLUGIN from alternative location

Asked by Hannes

Hi,

in ATLAS we have a central MG5_aMC installation on a read-only file system that cannot easily be modified.

For that reason it would be very convenient for us to load a plugin from an alternative location outside the MG5_aMC directory (that could for example be specified by an environment variable). Is something like this possible?

Cheers,
Hannes

Question information

Language:
English Edit question
Status:
Answered
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#1

This was indeed requested/put in place for ATLAS years ago.
Is this not working anymore?

For reference you should put your plugin in a directory named
XXX/MG5aMC_PLUGIN
and put XXX in your PYTHONPATH

I guess that you plan to have the plugin on the same read-only filesystem (or at least control by the same people)
Remember that the plugin have full control on the code and can overwrite any function/...
So if the point of the read-only filesystem is to be sure that the code stay the same, then you need the same level of protection for the plugin directory.

Cheers,

Olivier

> On 18 May 2022, at 18:20, Hannes <email address hidden> wrote:
>
> New question #701855 on MadGraph5_aMC@NLO:
> https://answers.launchpad.net/mg5amcnlo/+question/701855
>
> Hi,
>
> in ATLAS we have a central MG5_aMC installation on a read-only file system that cannot easily be modified.
>
> For that reason it would be very convenient for us to load a plugin from an alternative location outside the MG5_aMC directory (that could for example be specified by an environment variable). Is something like this possible?
>
> Cheers,
> Hannes
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Revision history for this message
Hannes (hannes3) said :
#2

Hi Olivier,

I have tried that, I have copied the code from

https://cp3.irmp.ucl.ac.be/projects/madgraph/wiki/FAQ-General-15

to

/tmp/hmildner/test/MG5aMC_PLUGIN/user_filter.py

and added

:/tmp/hmildner/test

to PYTHONPATH

but when I run

python $MADPATH/bin/mg5_aMC

and

generate p p > t t~ --diagram_filter

I still get

Error detected in "generate p p > t t~ --diagram_filter"
write debug file MG5_debug
If you need help with this issue please contact us on https://answers.launchpad.net/mg5amcnlo
str : user filter required to be defined in PLUGIN/user_filter.py with the function remove_diag(ONEDIAG) which returns True if the diagram has to be removed

Cheers,
Hannes

Revision history for this message
Hannes (hannes3) said :
#3

in v2.9.9

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#4

Aahhh user_filter is not a real plugin this is a (extremelly dangerous) hack.

So that indeed does not have a way to to be callable via environment variable.
I'm not in favor to have a way to do that actually. But adding such support can be done ... via a PLUGIN (which can be set by environment variable).

Revision history for this message
Hannes (hannes3) said :
#5

Hi Olivier,

thanks. It's an extremely dangerous hack because of the physics implications of removing some diagrams?
How would we go about implementing such a plugin in cases where it might still be required?

Cheers,
Hannes

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) said :
#6

> thanks. It's an extremely dangerous hack because of the physics implications of removing some diagrams?

yes breaking of gauge invariance in particular.

> How would we go about implementing such a plugin in cases where it might still be required?

I would have say by overwritting the function
 def apply_user_filter(self, diag_list):
of diagram_generation.py

but looks like this is already using the plugin magic function:

 if True:
            remove_diag = misc.plugin_import('user_filter',
                                             'user filter required to be defined in PLUGIN/user_filter.py with the function remove_diag(ONEDIAG) which returns True if the diagram has to be removed',
                                             fcts=['remove_diag'])

and misc.plugin_import has the method implemented for ATLAS and the plugin...

    try:
        _temp = __import__('PLUGIN.%s' % module, globals(), locals(), fcts, level)
    except ImportError:
        try:
            _temp = __import__('MG5aMC_PLUGIN.%s' % module, globals(), locals(), fcts, level)
        except ImportError:
            raise MadGraph5Error(error_msg)

So maybe this is a python3 issue...

Cheers,

Olivier

> On 18 May 2022, at 23:11, Hannes <email address hidden> wrote:
>
> Question #701855 on MadGraph5_aMC@NLO changed:
> https://answers.launchpad.net/mg5amcnlo/+question/701855
>
> Hannes posted a new comment:
> Hi Olivier,
>
> thanks. It's an extremely dangerous hack because of the physics implications of removing some diagrams?
> How would we go about implementing such a plugin in cases where it might still be required?
>
> Cheers,
> Hannes
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Can you help with this problem?

Provide an answer of your own, or ask Hannes for more information if necessary.

To post a message you must log in.