Skip to content

Commit

Permalink
refactor file
Browse files Browse the repository at this point in the history
  • Loading branch information
1ntEgr8 committed Nov 26, 2024
1 parent 84d89d2 commit bf301aa
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ def simulate(self) -> None:
This loop requires the `Workload` to be populated with the `TaskGraph`s whose
execution is to be simulated using the Scheduler.
"""

def f():
time_until_next_event = self.__time_until_next_event()
running_tasks = self._worker_pools.get_placed_tasks()
Expand Down Expand Up @@ -511,10 +512,12 @@ def f():
else:
step_size = time_until_next_event
return step_size

self.__simulate_f(should_step=f)

def tick(self, until: EventTime) -> None:
"""Tick the simulator until the specified time"""

def f():
time_until_next_event = self.__time_until_next_event()
if time_until_next_event.is_invalid():
Expand All @@ -525,18 +528,20 @@ def f():
return time_until_next_event
else:
return None

self.__simulate_f(should_step=f)

def __simulate_f(self, should_step: Callable[[EventTime], bool]) -> None:
"""TODO doc
"""
"""TODO doc"""
# Step the simulator loop.
while True:
step_size = should_step()
if not step_size:
break
self.__step(step_size=step_size)
if self._event_queue.peek() and self.__handle_event(self._event_queue.next()):
if self._event_queue.peek() and self.__handle_event(
self._event_queue.next()
):
break

def get_current_placements_for_task_graph(
Expand Down Expand Up @@ -713,7 +718,7 @@ def __create_events_from_task_placement_skip(
)
self._current_task_graph_placements[placement.task.task_graph][
placement.task.id
] = placement
] = placement

if task_graph.is_cancelled():
released_tasks_from_new_task_graph = (
Expand Down

0 comments on commit bf301aa

Please sign in to comment.