Skip to content

Commit

Permalink
Fixes wrapper warning message at the end closes #2035 (#2037)
Browse files Browse the repository at this point in the history
* Fixes wrapper warning message at the end

* Added typing suggestion
  • Loading branch information
dbeltrankyl authored Dec 18, 2024
1 parent 7b3e226 commit 451a25c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
13 changes: 13 additions & 0 deletions autosubmit/job/job_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ def build_packages(self):
built_packages_tmp = self._build_vertical_packages(jobs, wrapper_limits, wrapper_info=current_info)
if len(built_packages_tmp) > 0:
Log.result(f"Built {len(built_packages_tmp)} wrappers for {wrapper_name}")
self._propagate_inner_jobs_ready_date(built_packages_tmp)
packages_to_submit, max_jobs_to_submit = self.check_packages_respect_wrapper_policy(built_packages_tmp, packages_to_submit, max_jobs_to_submit, wrapper_limits, any_simple_packages)

# Now, prepare the packages for non-wrapper jobs
Expand Down Expand Up @@ -641,6 +642,18 @@ def build_packages(self):

return packages_to_submit

@staticmethod
def _propagate_inner_jobs_ready_date(built_packages_tmp: List[JobPackageBase]) -> None:
"""
Propagate the ready date of the inner jobs to the wrapper job.
:param built_packages_tmp: List of built packages.
"""
for package in built_packages_tmp:
if len(package.jobs) > 1:
for job in package.jobs[1:]:
job.ready_date = package.jobs[0].ready_date

def _divide_list_by_section(self, jobs_list):
"""
Returns a dict() with as many keys as 'jobs_list' different sections
Expand Down
27 changes: 27 additions & 0 deletions test/unit/test_job_packager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import time
import pytest

from autosubmit.job.job import Job
from autosubmit.job.job_common import Status
from autosubmit.job.job_packages import JobPackageVertical
from autosubmit.job.job_packager import JobPackager


@pytest.fixture
def setup(autosubmit_config, tmpdir, mocker):
job1 = Job("SECTION1", 1, Status.READY, 0)
job2 = Job("SECTION1", 1, Status.READY, 0)
job3 = Job("SECTION1", 1, Status.READY, 0)
wrapper_jobs = [job1, job2, job3]
packages = [mocker.MagicMock(spec=JobPackageVertical)]
packages[0].jobs = wrapper_jobs
yield packages, wrapper_jobs


def test_propagate_inner_jobs_ready_date(setup):
packages, wrapper_jobs = setup
current_time = time.time()
wrapper_jobs[0].ready_date = current_time
JobPackager._propagate_inner_jobs_ready_date(packages)
for job in wrapper_jobs:
assert job.ready_date == current_time

0 comments on commit 451a25c

Please sign in to comment.