Skip to content

Commit

Permalink
Fix issue with the is_wrapper attribute (#2033)
Browse files Browse the repository at this point in the history
* Fix issue with the wrapper attribute

* Fix issue with the wrapper attribute
  • Loading branch information
dbeltrankyl authored and Irene Simo Munoz committed Dec 23, 2024
1 parent 6e3646f commit e60f421
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions autosubmit/job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,19 @@ def __init__(self, name, job_id, status, priority):
self.wrapper_name = None
self.is_wrapper = False

def _adjust_new_parameters(self) -> None:
"""
Adjusts job parameters for compatibility with newer added attributes.
"""
# This function is always called at the start of a new run ( from update_parameters )
if not hasattr(self, 'is_wrapper'): # Added in 4.1.12
if not self.packed:
self.is_wrapper = False
self.wrapper_name = self.name
else:
self.is_wrapper = True
self.wrapper_name = "wrapped"

def _init_runtime_parameters(self):
# hetjobs
self.het = {'HETSIZE': 0}
Expand Down Expand Up @@ -2030,6 +2043,7 @@ def update_parameters(self, as_conf, parameters,
:type parameters: dict
"""
as_conf.reload()
self._adjust_new_parameters()
self._init_runtime_parameters()
if hasattr(self, "start_time"):
self.start_time = time.time()
Expand Down
16 changes: 16 additions & 0 deletions test/unit/test_job_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,19 @@ def test_update_parameters_attributes(
assert hasattr(job, attr)
assert getattr(job, attr) == attributes_to_check[attr] if type(
attributes_to_check[attr]) is not list else attributes_to_check[attr][0]

@pytest.mark.parametrize('test_packed', [
False,
True,
], ids=["Simple job", "Wrapped job"])
def test_adjust_new_parameters(test_packed):
job = Job('dummy', '1', 0, 1)
del job.is_wrapper
del job.wrapper_name
job.packed = test_packed
job._adjust_new_parameters()
assert job.is_wrapper == test_packed
if test_packed:
assert job.wrapper_name == "wrapped"
else:
assert job.wrapper_name == "dummy"

0 comments on commit e60f421

Please sign in to comment.