Skip to content

Commit

Permalink
Fix some typing
Browse files Browse the repository at this point in the history
Also added return value to _add_realization as that is expected by other
functions
  • Loading branch information
JHolba authored and berland committed Nov 21, 2023
1 parent 8e94c28 commit 01d351f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/_ert_job_runner/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def ensure_file_handles_closed():
f"Most likely you are missing and should add "
f"'#!/usr/bin/env python' to the top of the file: "
)
stderr.write(msg)
if stderr is not None:
stderr.write(msg)
ensure_file_handles_closed()
yield Exited(self, e.errno).with_error(msg)
return
Expand Down
4 changes: 2 additions & 2 deletions src/ert/job_queue/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def has_option(self, option_key: str) -> bool:
return option_key in self._options

@abstractmethod
async def submit(self, realization: "QueueableRealization"):
async def submit(self, realization: "RealizationState"):
pass

@abstractmethod
async def poll_statuses(self):
pass

@abstractmethod
async def kill(self, realization: "QueueableRealization"):
async def kill(self, realization: "RealizationState"):
pass

@classmethod
Expand Down
8 changes: 5 additions & 3 deletions src/ert/job_queue/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import logging
import ssl
from collections import deque
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union

from cloudevents.conversion import to_json
Expand Down Expand Up @@ -159,10 +160,11 @@ def kill_all_jobs(self) -> None:
def queue_size(self) -> int:
return len(self._realizations)

def _add_realization(self, realization: QueueableRealization) -> None:
def _add_realization(self, realization: QueueableRealization) -> int:
self._realizations.append(
RealizationState(self, realization, retries=self._queue_config.max_submit - 1)
)
return len(self._realizations) - 1

def max_running(self) -> int:
max_running = 0
Expand Down Expand Up @@ -360,7 +362,7 @@ def add_realization_from_run_arg(
num_cpu: int,
) -> None:
qreal = QueueableRealization(
job_script=job_script,
job_script=Path(job_script),
run_arg=run_arg,
num_cpu=num_cpu,
max_runtime=max_runtime,
Expand All @@ -374,7 +376,7 @@ def add_realization(
callback_timeout: Optional[Callable[[int], None]] = None,
) -> None:
qreal = QueueableRealization(
job_script=real.job_script,
job_script=Path(real.job_script),
num_cpu=real.num_cpu,
run_arg=real.run_arg,
max_runtime=real.max_runtime,
Expand Down

0 comments on commit 01d351f

Please sign in to comment.