equinor / ert

ERT - Ensemble based Reservoir Tool - is designed for running ensembles of dynamical models such as reservoir models, in order to do sensitivity analysis and data assimilation. ERT supports data assimilation using the Ensemble Smoother (ES), Ensemble Smoother with Multiple Data Assimilation (ES-MDA) and Iterative Ensemble Smoother (IES).
https://ert.readthedocs.io/en/latest/
GNU General Public License v3.0
101 stars 104 forks source link

LSF driver resource string can fail with host exclusion #8255

Closed berland closed 3 months ago

berland commented 3 months ago

If rusage and select are already present in the LSF resource string, and a user supplies a list of hosts to exlude, the LSF driver will build an invalid string.

This easily happens as both these are typically set through ert-configurations.

The existing parametrized test can be augmented to make this fail:

        pytest.param(
            "select[location=='cloud'] rusage[mem=7000]",
            ["rogue_host"],
            "select[location=='cloud' && hname!='rogue_host'] rusage[mem=7000]",
            id="select_and_rusage_in_resource_requirement_one_excluded_hosts",
        ),
    def test_build_resource_requirement_string(
        resource_requirement: Optional[str], exclude_hosts: List[str], expected_string: str
    ):
>       assert (
            build_resource_requirement_string(exclude_hosts, resource_requirement)
            == expected_string
        )
E       assert "select[locat...'rogue_host']" == 'select[locat...age[mem=7000]'
E         
E         - select[location=='cloud' && hname!='rogue_host'] rusage[mem=7000]
E         + select[location=='cloud'] rusage[mem=7000 && hname!='rogue_host']

tests/unit_tests/scheduler/test_lsf_driver.py:650: AssertionError
berland commented 3 months ago

The bug is due do rindex("]") which locates the wrong end of the select clause.

https://github.com/equinor/ert/blob/2ce20800e12006202828c3e7e657c13fb96e0c6f/src/ert/scheduler/lsf_driver.py#L150