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

assert not None #584

Merged
merged 5 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 9 additions & 7 deletions pacman/model/tags/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ def add_ip_tag(self, ip_tag: IPTag, vertex: MachineVertex):
raise PacmanInvalidParameterException(
"ip_tag", str(ip_tag), "Only add IP tags with this method.")
existing_tag = None
if (ip_tag.board_address, ip_tag.tag) in self._ip_tags:
existing_tag = self._ip_tags[ip_tag.board_address, ip_tag.tag]
board_address = ip_tag.board_address
assert board_address is not None
Christian-B marked this conversation as resolved.
Show resolved Hide resolved
if (board_address, ip_tag.tag) in self._ip_tags:
existing_tag = self._ip_tags[board_address, ip_tag.tag]
if (existing_tag.ip_address != ip_tag.ip_address or
not utility_calls.is_equal_or_none(
existing_tag.port, ip_tag.port) or
Expand All @@ -92,7 +94,7 @@ def add_ip_tag(self, ip_tag: IPTag, vertex: MachineVertex):
" the given board")

if existing_tag is None:
self._ip_tags[(ip_tag.board_address, ip_tag.tag)] = ip_tag
self._ip_tags[(board_address, ip_tag.tag)] = ip_tag
self._ip_tags_by_vertex[vertex].append(ip_tag)
else:
self._ip_tags_by_vertex[vertex].append(existing_tag)
Expand Down Expand Up @@ -133,13 +135,13 @@ def add_reverse_ip_tag(
"reverse_ip_tag", reverse_ip_tag,
"The port has already been assigned on the given board")

board_address = reverse_ip_tag.board_address
assert board_address is not None
self._reverse_ip_tags[
(reverse_ip_tag.board_address,
reverse_ip_tag.tag)] = reverse_ip_tag
(board_address, reverse_ip_tag.tag)] = reverse_ip_tag
self._reverse_ip_tags_by_vertex[vertex].append(reverse_ip_tag)
if reverse_ip_tag.port is not None:
self._ports_assigned.add(
(reverse_ip_tag.board_address, reverse_ip_tag.port))
self._ports_assigned.add((board_address, reverse_ip_tag.port))

@property
def ip_tags_vertices(self) -> Iterable[Tuple[IPTag, MachineVertex]]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ def __find_free_tag(
def __create_tag(
eth_chip: Chip, placement: Placement, iptag: IPtagResource,
tag: int) -> IPTag:
tag_ip = iptag.ip_address
assert tag_ip is not None
return IPTag(
eth_chip.ip_address, placement.x, placement.y,
tag, iptag.ip_address, iptag.port,
tag, tag_ip, iptag.port,
iptag.strip_sdp, iptag.traffic_identifier)


Expand Down