gotec / git2net

An Open Source Python package for the extraction of fine-grained and time-stamped co-editing networks from git repositories.
https://git2net.readthedocs.io
GNU Affero General Public License v3.0
53 stars 16 forks source link

KeyError: 'weight' when running get_coauthorship_network #28

Closed lisette-espin closed 2 years ago

lisette-espin commented 2 years ago

Hi, I managed to run successfully the tutorial from beginning to end!

However, when I re-run this line: n, node_info, edge_info = git2net.get_coauthorship_network(sqlite_db_file)

I get this error: KeyError: 'weight' on line 468 from /pathpy/classes/network.py

The first time I run it (following the tutorial) the sql_db_file was smaller than the second time I run it. The first time the db had only those actions with max_modifications=5 and the second time it had no limit.

So, If I load the whole network from the beginning (without specifying max_modifications), and follow the tutorial as is, and then re-run git2net.get_coauthorship_network the error does not occur.

gotec commented 2 years ago

Similar to #27, I am unfortunately not able to replicate the issue. What I tried is adding the following lines at the end of the tutorial, which, if I understand your description correctly, should reproduce the error:

n, node_info, edge_info = git2net.get_coauthorship_network(sqlite_db_file)
n

The good news is that all your issues appear to be related to pathpy2. The version of pathpy that is currently actively developed is pathpy3, which, while still being in alpha, already has a number of features currently lacking from pathpy2. These are particularly related to the network visualisation. Over the last weeks, I have been working on changing git2net to use pathpy3 instead of pathpy2. If all goes well, I am planning to release this update next week. This should then also resolve your issues.

In the mean time, you could try to reinstall pathpy2 and see if this resolves your issues. Also, if you could send me a minimal example reproducing the issue for you I am happy to look into this.

Cheers, Christoph

lisette-espin commented 2 years ago

I re-install pathpy2 and still got the 'weight' error :-/ Anyway, I think by loading the whole network from the beginning (without max_modifications) is fine for me for now.

I'm looking forward to the new version! Thanks!

gotec commented 2 years ago

I found out that while I had the correct version of git2net installed, python was still using an older version of git2net on a local path. This is also why my code ran without the line for the disambiguation in #27.

Fixing the path, I was able to reproduce your issue. I also now understand where it is coming from. While in the tutorial we disambiguated the database after mining it, we then included additional commits with the second mining process for which the authors were not disambiguated. Thus, when calling the visualisation again after that, pathpy threw an error (albeit a rather strange one).

I have now added a check in the visualisation functions to deal with this and updated the tutorial (see commit 672af3b). I will include these changes in a new version of git2net after #27 is also resolved for you.

Cheers, Christoph

gotec commented 2 years ago

resolved in git2net 1.5.3