Skip to content
Snippets Groups Projects
Commit a1b9f24c authored by Simon Bjurek's avatar Simon Bjurek
Browse files

Updated pre commit config versions and added a sort y on start time method...

Updated pre commit config versions and added a sort y on start time method used by schedulers and scheduling GUI.
parent f42c18bb
No related branches found
No related tags found
1 merge request!476Updated pre commit config versions and added a sort y on start time method
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0 rev: v5.0.0
hooks: hooks:
- id: mixed-line-ending - id: mixed-line-ending
exclude_types: [svg] exclude_types: [svg]
...@@ -14,17 +14,17 @@ repos: ...@@ -14,17 +14,17 @@ repos:
- id: check-toml - id: check-toml
- repo: https://github.com/crate-ci/typos - repo: https://github.com/crate-ci/typos
rev: v1.22.9 rev: v1.29.9
hooks: hooks:
- id: typos - id: typos
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 24.4.2 rev: 25.1.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/pycqa/isort - repo: https://github.com/pycqa/isort
rev: 5.13.2 rev: 6.0.0
hooks: hooks:
- id: isort - id: isort
name: isort (python) name: isort (python)
...@@ -36,17 +36,17 @@ repos: ...@@ -36,17 +36,17 @@ repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version. # Ruff version.
rev: "v0.5.0" rev: "v0.9.7"
hooks: hooks:
- id: ruff - id: ruff
- repo: https://github.com/adamchainz/blacken-docs - repo: https://github.com/adamchainz/blacken-docs
rev: 1.18.0 rev: 1.19.1
hooks: hooks:
- id: blacken-docs - id: blacken-docs
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v3.16.0 rev: v3.19.1
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: [--py38-plus] args: [--py38-plus]
......
...@@ -575,7 +575,7 @@ class Schedule: ...@@ -575,7 +575,7 @@ class Schedule:
if change_in_latency > (self.forward_slack(op.graph_id)): if change_in_latency > (self.forward_slack(op.graph_id)):
passed = False passed = False
raise ValueError( raise ValueError(
f"Error: Can't increase latency for all components. Try increassing forward slack time by rescheduling. " f"Error: Can't increase latency for all components. Try increasing forward slack time by rescheduling. "
f"Error in: {op.graph_id}" f"Error in: {op.graph_id}"
) )
break break
...@@ -894,6 +894,12 @@ class Schedule: ...@@ -894,6 +894,12 @@ class Schedule:
self._y_locations[graph_id] = y_location self._y_locations[graph_id] = y_location
return operation_gap + y_location * (operation_height + operation_gap) return operation_gap + y_location * (operation_height + operation_gap)
def sort_y_locations_on_start_times(self):
for i, graph_id in enumerate(
sorted(self._start_times, key=self._start_times.get)
):
self.set_y_location(graph_id, i)
def _plot_schedule(self, ax: Axes, operation_gap: float = OPERATION_GAP) -> None: def _plot_schedule(self, ax: Axes, operation_gap: float = OPERATION_GAP) -> None:
"""Draw the schedule.""" """Draw the schedule."""
line_cache = [] line_cache = []
......
...@@ -120,6 +120,8 @@ class ASAPScheduler(Scheduler): ...@@ -120,6 +120,8 @@ class ASAPScheduler(Scheduler):
self._handle_outputs(schedule, non_schedulable_ops) self._handle_outputs(schedule, non_schedulable_ops)
schedule.remove_delays() schedule.remove_delays()
schedule.sort_y_locations_on_start_times()
class ALAPScheduler(Scheduler): class ALAPScheduler(Scheduler):
"""Scheduler that implements the as-late-as-possible (ALAP) algorithm.""" """Scheduler that implements the as-late-as-possible (ALAP) algorithm."""
...@@ -151,6 +153,8 @@ class ALAPScheduler(Scheduler): ...@@ -151,6 +153,8 @@ class ALAPScheduler(Scheduler):
if not isinstance(outport.operation, Delay): if not isinstance(outport.operation, Delay):
schedule.move_operation_alap(outport.operation.graph_id) schedule.move_operation_alap(outport.operation.graph_id)
schedule.sort_y_locations_on_start_times()
class ListScheduler(Scheduler, ABC): class ListScheduler(Scheduler, ABC):
def __init__( def __init__(
...@@ -314,6 +318,8 @@ class ListScheduler(Scheduler, ABC): ...@@ -314,6 +318,8 @@ class ListScheduler(Scheduler, ABC):
schedule.start_times[dc_op.graph_id] = 0 schedule.start_times[dc_op.graph_id] = 0
schedule.move_operation_alap(dc_op.graph_id) schedule.move_operation_alap(dc_op.graph_id)
schedule.sort_y_locations_on_start_times()
def _get_next_op_id( def _get_next_op_id(
self, ready_ops_priority_table: list[tuple["GraphID", int, ...]] self, ready_ops_priority_table: list[tuple["GraphID", int, ...]]
) -> "GraphID": ) -> "GraphID":
......
...@@ -313,9 +313,8 @@ class SchedulerItem(SchedulerEvent, QGraphicsItemGroup): # PySide2 / PyQt5 ...@@ -313,9 +313,8 @@ class SchedulerItem(SchedulerEvent, QGraphicsItemGroup): # PySide2 / PyQt5
def _redraw_from_start(self) -> None: def _redraw_from_start(self) -> None:
self.schedule._reset_y_locations() self.schedule._reset_y_locations()
for graph_id in dict( self.schedule.sort_y_locations_on_start_times()
sorted(self.schedule.start_times.items(), key=lambda item: item[1]) for graph_id in self.schedule.start_times.keys():
):
self._set_position(graph_id) self._set_position(graph_id)
self._redraw_all_lines() self._redraw_all_lines()
self._update_axes() self._update_axes()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment