ert icon indicating copy to clipboard operation
ert copied to clipboard

Make it possible to register PATH additions for forward models through plugin system

Open berland opened this issue 1 year ago • 6 comments

In order to solve #8925 it can be beneficial to make a new hook specification in Erts plugin manager in order for plugins to register paths that are to be amended to $PATH when running forward models.

Necessary paths for forward models is currently possible by setting arbitrary env variables using SETENV directives in site-config, and then the forward models can be aware of those special env variables and add them to PATH when needed. But that only works after Ert has processed the SETENV directives and set off the forward model on the compute side.

In order for validation to work, as done today in:

https://github.com/equinor/ert/blob/59d80e704899f099f914476b9d0c37940025a19c/src/ert/resources/forward_models/res/script/ecl_config.py#L262-L266

it must be possible to run the forward model before SETENV directives are processed.

berland avatar Oct 15 '24 07:10 berland

This seems reasonable to me. What do you think @sondreso ?

eivindjahren avatar Oct 15 '24 08:10 eivindjahren

Proposals (up for discussion):

  • The hook is forward model agnostic, i.e., the hook can register paths without stating which forward models should use them
  • The hook registers List[str]. ~~It should fail if colon separated paths are given.~~
  • pluggys LIFO principle should be adhered to, last registered plugin comes first in the resulting path.
  • The plugin manager provides a function to obtain all the registered paths, as List[str].
  • Users of this function (forward model steps) should colon-join this list and then prepend or append to their PATH, or do whatever.
  • The order among paths for each individual plugin should be kept as is.

berland avatar Oct 16 '24 08:10 berland

An alternative approach is to overlap with the SETENV possibility in site-config and provide a way of setting environment variables through the plugin system.

Setting/augmenting PATH through such a system would require special casing of that env variable which is not pretty, maybe PATH should be illegal to modify through this. Forward models can then define their special env variables to look for, and then use them as they please, augmenting PATH if wanted.

Conflicting env settings from different plugins should result in a warning and using the last registered value.

berland avatar Oct 16 '24 14:10 berland

@yngve-sk , do you know if the same changes must be copied to the Everest pluginmanager, or will Everest's pluginmanager be removed/merged into Ert any time soon?

berland avatar Oct 16 '24 16:10 berland

@yngve-sk , do you know if the same changes must be copied to the Everest pluginmanager, or will Everest's pluginmanager be removed/merged into Ert any time soon?

I think we would have to make those additions to Everest separately, current everest forward models are "old style" files exported there etc. This is on our TODO: https://github.com/equinor/ert/issues/8847 but that is only for validation. There are some differences in how the forward models are specified in everest-models, but I don't immediately see it being impossible to port them over to the current forward model implementation plugin style used in ERT. @oyvindeide might know more about whether we want to do this.

yngve-sk avatar Oct 23 '24 06:10 yngve-sk

#9036 presents an alternative solution to the underlying problem.

berland avatar Oct 24 '24 13:10 berland

Superseded by #9036

berland avatar Nov 04 '24 08:11 berland