Merge lp:~jp-ellis/mg5amcnlo/allow-absolute-model-path into lp:mg5amcnlo/lts

Proposed by Joshua Ellis
Status: Merged
Merge reported by: Olivier Mattelaer
Merged at revision: not available
Proposed branch: lp:~jp-ellis/mg5amcnlo/allow-absolute-model-path
Merge into: lp:mg5amcnlo/lts
Diff against target: 12 lines (+2/-0)
1 file modified
models/import_ufo.py (+2/-0)
To merge this branch: bzr merge lp:~jp-ellis/mg5amcnlo/allow-absolute-model-path
Reviewer Review Type Date Requested Status
Olivier Mattelaer Needs Information
Review via email: mp+303914@code.launchpad.net

Commit message

Allow for absolute paths to be specified for the model's UFO files.

Description of the change

Allow for absolute paths to be specified for the model's UFO files.

To post a comment you must log in.
Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote :

Dear Joshua,

I guess that the patch that you are looking for is

=== modified file 'models/import_ufo.py'
--- models/import_ufo.py 2016-06-20 11:08:55 +0000
+++ models/import_ufo.py 2016-08-25 11:02:57 +0000
@@ -79,9 +79,9 @@
                     last_model_path = os.path.join(MG5DIR, p, model_name)
                 return os.path.join(MG5DIR, p, model_name)
     if os.path.isdir(model_name):
- if last_model_path != os.path.join(MG5DIR, p, model_name):
+ if last_model_path != os.path.join(MG5DIR, model_name):
             logger.info("model loaded from: %s", os.path.join(os.getcwd(), model_name))
- last_model_path = os.path.join(MG5DIR, p, model_name)
+ last_model_path = os.path.join(MG5DIR, model_name)
         return model_name
     else:
         raise UFOImportError("Path %s is not a valid pathname" % model_name)

Thanks,

Olivier

review: Needs Information
Revision history for this message
Joshua Ellis (jp-ellis) wrote :

Is that in addition to what I have, or an alternative?

Essentially, MadGraph current does not allow to have:

import model /some/path/to/model/ -modelname

and the patch I offer allows this to work, and as far as I can tell, it works (though you may want to do extra testing of course in case it has unforeseen consequences).

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

Hi,

> Is that in addition to what I have, or an alternative?

as an alternative.

> import model /some/path/to/model/ -modelname

This is actually working for me without any of those patch.
I guess that the reason is that I have PYTHONPATH in my environment.
If you do not have PYTHONPATH in your environment, I indeed expect a bug to occur.
This is that bug that I fix in my proposal.
With that fix, it is basically equivalent to the your proposal actually (up to a print statement)

Cheers,

Olivier

> On Aug 25, 2016, at 13:26, Joshua Ellis <email address hidden> wrote:
>
> Is that in addition to what I have, or an alternative?
>
> Essentially, MadGraph current does not allow to have:
>
> import model /some/path/to/model/ -modelname
>
> and the patch I offer allows this to work, and as far as I can tell, it works (though you may want to do extra testing of course in case it has unforeseen consequences).
> --
> https://code.launchpad.net/~jp-ellis/mg5amcnlo/allow-absolute-model-path/+merge/303914
> You are reviewing the proposed merge of lp:~jp-ellis/mg5amcnlo/allow-absolute-model-path into lp:mg5amcnlo.

Revision history for this message
Joshua Ellis (jp-ellis) wrote :

But, doesn't your patch still load the model from the MadGraph5 path, seeing as it is concatenating it with the model path?

What happens if the model is outside of the MadGraph5 path entirely?

Also, it is correct that I don't have the PYTHONPATH environment variable set (I'm not entirely sure why I should have it set...)

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

No I also return “model_name” exactly like you.
No difference on that.

> On Aug 25, 2016, at 13:45, Joshua Ellis <email address hidden> wrote:
>
> But, doesn't your patch still load the model from the MadGraph5 path, seeing as it is concatenating it with the model path?
>
> What happens if the model is outside of the MadGraph5 path entirely?
>
> Also, it is correct that I don't have the PYTHONPATH environment variable set (I'm not entirely sure why I should have it set...)
> --
> https://code.launchpad.net/~jp-ellis/mg5amcnlo/allow-absolute-model-path/+merge/303914
> You are reviewing the proposed merge of lp:~jp-ellis/mg5amcnlo/allow-absolute-model-path into lp:mg5amcnlo.

Revision history for this message
Joshua Ellis (jp-ellis) wrote :

I'll have a go at the patch you suggest tomorrow and let you know whether it works for me. Thanks!

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

Just to close this merge request,
I have implemented my proposal.
If it does not work for you, please tell me.

Cheers,

Olivier

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'models/import_ufo.py'
2--- models/import_ufo.py 2016-06-08 22:44:34 +0000
3+++ models/import_ufo.py 2016-08-25 10:25:05 +0000
4@@ -69,6 +69,8 @@
5 # Check for a valid directory
6 if model_name.startswith('./') and os.path.isdir(model_name):
7 return model_name
8+ elif model_name.startswith('/') and os.path.isdir(model_name):
9+ return model_name
10 elif os.path.isdir(os.path.join(MG5DIR, 'models', model_name)):
11 return os.path.join(MG5DIR, 'models', model_name)
12 elif 'PYTHONPATH' in os.environ:

Subscribers

People subscribed via source and target branches

to all changes: