Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run_safe #284

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions gfe_integration_tests/test_profile/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,44 @@
# limitations under the License.

import os
import spinnaker_graph_front_end as s
from gfe_integration_tests.test_profile.profiled_vertex import ProfiledVertex

from spinn_front_end_common.data.fec_data_view import FecDataView
from spinnaker_testbase import BaseTestCase

import spinnaker_graph_front_end as s
from gfe_integration_tests.test_profile.profiled_vertex import ProfiledVertex

def test_profile():
s.setup(model_binary_folder=os.path.dirname(__file__))
vertex = ProfiledVertex()
s.add_machine_vertex_instance(vertex)
s.run(50)
class TestProfile(BaseTestCase):

place = FecDataView.get_placement_of_vertex(vertex)
folder = FecDataView.get_app_provenance_dir_path()
def check_profile_data(self):
s.setup(model_binary_folder=os.path.dirname(__file__))
vertex = ProfiledVertex()
s.add_machine_vertex_instance(vertex)
s.run(50)

s.stop()
place = FecDataView.get_placement_of_vertex(vertex)
folder = FecDataView.get_app_provenance_dir_path()

profile_file = os.path.join(
folder, f"{place.x}_{place.y}_{place.p}_profile.txt")
assert os.path.exists(profile_file)
s.stop()

with open(profile_file, "r") as f:
# Headings and lines
f.readline()
f.readline()
profile_file = os.path.join(
folder, f"{place.x}_{place.y}_{place.p}_profile.txt")
assert os.path.exists(profile_file)

# Next 2 lines should have profile data
for i in range(2):
line = f.readline()
parts = line.split()
assert len(parts) == 5
assert parts[0] == "SDRAMWrite" or parts[0] == "DTCMWrite"
assert int(parts[1]) == 25
assert float(parts[3]) == 1.0
assert float(parts[2]) == float(parts[4])
with open(profile_file, "r") as f:
# Headings and lines
f.readline()
f.readline()

# Next 2 lines should have profile data
for i in range(2):
line = f.readline()
parts = line.split()
assert len(parts) == 5
assert parts[0] == "SDRAMWrite" or parts[0] == "DTCMWrite"
assert int(parts[1]) == 25
assert float(parts[3]) == 1.0
assert float(parts[2]) == float(parts[4])

if __name__ == "__main__":
test_profile()
def test_profile_data(self):
self.runsafe(self.check_profile_data)
30 changes: 19 additions & 11 deletions gfe_integration_tests/test_rte/test_rte_during_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,28 @@
import os
import traceback
import pytest

from spinnman.exceptions import SpinnmanException
from spinnman.model.enums import ExecutableType
from spinnaker_testbase import BaseTestCase

import spinnaker_graph_front_end as s
from gfe_integration_tests.test_rte.run_vertex import RunVertex


def test_rte_during_run():
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(RunVertex(
"test_rte_during_run.aplx",
ExecutableType.USES_SIMULATION_INTERFACE))
with pytest.raises(SpinnmanException):
try:
s.run(1000)
except Exception:
traceback.print_exc()
raise
class TestRteDuringRun(BaseTestCase):

def check_rte_during_run(self):
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(RunVertex(
"test_rte_during_run.aplx",
ExecutableType.USES_SIMULATION_INTERFACE))
with pytest.raises(SpinnmanException):
try:
s.run(1000)
except Exception:
traceback.print_exc()
raise

def test_rte_during_run(self):
self.runsafe(self.check_rte_during_run)
36 changes: 20 additions & 16 deletions gfe_integration_tests/test_rte/test_rte_during_run_forever.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,36 @@
# limitations under the License.

import os
import pytest
from time import sleep

from spinnman.model.enums import ExecutableType
from spinn_front_end_common.utilities.exceptions import (
ExecutableFailedToStopException)
from spinn_front_end_common.utilities.database import DatabaseConnection
from spinnaker_testbase import BaseTestCase

import spinnaker_graph_front_end as s
from gfe_integration_tests.test_rte.run_vertex import RunVertex
import pytest


def test_rte_during_run_forever():
class TestRteDuringRunForever(BaseTestCase):

def start():
sleep(3.0)
s.stop_run()
def check_rte_during_run_forever(self):

with DatabaseConnection(start, local_port=None) as conn:
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(RunVertex(
"test_rte_during_run.aplx",
ExecutableType.USES_SIMULATION_INTERFACE))
s.add_socket_address(None, "localhost", conn.local_port)
s.run(None)
with pytest.raises(ExecutableFailedToStopException):
s.stop()
def start():
sleep(3.0)
s.stop_run()

with DatabaseConnection(start, local_port=None) as conn:
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(RunVertex(
"test_rte_during_run.aplx",
ExecutableType.USES_SIMULATION_INTERFACE))
s.add_socket_address(None, "localhost", conn.local_port)
s.run(None)
with pytest.raises(ExecutableFailedToStopException):
s.stop()

if __name__ == "__main__":
test_rte_during_run_forever()
def test_rte_during_run_forever(self):
self.runsafe(self.check_rte_during_run_forever)
24 changes: 16 additions & 8 deletions gfe_integration_tests/test_rte/test_rte_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@

import os
import pytest

from spinnman.exceptions import SpinnmanException
from spinnman.model.enums import ExecutableType
from spinnaker_testbase import BaseTestCase

import spinnaker_graph_front_end as s
from gfe_integration_tests.test_rte.run_vertex import RunVertex


def test_rte_at_start():
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(
RunVertex(
"test_rte_start.aplx",
ExecutableType.USES_SIMULATION_INTERFACE))
with pytest.raises(SpinnmanException):
s.run(1000)
class TestRteStart(BaseTestCase):

def check_rte_at_start(self):
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(
RunVertex(
"test_rte_start.aplx",
ExecutableType.USES_SIMULATION_INTERFACE))
with pytest.raises(SpinnmanException):
s.run(1000)

def test_rte_at_start(self):
self.runsafe(self.check_rte_at_start)
22 changes: 15 additions & 7 deletions gfe_integration_tests/test_rte/test_run_too_long.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@

import os
import pytest

from spinnman.exceptions import SpinnmanTimeoutException
from spinnman.model.enums import ExecutableType
from spinnaker_testbase import BaseTestCase

import spinnaker_graph_front_end as s
from gfe_integration_tests.test_rte.run_vertex import RunVertex


def test_run_too_long():
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(RunVertex(
"test_run_too_long.aplx",
ExecutableType.USES_SIMULATION_INTERFACE))
with pytest.raises(SpinnmanTimeoutException):
s.run(1000)
class TestRunTooLong(BaseTestCase):

def check_run_too_long(slef):
s.setup(model_binary_folder=os.path.dirname(__file__))
s.add_machine_vertex_instance(RunVertex(
"test_run_too_long.aplx",
ExecutableType.USES_SIMULATION_INTERFACE))
with pytest.raises(SpinnmanTimeoutException):
s.run(1000)

def test_run_too_long(self):
self.runsafe(self.check_run_too_long)