Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Nov 10, 2023
2 parents 835d92f + 48d2dc0 commit b358c8c
Show file tree
Hide file tree
Showing 196 changed files with 5,633 additions and 5,144 deletions.
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@

[run]
branch = True

[report]
# Coverage should ignore overloads; they're not real code
exclude_lines =
@overload
\.\.\.$
raise\s+NotImplementedError
if\s+TYPE_CHECKING:
#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(cover|COVER)
6 changes: 5 additions & 1 deletion .github/workflows/python_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install pip, etc
uses: ./support/actions/python-tools
- name: Install mypy
run: pip install mypy

- name: Install Spinnaker Dependencies
uses: ./support/actions/install-spinn-deps
Expand All @@ -63,12 +65,14 @@ jobs:
coveralls-token: ${{ secrets.GITHUB_TOKEN }}

- name: Lint with flake8
run: flake8 spinn_front_end_common unittests fec_integration_tests
run: flake8 $BASE_PKG unittests fec_integration_tests
- name: Lint with pylint
uses: ./support/actions/pylint
with:
package: ${{ env.BASE_PKG }}
language: en_GB
- name: Lint with mypy
run: mypy $BASE_PKG

validate:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion .pylint_dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ LivePacketGatherMachineVertex
DataSpeedUpPacketGatherMachineVertex
ExtraMonitorSupportMachineVertex
AbstractEIEIOMessage
CommandSender
CPUState
CoreSubset
CoreSubsets
Expand Down Expand Up @@ -106,4 +107,5 @@ Struct
# sqlite3.cursor methods mentioned in docs
fetchone
lastrowid
rowcount
rowcount
WAL
4 changes: 3 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=R,C
disable=R,C,unsubscriptable-object
# False positives for unsubscriptable-object. Mypy better at this class of issue
# See https://github.com/pylint-dev/pylint/issues/1498

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _chips_differ(self, chip1, chip2):
if (chip1 == chip2):
return False
if len(chip1) != len(chip2):
raise True
return True
for i in range(len(chip1)):
if chip1[i] == chip2[i]:
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from spinn_front_end_common.utilities.database import DatabaseReader


class TestSplitter(AbstractSplitterCommon):
class MockSplitter(AbstractSplitterCommon):
def create_machine_vertices(self, chip_counter):
pass

Expand All @@ -56,10 +56,10 @@ def reset_called(self):
pass


class TestAppVertex(ApplicationVertex):
class MockAppVertex(ApplicationVertex):
def __init__(self, n_atoms, label):
super(TestAppVertex, self).__init__(
label=label, splitter=TestSplitter())
super(MockAppVertex, self).__init__(
label=label, splitter=MockSplitter())
self.__n_atoms = n_atoms

@property
Expand Down Expand Up @@ -111,8 +111,8 @@ def test_database_interface():
writer = FecDataWriter.mock()
placements = Placements()

app_vertex_1 = TestAppVertex(100, "test_1")
app_vertex_2 = TestAppVertex(200, "test_2")
app_vertex_1 = MockAppVertex(100, "test_1")
app_vertex_2 = MockAppVertex(200, "test_2")
writer.add_vertex(app_vertex_1)
writer.add_vertex(app_vertex_2)
writer.add_edge(ApplicationEdge(app_vertex_1, app_vertex_2), "Test")
Expand All @@ -124,7 +124,7 @@ def test_database_interface():
writer.add_vertex(lpg_vertex)
writer.add_edge(ApplicationEdge(app_vertex_1, lpg_vertex), "Test")

lpg_vertex.splitter.create_vertices(placements)
lpg_vertex.splitter.create_sys_vertices(placements)
_place_vertices(app_vertex_1, placements, [(0, 0)])
_place_vertices(app_vertex_2, placements, [(0, 1), (1, 1)])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def __init__(self, test_case):
self._executable_on_core = dict()

@overrides(MockableTransceiver.execute_flood)
def execute_flood(self, core_subsets, executable, app_id, *,
n_bytes=None, wait=False): # @UnusedVariable
def execute_flood(
self, core_subsets, executable, app_id, *,
n_bytes=None, wait=False, is_filename=False): # @UnusedVariable
for core_subset in core_subsets.core_subsets:
x = core_subset.x
y = core_subset.y
x, y = core_subset.x, core_subset.y
for p in core_subset.processor_ids:
self._test_case.assertNotIn(
(x, y, p), self._executable_on_core)
Expand Down
5 changes: 2 additions & 3 deletions fec_integration_tests/mock_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
from spinnman.messages.sdp import SDPMessage, SDPHeader, SDPFlag
from spinnman.messages.scp import SCPRequestHeader
from spinnman.messages.scp.enums import SCPResult
from spinnman.connections.udp_packet_connections import (
utils, UDPConnection)
from spinnman.connections.udp_packet_connections import UDPConnection


class _SCPOKMessage(SDPMessage):
Expand All @@ -31,7 +30,7 @@ def __init__(self, x, y, sequence):
sdp_header = SDPHeader(
flags=SDPFlag.REPLY_NOT_EXPECTED, destination_port=0,
destination_cpu=0, destination_chip_x=x, destination_chip_y=y)
utils.update_sdp_header_for_udp_send(sdp_header, 0, 0)
sdp_header.update_for_send(0, 0)
super().__init__(sdp_header, data=scp_header.bytestring)


Expand Down
2 changes: 1 addition & 1 deletion fec_local_tests/test_java_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class TestJavaCaller(unittest.TestCase):

def setUp(cls):
def setUp(self):
unittest_setup()

def test_creation(self):
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[[tool.mypy.overrides]]
module = ["scipy"]
ignore_missing_imports = true
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ include =
*.aplx
*.dict
*.sql
py.typed

[options.extras_require]
test =
# pytest will be brought in by pytest-cov
pytest-cov
testfixtures
httpretty != 1.0.0
types-jsonschema
types-requests
plotting =
matplotlib
seaborn
Expand Down
4 changes: 2 additions & 2 deletions spinn_front_end_common/abstract_models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
from .abstract_can_reset import AbstractCanReset
from .has_custom_atom_key_map import HasCustomAtomKeyMap

__all__ = ["AbstractGeneratesDataSpecification",
__all__ = ("AbstractGeneratesDataSpecification",
"AbstractHasAssociatedBinary",
"AbstractRewritesDataSpecification",
"AbstractSendMeMulticastCommandsVertex",
"AbstractSupportsDatabaseInjection",
"AbstractVertexWithEdgeToDependentVertices", "AbstractCanReset",
"AbstractSupportsBitFieldGeneration",
"AbstractSupportsBitFieldRoutingCompression",
"HasCustomAtomKeyMap"]
"HasCustomAtomKeyMap")
5 changes: 3 additions & 2 deletions spinn_front_end_common/abstract_models/abstract_can_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ class AbstractCanReset(object, metaclass=AbstractBase):
All Vertices and all edges in the original graph
(the one added to by the user) will be checked and reset.
"""
__slots__ = []
__slots__ = ()

@abstractmethod
def reset_to_first_timestep(self):
def reset_to_first_timestep(self) -> None:
"""
Reset the object to first time step.
"""
raise NotImplementedError
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,27 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations
from typing import TYPE_CHECKING
from spinn_utilities.abstract_base import AbstractBase, abstractmethod
from spinn_utilities.require_subclass import require_subclass
from pacman.model.placements import Placement
from .abstract_has_associated_binary import AbstractHasAssociatedBinary
if TYPE_CHECKING:
from spinn_front_end_common.interface.ds import DataSpecificationGenerator


@require_subclass(AbstractHasAssociatedBinary)
class AbstractGeneratesDataSpecification(object, metaclass=AbstractBase):

"""
A machine vertex that generates a data specification that describes what
its binary's initialisation data is.
"""
__slots__ = ()

@abstractmethod
def generate_data_specification(self, spec, placement):
def generate_data_specification(
self, spec: DataSpecificationGenerator, placement: Placement):
"""
Generate a data specification.
Expand All @@ -32,3 +40,4 @@ def generate_data_specification(self, spec, placement):
:param ~pacman.model.placements.Placement placement:
The placement the vertex is located at
"""
raise NotImplementedError
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from spinn_utilities.abstract_base import AbstractBase, abstractmethod
from spinn_utilities.require_subclass import require_subclass
from pacman.model.graphs.machine import MachineVertex
from spinnman.model.enums import ExecutableType
# mypy: disable-error-code=empty-body


@require_subclass(MachineVertex)
Expand All @@ -26,17 +28,19 @@ class AbstractHasAssociatedBinary(object, metaclass=AbstractBase):
__slots__ = ()

@abstractmethod
def get_binary_file_name(self):
def get_binary_file_name(self) -> str:
"""
Get the binary name to be run for this vertex.
:rtype: str
"""
raise NotImplementedError

@abstractmethod
def get_binary_start_type(self):
def get_binary_start_type(self) -> ExecutableType:
"""
Get the start type of the binary to be run.
:rtype: ~spinnman.model.enum.ExecutableType
"""
raise NotImplementedError
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations
from typing import TYPE_CHECKING
from spinn_utilities.abstract_base import AbstractBase, abstractmethod
from spinn_utilities.require_subclass import require_subclass
from pacman.model.placements import Placement
from .abstract_generates_data_specification import (
AbstractGeneratesDataSpecification)
if TYPE_CHECKING:
from spinn_front_end_common.interface.ds import DataSpecificationReloader


@require_subclass(AbstractGeneratesDataSpecification)
Expand All @@ -25,10 +29,11 @@ class AbstractRewritesDataSpecification(object, metaclass=AbstractBase):
and so can rewrite the data specification.
"""

__slots__ = []
__slots__ = ()

@abstractmethod
def regenerate_data_specification(self, spec, placement):
def regenerate_data_specification(
self, spec: DataSpecificationReloader, placement: Placement):
"""
Regenerate the data specification, only generating regions that
have changed and need to be reloaded.
Expand All @@ -38,19 +43,22 @@ def regenerate_data_specification(self, spec, placement):
:param ~pacman.model.placements.Placement placement:
Where are we regenerating for?
"""
raise NotImplementedError

@abstractmethod
def reload_required(self):
def reload_required(self) -> bool:
"""
Return true if any data region needs to be reloaded.
:rtype: bool
"""
raise NotImplementedError

@abstractmethod
def set_reload_required(self, new_value):
def set_reload_required(self, new_value: bool):
"""
Indicate that the regions have been reloaded.
:param new_value: the new value
"""
raise NotImplementedError
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from spinn_utilities.abstract_base import AbstractBase, abstractproperty
from __future__ import annotations
from typing import Iterable, List, TYPE_CHECKING
from spinn_utilities.abstract_base import AbstractBase, abstractmethod
if TYPE_CHECKING:
from spinn_front_end_common.utility_models import MultiCastCommand
# mypy: disable-error-code=empty-body


class AbstractSendMeMulticastCommandsVertex(object, metaclass=AbstractBase):
Expand All @@ -28,29 +32,34 @@ class AbstractSendMeMulticastCommandsVertex(object, metaclass=AbstractBase):

__slots__ = ()

@abstractproperty
def start_resume_commands(self):
@property
@abstractmethod
def start_resume_commands(self) -> Iterable[MultiCastCommand]:
"""
The commands needed when starting or resuming simulation.
:rtype:
iterable(~spinn_front_end_common.utility_models.MultiCastCommand)
"""
raise NotImplementedError

@abstractproperty
def pause_stop_commands(self):
@property
@abstractmethod
def pause_stop_commands(self) -> Iterable[MultiCastCommand]:
"""
The commands needed when pausing or stopping simulation.
:rtype:
iterable(~spinn_front_end_common.utility_models.MultiCastCommand)
"""
raise NotImplementedError

@abstractproperty
def timed_commands(self):
@property
@abstractmethod
def timed_commands(self) -> List[MultiCastCommand]:
"""
The commands to be sent at given times in the simulation.
:rtype:
iterable(~spinn_front_end_common.utility_models.MultiCastCommand)
:rtype: list(~spinn_front_end_common.utility_models.MultiCastCommand)
"""
raise NotImplementedError
Loading

0 comments on commit b358c8c

Please sign in to comment.