Skip to content

Conversation

@schmerl
Copy link
Collaborator

@schmerl schmerl commented Oct 29, 2021

Nodes in a LaunchConfig were sets, which breaks the ordering required for starting nodelets after nodelet managers.

for node_name, prefix in prefixes.items():
nodes[node_name] = nodes[node_name].with_launch_prefix(prefix)
return attr.evolve(self, nodes=frozenset(nodes.values()))
return attr.evolve(self, nodes=list(nodes.values()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer (immutable) tuple over list

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

m = m.format(node.full_name)
raise FailedToParseLaunchFile(m)
nodes = self.nodes | frozenset({node})
nodes = self.nodes | list(node)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at the mypy output yet, but I suspect that this is the line that's causing it to fail. The set union operator doesn't make sense for a list here. This line can just be replaced by:

nodes = self.nodes + [node]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely misread what this line was doing. Changed it to extend the tuple

nodes.add(node)
return attr.evolve(self, nodes=frozenset(nodes))
nodes.append(node)
return attr.evolve(self, nodes=nodes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beware: nodes is a list here; we probably want to convert it to a tuple before passing it to evolve (otherwise we'll get a crash on line 140)

@attr.s(frozen=True, slots=True)
class LaunchConfig:
nodes: Sequence[NodeConfig] = attr.ib(default=())
nodes: Tuple[NodeConfig, ...] = attr.ib(default=())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change? (tuples are sequences)

Copy link
Collaborator Author

@schmerl schmerl Oct 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I make it a Sequence, mypy doesn't like the '+' operation.

src/roswire/common/launch/config/launch.py:140: error: Unsupported left operand type for + ("Sequence[NodeConfig]")

Is there a way around this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants