Skip to content

Commit

Permalink
Rename Job.__call__ to job.run in scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-eq committed Apr 10, 2024
1 parent 6f49e28 commit bae11c0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ert/scheduler/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async def _submit_and_run_once(self, sem: asyncio.BoundedSemaphore) -> None:
timeout_task.cancel()
sem.release()

async def __call__(
async def run(
self, start: asyncio.Event, sem: asyncio.BoundedSemaphore, max_submit: int = 2
) -> None:
self._requested_max_submit = max_submit
Expand Down
2 changes: 1 addition & 1 deletion src/ert/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ async def execute(
sem = asyncio.BoundedSemaphore(self._max_running or len(self._jobs))
for iens, job in self._jobs.items():
self._job_tasks[iens] = asyncio.create_task(
job(start, sem, self._max_submit), name=f"job-{iens}_task"
job.run(start, sem, self._max_submit), name=f"job-{iens}_task"
)

start.set()
Expand Down
10 changes: 5 additions & 5 deletions tests/unit_tests/scheduler/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def test_submitted_job_is_cancelled(realization, mock_event):
],
)
@pytest.mark.asyncio
async def test_call(
async def test_run(
return_code: int,
max_submit: int,
forward_model_ok_result,
Expand All @@ -112,23 +112,23 @@ async def test_call(
job = Job(scheduler, realization)
job.started.set()

job_call_task = asyncio.create_task(
job(job.started, asyncio.Semaphore(), max_submit=max_submit)
job_run_task = asyncio.create_task(
job.run(job.started, asyncio.Semaphore(), max_submit=max_submit)
)

for attempt in range(max_submit):
# The execution flow through job() is manipulated through job.returncode
if attempt < max_submit - 1:
job.returncode.set_result(1)
while job.returncode.done():
# wait until __call__ (which is job()) resets
# wait until job.run() resets
# the future after seeing the failure
await asyncio.sleep(0)
else:
job.started.set()
job.returncode.set_result(return_code)

await job_call_task
await job_run_task

await assert_scheduler_events(
scheduler,
Expand Down

0 comments on commit bae11c0

Please sign in to comment.