From f28fbefefb8af725c29cfce71b42e877c1add6b4 Mon Sep 17 00:00:00 2001 From: Andrew Rowley Date: Thu, 10 Oct 2024 13:31:55 +0100 Subject: [PATCH 1/3] Replace deprecated function calls --- spinn_gym/games/breakout/breakout_machine_vertex.py | 4 ++-- .../double_pendulum_machine_vertex.py | 4 ++-- .../inverted_pendulum/inverted_pendulum_machine_vertex.py | 4 ++-- spinn_gym/games/logic/logic_machine_vertex.py | 4 ++-- spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py | 4 ++-- spinn_gym/games/store_recall/store_recall_machine_vertex.py | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spinn_gym/games/breakout/breakout_machine_vertex.py b/spinn_gym/games/breakout/breakout_machine_vertex.py index 9521208..1de6bba 100644 --- a/spinn_gym/games/breakout/breakout_machine_vertex.py +++ b/spinn_gym/games/breakout/breakout_machine_vertex.py @@ -135,8 +135,8 @@ def generate_data_specification(self, spec, placement): spec.switch_write_focus( BreakoutMachineVertex._BREAKOUT_REGIONS.BREAKOUT.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_first_key_from_pre_vertex( - vertex, constants.SPIKE_PARTITION_ID)) + spec.write_value(routing_info.get_single_first_key_from_pre_vertex( + vertex)) if self.app_vertex.source_vertex is None: raise ValueError( "The breakout vertex doesn't have a source vertex!") diff --git a/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py b/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py index 12bc043..242b7ee 100644 --- a/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py +++ b/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py @@ -162,8 +162,8 @@ def generate_data_specification(self, spec, placement): spec.switch_write_focus( self._DOUBLE_PENDULUM_REGIONS.PENDULUM.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_first_key_from_pre_vertex( - vertex, constants.SPIKE_PARTITION_ID)) + spec.write_value(routing_info.get_single_first_key_from_pre_vertex( + vertex)) # Write recording region for score spec.comment("\nWriting double pendulum recording region:\n") diff --git a/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py b/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py index 3501fe9..954a684 100644 --- a/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py +++ b/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py @@ -160,8 +160,8 @@ def generate_data_specification(self, spec, placement): spec.switch_write_focus( self._PENDULUM_REGIONS.PENDULUM.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_first_key_from_pre_vertex( - vertex, constants.SPIKE_PARTITION_ID)) + spec.write_value(routing_info.get_single_first_key_from_pre_vertex( + vertex)) # Write recording region for score spec.comment("\nWriting pendulum recording region:\n") diff --git a/spinn_gym/games/logic/logic_machine_vertex.py b/spinn_gym/games/logic/logic_machine_vertex.py index 34d1775..b251df3 100644 --- a/spinn_gym/games/logic/logic_machine_vertex.py +++ b/spinn_gym/games/logic/logic_machine_vertex.py @@ -145,8 +145,8 @@ def generate_data_specification(self, spec, placement): spec.switch_write_focus( self._LOGIC_REGIONS.LOGIC.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_first_key_from_pre_vertex( - vertex, constants.SPIKE_PARTITION_ID)) + spec.write_value(routing_info.get_single_first_key_from_pre_vertex( + vertex)) # Write recording region for score spec.comment("\nWriting logic recording region:\n") diff --git a/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py b/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py index f116819..aba4908 100644 --- a/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py +++ b/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py @@ -155,8 +155,8 @@ def generate_data_specification(self, spec, placement): spec.switch_write_focus( self._BANDIT_REGIONS.BANDIT.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_first_key_from_pre_vertex( - vertex, constants.SPIKE_PARTITION_ID)) + spec.write_value(routing_info.get_single_first_key_from_pre_vertex( + vertex)) # Write recording region for score spec.comment("\nWriting bandit recording region:\n") diff --git a/spinn_gym/games/store_recall/store_recall_machine_vertex.py b/spinn_gym/games/store_recall/store_recall_machine_vertex.py index a1bcea1..9d6dc4c 100644 --- a/spinn_gym/games/store_recall/store_recall_machine_vertex.py +++ b/spinn_gym/games/store_recall/store_recall_machine_vertex.py @@ -149,8 +149,8 @@ def generate_data_specification(self, spec, placement): spec.switch_write_focus( self._RECALL_REGIONS.RECALL.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_first_key_from_pre_vertex( - vertex, constants.SPIKE_PARTITION_ID)) + spec.write_value(routing_info.get_single_first_key_from_pre_vertex( + vertex)) # Write recording region for score spec.comment("\nWriting recall recording region:\n") From 4fc9f33fc8cac7f505023d53087ec7859ba323d5 Mon Sep 17 00:00:00 2001 From: Andrew Rowley Date: Thu, 10 Oct 2024 14:12:05 +0100 Subject: [PATCH 2/3] This has to be done this way --- spinn_gym/games/breakout/breakout_machine_vertex.py | 5 +++-- .../double_pendulum_machine_vertex.py | 5 +++-- .../inverted_pendulum/inverted_pendulum_machine_vertex.py | 5 +++-- spinn_gym/games/logic/logic_machine_vertex.py | 6 ++++-- spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py | 5 +++-- spinn_gym/games/store_recall/store_recall_machine_vertex.py | 5 +++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/spinn_gym/games/breakout/breakout_machine_vertex.py b/spinn_gym/games/breakout/breakout_machine_vertex.py index d6c5163..3fe9366 100644 --- a/spinn_gym/games/breakout/breakout_machine_vertex.py +++ b/spinn_gym/games/breakout/breakout_machine_vertex.py @@ -38,6 +38,7 @@ from spynnaker.pyNN.data import SpynnakerDataView from spynnaker.pyNN.models.common import PopulationApplicationVertex +from spynnaker.pyNN.utilities.constants import SPIKE_PARTITION_ID # spinn_gym imports from spinn_gym.games import SpinnGymMachineVertex @@ -149,8 +150,8 @@ def generate_data_specification( spec.switch_write_focus( BreakoutMachineVertex._BREAKOUT_REGIONS.BREAKOUT.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_single_first_key_from_pre_vertex( - vertex)) + spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + vertex, SPIKE_PARTITION_ID)) if self.app_vertex.source_vertex is None: raise ValueError( "The breakout vertex doesn't have a source vertex!") diff --git a/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py b/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py index c3bdce1..2bb740b 100644 --- a/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py +++ b/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py @@ -33,6 +33,7 @@ # sPyNNaker imports from spynnaker.pyNN.data import SpynnakerDataView +from spynnaker.pyNN.utilities.constants import SPIKE_PARTITION_ID # spinn_gym imports from spinn_gym.games import SpinnGymMachineVertex @@ -166,8 +167,8 @@ def generate_data_specification( spec.switch_write_focus( self._DOUBLE_PENDULUM_REGIONS.PENDULUM.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_single_first_key_from_pre_vertex( - vertex)) + spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + vertex, SPIKE_PARTITION_ID)) # Write recording region for score spec.comment("\nWriting double pendulum recording region:\n") diff --git a/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py b/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py index b2d4a48..c78f92b 100644 --- a/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py +++ b/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py @@ -36,6 +36,7 @@ # sPyNNaker imports from spynnaker.pyNN.data import SpynnakerDataView +from spynnaker.pyNN.utilities.constants import SPIKE_PARTITION_ID # spinn_gym imports from spinn_gym.games import SpinnGymMachineVertex @@ -164,8 +165,8 @@ def generate_data_specification( spec.switch_write_focus( self._PENDULUM_REGIONS.PENDULUM.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_single_first_key_from_pre_vertex( - vertex)) + spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + vertex, SPIKE_PARTITION_ID)) # Write recording region for score spec.comment("\nWriting pendulum recording region:\n") diff --git a/spinn_gym/games/logic/logic_machine_vertex.py b/spinn_gym/games/logic/logic_machine_vertex.py index 3f94612..467a10e 100644 --- a/spinn_gym/games/logic/logic_machine_vertex.py +++ b/spinn_gym/games/logic/logic_machine_vertex.py @@ -37,6 +37,8 @@ # sPyNNaker imports from spynnaker.pyNN.data import SpynnakerDataView +from spynnaker.pyNN.utilities.constants import SPIKE_PARTITION_ID + # spinn_gym imports from spinn_gym.games import SpinnGymMachineVertex @@ -148,8 +150,8 @@ def generate_data_specification( spec.switch_write_focus( self._LOGIC_REGIONS.LOGIC.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_single_first_key_from_pre_vertex( - vertex)) + spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + vertex, SPIKE_PARTITION_ID)) # Write recording region for score spec.comment("\nWriting logic recording region:\n") diff --git a/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py b/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py index 9cabf08..9b985e4 100644 --- a/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py +++ b/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py @@ -37,6 +37,7 @@ # sPyNNaker imports from spynnaker.pyNN.data import SpynnakerDataView +from spynnaker.pyNN.utilities.constants import SPIKE_PARTITION_ID # spinn_gym imports from spinn_gym.games import SpinnGymMachineVertex @@ -159,8 +160,8 @@ def generate_data_specification( spec.switch_write_focus( self._BANDIT_REGIONS.BANDIT.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_single_first_key_from_pre_vertex( - vertex)) + spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + vertex, SPIKE_PARTITION_ID)) # Write recording region for score spec.comment("\nWriting bandit recording region:\n") diff --git a/spinn_gym/games/store_recall/store_recall_machine_vertex.py b/spinn_gym/games/store_recall/store_recall_machine_vertex.py index 9f49932..d237bed 100644 --- a/spinn_gym/games/store_recall/store_recall_machine_vertex.py +++ b/spinn_gym/games/store_recall/store_recall_machine_vertex.py @@ -36,6 +36,7 @@ # sPyNNaker imports from spynnaker.pyNN.data import SpynnakerDataView +from spynnaker.pyNN.utilities.constants import SPIKE_PARTITION_ID # spinn_gym imports from spinn_gym.games import SpinnGymMachineVertex @@ -153,8 +154,8 @@ def generate_data_specification( spec.switch_write_focus( self._RECALL_REGIONS.RECALL.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_single_first_key_from_pre_vertex( - vertex)) + spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + vertex, SPIKE_PARTITION_ID)) # Write recording region for score spec.comment("\nWriting recall recording region:\n") From 42b9b3853665af052b0ec69dd8d88641975cd045 Mon Sep 17 00:00:00 2001 From: Andrew Rowley Date: Mon, 14 Oct 2024 11:40:20 +0100 Subject: [PATCH 3/3] Rename functions --- spinn_gym/games/breakout/breakout_machine_vertex.py | 2 +- .../double_inverted_pendulum/double_pendulum_machine_vertex.py | 2 +- .../games/inverted_pendulum/inverted_pendulum_machine_vertex.py | 2 +- spinn_gym/games/logic/logic_machine_vertex.py | 2 +- spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py | 2 +- spinn_gym/games/store_recall/store_recall_machine_vertex.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spinn_gym/games/breakout/breakout_machine_vertex.py b/spinn_gym/games/breakout/breakout_machine_vertex.py index 3fe9366..d0b2061 100644 --- a/spinn_gym/games/breakout/breakout_machine_vertex.py +++ b/spinn_gym/games/breakout/breakout_machine_vertex.py @@ -150,7 +150,7 @@ def generate_data_specification( spec.switch_write_focus( BreakoutMachineVertex._BREAKOUT_REGIONS.BREAKOUT.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + spec.write_value(routing_info.get_key_from( vertex, SPIKE_PARTITION_ID)) if self.app_vertex.source_vertex is None: raise ValueError( diff --git a/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py b/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py index 2bb740b..ba3936a 100644 --- a/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py +++ b/spinn_gym/games/double_inverted_pendulum/double_pendulum_machine_vertex.py @@ -167,7 +167,7 @@ def generate_data_specification( spec.switch_write_focus( self._DOUBLE_PENDULUM_REGIONS.PENDULUM.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + spec.write_value(routing_info.get_key_from( vertex, SPIKE_PARTITION_ID)) # Write recording region for score diff --git a/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py b/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py index c78f92b..378ea90 100644 --- a/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py +++ b/spinn_gym/games/inverted_pendulum/inverted_pendulum_machine_vertex.py @@ -165,7 +165,7 @@ def generate_data_specification( spec.switch_write_focus( self._PENDULUM_REGIONS.PENDULUM.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + spec.write_value(routing_info.get_key_from( vertex, SPIKE_PARTITION_ID)) # Write recording region for score diff --git a/spinn_gym/games/logic/logic_machine_vertex.py b/spinn_gym/games/logic/logic_machine_vertex.py index 467a10e..80d73f6 100644 --- a/spinn_gym/games/logic/logic_machine_vertex.py +++ b/spinn_gym/games/logic/logic_machine_vertex.py @@ -150,7 +150,7 @@ def generate_data_specification( spec.switch_write_focus( self._LOGIC_REGIONS.LOGIC.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + spec.write_value(routing_info.get_key_from( vertex, SPIKE_PARTITION_ID)) # Write recording region for score diff --git a/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py b/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py index 9b985e4..676f090 100644 --- a/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py +++ b/spinn_gym/games/multi_arm_bandit/bandit_machine_vertex.py @@ -160,7 +160,7 @@ def generate_data_specification( spec.switch_write_focus( self._BANDIT_REGIONS.BANDIT.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + spec.write_value(routing_info.get_key_from( vertex, SPIKE_PARTITION_ID)) # Write recording region for score diff --git a/spinn_gym/games/store_recall/store_recall_machine_vertex.py b/spinn_gym/games/store_recall/store_recall_machine_vertex.py index d237bed..1b4163c 100644 --- a/spinn_gym/games/store_recall/store_recall_machine_vertex.py +++ b/spinn_gym/games/store_recall/store_recall_machine_vertex.py @@ -154,7 +154,7 @@ def generate_data_specification( spec.switch_write_focus( self._RECALL_REGIONS.RECALL.value) routing_info = SpynnakerDataView.get_routing_infos() - spec.write_value(routing_info.get_safe_first_key_from_pre_vertex( + spec.write_value(routing_info.get_key_from( vertex, SPIKE_PARTITION_ID)) # Write recording region for score