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

KeyError: 'from' when adding links #248

Closed
KasiaKoz opened this issue Nov 13, 2024 · 0 comments · Fixed by #249
Closed

KeyError: 'from' when adding links #248

KasiaKoz opened this issue Nov 13, 2024 · 0 comments · Fixed by #249
Assignees
Labels
bug Something isn't working

Comments

@KasiaKoz
Copy link
Collaborator

In a very specific scenario---when adding links to graph where edges were removed, opening up multi edge indices up for grabs---the following error appears:

        self.graph.add_edges_from(
            [
                (
>                   attribs["from"],
                    attribs["to"],
                    add_to_link_id_mapping[link]["multi_edge_idx"],
                    attribs,
                )
                for link, attribs in links_and_attributes.items()
            ]
        )
E       KeyError: 'from'

../src/genet/core.py:1345: KeyError

This only happens sometimes. We rely on networkx to generate a unique multi index, so that we can have unique edges stored on a the graph between the same pair of nodes. Sometimes the method from networkx we use returns an available index that is sandwiched between the indices we already use (it was been freed by an earlier operation on the graph), and in that case, our code fails and the data for that link disappears along the way, throwing the error seen above.

@KasiaKoz KasiaKoz added the bug Something isn't working label Nov 13, 2024
@KasiaKoz KasiaKoz self-assigned this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant