Skip to content

Commit

Permalink
Update signatures for pybind
Browse files Browse the repository at this point in the history
Fix job_queue test patch
  • Loading branch information
andreas-el committed Sep 21, 2023
1 parent 9e77268 commit cd2f87d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
7 changes: 2 additions & 5 deletions src/ert/job_queue/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ def _queue_state_event_type(state: str) -> str:
# pylint: disable=too-many-public-methods
class JobQueue(BaseCClass): # type: ignore
TYPE_NAME = "job_queue"
_alloc = ResPrototype("void* job_queue_alloc()", bind=False)
_alloc = ResPrototype("void* job_queue_alloc(void*)", bind=False)
_free = ResPrototype("void job_queue_free( job_queue )")
_set_driver = ResPrototype("void job_queue_set_driver( job_queue , void* )")

_add_job = ResPrototype("int job_queue_add_job_node(job_queue, job_queue_node)")

def __repr__(self) -> str:
Expand All @@ -112,11 +110,10 @@ def __init__(self, driver: "Driver", max_submit: int = 2):

self.job_list: List[JobQueueNode] = []
self._stopped = False
c_ptr = self._alloc(STATUS_file, ERROR_file)
c_ptr = self._alloc(driver.from_param(driver))
super().__init__(c_ptr)

self.driver = driver
self._set_driver(driver.from_param(driver))
self._differ = QueueDiffer()
self._max_job_duration = 0
self._max_submit = max_submit
Expand Down
19 changes: 8 additions & 11 deletions tests/unit_tests/job_queue/test_job_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,14 @@ def test_stop_long_running():
job_list[i]._start_time = 0
job_list[i]._end_time = 5

# The driver is of no consequence, so resolving it in the c layer is
# uninteresting and mocked out.
with patch("ert.job_queue.JobQueue._set_driver"):
queue = JobQueue(MagicMock())

# We don't need the c layer call here, we only need it added to
# the queue's job_list.
with patch("ert.job_queue.JobQueue._add_job") as _add_job:
for idx, job in enumerate(job_list):
_add_job.return_value = idx
queue.add_job(job, idx)
queue = JobQueue(MagicMock())

# We don't need the c layer call here, we only need it added to
# the queue's job_list.
with patch("ert.job_queue.JobQueue._add_job") as _add_job:
for idx, job in enumerate(job_list):
_add_job.return_value = idx
queue.add_job(job, idx)

queue.stop_long_running_jobs(5)
queue._differ.transition(queue.job_list)
Expand Down

0 comments on commit cd2f87d

Please sign in to comment.