Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mining Github for fun and profit

Mining Github for fun and profit

Georgios Gousios

June 24, 2016
Tweet

More Decks by Georgios Gousios

Other Decks in Technology

Transcript

  1. api.github.com Entities Events •static view •interlinked •current state •dynamic view

    •generated by user actions •affect current entity state •can be browsing roots
  2. WatchEvent PushEvent ForkEvent . . . CreateEvent {{ "type": "WatchEvent",

    "payload": {...}, "public": true, "repo": {...}, "created_at": "2012-05-28T12:42 "id": "1556481024", "actor": {"login": "Sarukhan"} } Events
  3. repositories users organizations issues /users/:user /user/repos /repos/:user/:repo/issues /orgs/:org { "type":

    "User", "public_gists": 10, "login": "gousiosg", "followers": 64, "name": "Georgios Gousios", "public_repos": 20, "created_at": ..., "id": 386172, "following": 16, } { Entities . . .
  4. <<event>> PushEvent <<api>> /users/:user ensure_user <<api>> /repos/:user/:repo/ ensure_repo <<api>> /repos/:user/:repo/commits

    ensure_commits <<api>> /:user/:repo/sha ensure_commit <<api>> /repos/:user/:repo/ commits/:sha/comments ensure_commit_comments
  5. <<event>> PushEvent <<api>> /users/:user ensure_user <<api>> /repos/:user/:repo/ ensure_repo <<api>> /repos/:user/:repo/commits

    ensure_commits <<api>> /:user/:repo/sha ensure_commit <<api>> /users/:user/ followers ensure_followers <<api>> /repos/:user/:repo/ commits/:sha/comments ensure_commit_comments
  6. <<event>> PushEvent <<api>> /users/:user ensure_user <<api>> /repos/:user/:repo/ ensure_repo <<api>> /repos/:user/:repo/commits

    ensure_commits <<api>> /:user/:repo/sha ensure_commit <<api>> /users/:user/ followers ensure_followers <<api>> /repos/:user/:repo/ commits/:sha/comments ensure_commit_comments <<api>> /users/:user/orgs ensure_orgs
  7. <<event>> PushEvent <<api>> /users/:user ensure_user <<api>> /repos/:user/:repo/ ensure_repo <<api>> /repos/:user/:repo/commits

    ensure_commits <<api>> /:user/:repo/sha ensure_commit <<api>> /users/:user/ followers ensure_followers <<api>> /repos/:user/:repo/ commits/:sha/comments ensure_commit_comments <<api>> /users/:user/orgs ensure_orgs <<api>> /orgs/:org/teams ensure_teams
  8. <<event>> PushEvent <<api>> /users/:user ensure_user <<api>> /repos/:user/:repo/ ensure_repo <<api>> /repos/:user/:repo/commits

    ensure_commits ensure_user <<api>> /:user/:repo/sha ensure_commit <<api>> /users/:user/ followers ensure_followers <<api>> /repos/:user/:repo/ commits/:sha/comments ensure_commit_comments <<api>> /users/:user/orgs ensure_orgs <<api>> /orgs/:org/teams ensure_teams
  9. <<event>> PushEvent <<api>> /users/:user ensure_user <<api>> /repos/:user/:repo/ ensure_repo <<api>> /repos/:user/:repo/commits

    ensure_commits ensure_user <<api>> /:user/:repo/sha ensure_commit ensure_user <<api>> /users/:user/ followers ensure_followers <<api>> /repos/:user/:repo/ commits/:sha/comments ensure_commit_comments <<api>> /users/:user/orgs ensure_orgs <<api>> /orgs/:org/teams ensure_teams
  10. Github API Event Retrieval Commits Queue Project Events Queue Events

    Data Retrieval Projects Commits evt.commit evt.watch evt.fork Data Retrieval Data Retrieval Data Retrieval Mirroring Cluster Distributed data processing
  11. repositories users organizations issues /users/:user /user/repos /repos/:user/:repo/issues /orgs/:org { "type":

    "User", "public_gists": 10, "login": "gousiosg", "followers": 64, "name": "Georgios Gousios", "public_repos": 20, "created_at": ..., "id": 386172, "following": 16, } { . . . MongoDB as query-able cache
  12. Roll your own dataset $ gem install sqlite3 bundler $

    git clone https://github.com/gousiosg/github-mirror $ cd github-mirror $ bundle install $ mv config.yaml.standalone > config.yaml $ ruby -Ilib bin/ght-retrieve-repo -t token rails rails
  13. Statistics Since Feb 2012 12TB in MongoDB 4.5B rows in

    MySQL 2GB per hour 120k API reqs/hour 46 user donated API keys G. Gousios, “The GHTorrent dataset and tool suite,” in MSR, 2013: 233-236 130+ users, 80+ institutions 80+ papers 3 data mining challenges 2 best paper awards G. Gousios and D. Spinellis, “ GHTorrent: GitHub’s Data from a Firehose,” in MSR, 2012, 12–21
  14. MongoDB MySQL Diff 2016/2013 Events 476 11.1x Users 6,7 9,2

    8.4x Repos 28 25,5 21.8x Commits 367 362 12.3x Issues 24,1 25,3 10.3x Pull requests 11,9 11,1 9.7x Issue comments 42 43 14.6x Watchers 51 37 6.6x G. Gousios, The Evolution of GHTorrent: Growing an Open Access Dataset 10x Growth
  15. 1000 10000 100000 2012 2013 2014 2015 2016 Date Number

    of events Event Type CommitCommentEvent FollowEvent ForkEvent IssueCommentEvent IssuesEvent MemberEvent PullRequestEvent PullRequestReviewCommentEvent PushEvent TeamAddEvent WatchEvent G. Gousios, The Evolution of GHTorrent: Growing an Open Access Dataset 10x
  16. 0 100000 200000 300000 2012 2013 2014 2015 2016 Date

    Number of events Event Type CommitCommentEvent FollowEvent ForkEvent IssueCommentEvent IssuesEvent MemberEvent PullRequestEvent PullRequestReviewCommentEvent PushEvent TeamAddEvent WatchEvent G. Gousios, The Evolution of GHTorrent: Growing an Open Access Dataset 10x
  17. Here are my changes Please fix those issues Here are

    my updates Looks great, thanks! contributor integrator changes integrated changes examined changes re- examined
  18. Across 5k repos/ ~1M pull requests 85% merged, 70% with

    merge button 80% < 150 lines, < 7 files, 3 commits 66% < 1 day to merge 80% 4 comments, 3 participants Mostly rejected due to observability/awareness issues (not technical!) G. Gousios, M. Pinzger, and A. van Deursen, “An Exploratory Study of the Pull-based Software Development Model,” ICSE 2014, pp. 345–355 What factors affect PR acceptance?
  19. G. Gousios et al., “Distributed software development with pull requests”.

    Unpublished. Which factors affect PR acceptance? Do we know the submitter? Can we handle the workload? How ready is our project for PRs? What does the PR look like?
  20. G. Gousios et al., “Distributed software development with pull requests”.

    Unpublished. Which factors affect PR acceptance? Do we know the submitter? Can we handle the workload? How ready is our project for PRs? Do we know the submitter? What does the PR look like?
  21. G. Gousios et al., “Distributed software development with pull requests”.

    Unpublished. Which factors affect PR acceptance? Do we know the submitter? Can we handle the workload? How ready is our project for PRs? Can we handle the workload? What does the PR look like?
  22. G. Gousios et al., “Distributed software development with pull requests”.

    Unpublished. Which factors affect PR acceptance? Do we know the submitter? Can we handle the workload? How ready is our project for PRs? What does the PR look like? What does the PR look like?
  23. G. Gousios et al., “Distributed software development with pull requests”.

    Unpublished. Which factors affect PR acceptance? Do we know the submitter? Can we handle the workload? How ready is our project for PRs? What does the PR look like? How ready is our project for PRs?
  24. Can we handle the workload? G. Gousios et al., “Distributed

    software development with pull requests”. Unpublished. Which factors affect the time to process PRs? Do we know the submitter? How ready is our project for PRs? What does the PR look like?
  25. Can we handle the workload? G. Gousios et al., “Distributed

    software development with pull requests”. Unpublished. Which factors affect the time to process PRs? Do we know the submitter? How ready is our project for PRs? What does the PR look like? Can we handle the workload?
  26. Can we handle the workload? G. Gousios et al., “Distributed

    software development with pull requests”. Unpublished. Which factors affect the time to process PRs? Do we know the submitter? How ready is our project for PRs? What does the PR look like? Do we know the submitter?
  27. Can we handle the workload? G. Gousios et al., “Distributed

    software development with pull requests”. Unpublished. Which factors affect the time to process PRs? Do we know the submitter? How ready is our project for PRs? What does the PR look like? How ready is our project for PRs?
  28. Can we handle the workload? G. Gousios et al., “Distributed

    software development with pull requests”. Unpublished. Which factors affect the time to process PRs? Do we know the submitter? How ready is our project for PRs? What does the PR look like? What does the PR look like?
  29. Survey of 650 integrators Generally, few complains about the process

    Points of pain are mostly social (workload, drive-by PRs, explaining rejection) Needed tools Quality analysis Impact analysis Work prioritization G. Gousios, A. Zaidman, M.-A. Storey, and A. van Deursen, “Work Practices and Challenges in Pull-Based Development: The Integrator’s Perspective,” ICSE 2015, pp. 358–368. What do integrators actually believe?
  30. Survey of 640 contributors. Similar issues, reversed Awareness Asynchrony Responsiveness

    G. Gousios, M.-A. Storey, and A. Bacchelli, “Work Practices and Challenges in Pull-Based Development: The Contributor’s Perspective,” ICSE, 2016. What do contributors actually believe?
  31. Decide change Code/Check quality Submit Discuss intentions Feedback Code review

    Submit Proposed fixes Discuss fixes Code review Accept Code/Check quality contributors integrators
  32. Decide change Code/Check quality Submit Discuss intentions Feedback Code review

    Submit Proposed fixes Discuss fixes Code review Accept Code/Check quality contributors integrators
  33. Which are ?  IMPORTANT     

                 
  34. Which are ?  IMPORTANT     

                  Day 1 Day 2 Day 3 Day 4
  35. Which are ?  IMPORTANT     

           Day 1 Day 2 Day 3 Day 4
  36. Which are ?  IMPORTANT     

           Day 1 Day 2 Day 3 Day 4
  37. Which are ?  IMPORTANT     

           Day 1 Day 2 Day 3 Day 4 
  38. Which are ?  IMPORTANT     

           Day 1 Day 2 Day 3 Day 4  
  39. Which are ?  IMPORTANT     

                Day 1 Day 2 Day 3 Day 4  
  40. Which are ?  IMPORTANT     

                Day 1 Day 2 Day 3 Day 4 
  41. Which are ?  IMPORTANT     

                Day 1 Day 2 Day 3 Day 4  
  42. Which are ?  IMPORTANT     

                  Day 1 Day 2 Day 3 Day 4  
  43. Which are ?  IMPORTANT     

                  Day 1 Day 2 Day 3 Day 4   IMPORTANT = about to be active
  44. Precision Recall AUC Accuracy Random Forests 0.66 0.63 0.89 0.86

    Naive Bayes 0.34 0.79 0.75 0.60 Logistic regression 0.36 0.84 0.81 0.62 E. van der Veen, G. Gousios, and A. Zaidman, “Automatically Prioritizing Pull Requests,” MSR, 2015, pp. 357–361.
  45. Precision Recall AUC Accuracy Random Forests 0.66 0.63 0.89 0.86

    Naive Bayes 0.34 0.79 0.75 0.60 Logistic regression 0.36 0.84 0.81 0.62 E. van der Veen, G. Gousios, and A. Zaidman, “Automatically Prioritizing Pull Requests,” MSR, 2015, pp. 357–361.
  46. Openess perf reports How open is your project to community

    contributions? • 5k projects • every 15 days http://ghtorrent.org/pullreq-perf
  47. Reviewer recommendation Yue Yu, Huaimin Wang, Gang Yin, Tao Wang,

    Reviewer recommendation for pull- requests in GitHub: What can we learn from code review and bug assignment?,IST, 2016 Exploit @mention networks to propose top-3 reviewers for incoming pull requests. Accuracy ~60% on top-3 recommendation
  48. Automated code review Vincent J. Hellendoorn, Premkumar T. Devanbu, and

    Alberto Bacchelli. 2015. Will they like this?: evaluating code contributions with language models. MSR ’15, pp157-167 Examine how “natural” the PR code is WRT the project’s code base. Accepted PRs are significantly similar to the project More debated PRs are significantly less similar
  49. Gender and Tenure Vasilescu, Posnett, Ray, van den Brand, Serebrenik,

    Devanbu, and Filkov. Gender and Tenure Diversity in GitHub Teams. CHI. 2015 “Our study suggests that, overall, when forming or recruiting a software team, increased gender and tenure diversity are associated with greater productivity.”
  50. Geographical equality A. Rastogi, N. Nagappan, and G. Gousios, “All

    contributors are equal; some contributors are more equal than others,”, TR, 2016 Traces of bias on contributions from certain countries • Contributors perceive it • Integrator’s do not
  51. Gender & Contributions Terrell J, Kofink A, Middleton J, Rainear

    C, Murphy-Hill E, Parnin C. (2016) Gender bias in open source: Pull request acceptance of women versus men. PeerJ PrePrints 4:e1733v1 When gender is identifiable: women rejected more often When gender is not identifiable: women accepted more often
  52. I am not a lawyer! • Other commenters are no

    lawyers either • The law is complicated and open to interpretation
  53. Two important issues • Copyright: Who owns the data? •

    Privacy: How does GHTorrent protect users from personal data misuse?
  54. Copyright —General terms • For original content, the publisher maintains

    full copyright by default • Licenses restrict the effect of copyright • Events (e.g. the fact that an issue comment was created) are not copyrightable, but their content may be
  55. Copyright — GitHub’s POV • GitHub: We claim no intellectual

    property rights over the material you provide to the Service. (TOS F.1) • Structure of API responses is GitHub’s IP • Several fields in API responses may contain copyrighted material
  56. Copyright situation example { "id": "4141500869", "type": "IssueCommentEvent", "actor": {},

    "repo": {}, "payload": { "action": "created", "issue": { "id": 158442053, "number": 138, "title": "Issue in CopyrightedProjectName", "user": {}, "labels": [], "state": "closed", "body": "Added data holding classes and a map manager. Will add a system soon" }, "comment": { "created_at": "2016-06-14T05:51:16Z", "updated_at": "2016-06-14T05:51:16Z", "body": "continuing in #141 \r\n" } } }
  57. Copyright situation example { "id": "4141500869", "type": "IssueCommentEvent", "actor": {},

    "repo": {}, "payload": { "action": "created", "issue": { "id": 158442053, "number": 138, "title": "Issue in CopyrightedProjectName", "user": {}, "labels": [], "state": "closed", "body": "Added data holding classes and a map manager. Will add a system soon" }, "comment": { "created_at": "2016-06-14T05:51:16Z", "updated_at": "2016-06-14T05:51:16Z", "body": "continuing in #141 \r\n" } } } ©Issue initiator
  58. Copyright situation example { "id": "4141500869", "type": "IssueCommentEvent", "actor": {},

    "repo": {}, "payload": { "action": "created", "issue": { "id": 158442053, "number": 138, "title": "Issue in CopyrightedProjectName", "user": {}, "labels": [], "state": "closed", "body": "Added data holding classes and a map manager. Will add a system soon" }, "comment": { "created_at": "2016-06-14T05:51:16Z", "updated_at": "2016-06-14T05:51:16Z", "body": "continuing in #141 \r\n" } } } ©Issue initiator ©Issue commenter
  59. Copyright situation example { "id": "4141500869", "type": "IssueCommentEvent", "actor": {},

    "repo": {}, "payload": { "action": "created", "issue": { "id": 158442053, "number": 138, "title": "Issue in CopyrightedProjectName", "user": {}, "labels": [], "state": "closed", "body": "Added data holding classes and a map manager. Will add a system soon" }, "comment": { "created_at": "2016-06-14T05:51:16Z", "updated_at": "2016-06-14T05:51:16Z", "body": "continuing in #141 \r\n" } } } ©Project Name ©Issue initiator ©Issue commenter
  60. Copyright situation example { "id": "4141500869", "type": "IssueCommentEvent", "actor": {},

    "repo": {}, "payload": { "action": "created", "issue": { "id": 158442053, "number": 138, "title": "Issue in CopyrightedProjectName", "user": {}, "labels": [], "state": "closed", "body": "Added data holding classes and a map manager. Will add a system soon" }, "comment": { "created_at": "2016-06-14T05:51:16Z", "updated_at": "2016-06-14T05:51:16Z", "body": "continuing in #141 \r\n" } } } ©GitHub ©Project Name ©Issue initiator ©Issue commenter
  61. Privacy is the ability of an individual or group to

    seclude themselves, or information about themselves, and thereby express themselves selectively.
  62. Privacy provisions — EU • Personal data identify a person

    uniquely • Facts are not personal data • GHTorrent processes personal data, therefore is a controller • Controllers must • get consent for processing (except in the case of legitimate interest) • include mechanisms for opting out
  63. Privacy provisions — USA • No single law/directive • Consent

    only required for specific types of data storage (e.g. social security numbers) • Offering an opting out mechanism
  64. What did GHTorrent do? • Stopped distributing user names and

    emails in MySQL data dumps • Researchers can “sign” a form to get access to private data • Created an opt-out process • In the process of creating Terms of Fair Use
  65. A question of research ethics Can we, in the name

    of science, • send emails to developers? • create developer profiles? • recommend work to developers? • rank developers based on contributions? • compare project characteristics? • characterise community practices?