From 5bb7b6c93fe74f24da0ae0aad9b47c605df17ad4 Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Fri, 11 Nov 2022 08:38:06 +0100 Subject: [PATCH] Fix an issue with arglist with simulation job In 9809fefbc4b3655fbb3df89676959d93fa645672 the call to ext_job_free_deprecated_argv was erronously omitted while reimplementing the creation of ext_job from the SIMULATION_JOB keyword in python. This lead to simulation job not working correctly when the job has an ARGLIST. --- src/clib/lib/include/ert/job_queue/ext_job.hpp | 3 ++- src/ert/_c_wrappers/enkf/res_config.py | 1 + src/ert/_c_wrappers/job_queue/ext_job.py | 4 ++++ .../c_wrappers/res/enkf/test_enkf_sim_model.py | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/clib/lib/include/ert/job_queue/ext_job.hpp b/src/clib/lib/include/ert/job_queue/ext_job.hpp index 7fd679c485e..35445a3c876 100644 --- a/src/clib/lib/include/ert/job_queue/ext_job.hpp +++ b/src/clib/lib/include/ert/job_queue/ext_job.hpp @@ -14,7 +14,8 @@ extern "C" const char *ext_job_get_help_text(const ext_job_type *job); void ext_job_set_help_text(ext_job_type *job, const char *help_text); ext_job_type *ext_job_alloc_copy(const ext_job_type *); -void ext_job_free_deprecated_argv(ext_job_type *ext_job); //DEPRECATED +extern "C" void +ext_job_free_deprecated_argv(ext_job_type *ext_job); //DEPRECATED ext_job_type *ext_job_alloc(const char *, const char *license_root_path, bool private_job); extern "C" const char *ext_job_get_name(const ext_job_type *); diff --git a/src/ert/_c_wrappers/enkf/res_config.py b/src/ert/_c_wrappers/enkf/res_config.py index f318038602c..a04f61814f8 100644 --- a/src/ert/_c_wrappers/enkf/res_config.py +++ b/src/ert/_c_wrappers/enkf/res_config.py @@ -320,6 +320,7 @@ def _alloc_from_content(self, user_config_file=None, config=None): job = self.site_config.job_list.get_job_copy(job_description[0]) job.set_arglist(job_description[1:]) job.set_define_args(self.substitution_list) + job.clear_deprecated_argv() job.convertToCReference(None) jobs.append(job) diff --git a/src/ert/_c_wrappers/job_queue/ext_job.py b/src/ert/_c_wrappers/job_queue/ext_job.py index 7f94e8a1657..90e74e826f9 100644 --- a/src/ert/_c_wrappers/job_queue/ext_job.py +++ b/src/ert/_c_wrappers/job_queue/ext_job.py @@ -68,6 +68,7 @@ class ExtJob(BaseCClass): _set_define_args = ResPrototype( "subst_list_ref ext_job_set_define_args(ext_job, subst_list)" ) + _free_deprecated_argv = ResPrototype("void ext_job_free_deprecated_argv(ext_job)") def __init__( self, @@ -102,6 +103,9 @@ def __repr__(self): else: return "UNINITIALIZED ExtJob" + def clear_deprecated_argv(self): + self._free_deprecated_argv() + def set_define_args(self, subst_list: SubstitutionList) -> None: self._set_define_args(subst_list) diff --git a/tests/unit_tests/c_wrappers/res/enkf/test_enkf_sim_model.py b/tests/unit_tests/c_wrappers/res/enkf/test_enkf_sim_model.py index 8311fbeea3a..923f18c69aa 100644 --- a/tests/unit_tests/c_wrappers/res/enkf/test_enkf_sim_model.py +++ b/tests/unit_tests/c_wrappers/res/enkf/test_enkf_sim_model.py @@ -153,6 +153,21 @@ def test_forward_model_job(job, forward_model, expected_args): ["word", ""], id="Some args", ), + pytest.param( + dedent( + """ + EXECUTABLE echo + MIN_ARG 1 + MAX_ARG 2 + ARG_TYPE 0 STRING + ARG_TYPE 0 STRING + ARGLIST + """ + ), + "SIMULATION_JOB job_name arga argb", + ["arga", "argb"], + id="simulation job with arglist", + ), ], ) def test_simulation_job(job, forward_model, expected_args):