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

Document repo analytics #2317

Merged
merged 3 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 18 additions & 0 deletions .github/analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Repo Analytics

To run the repo analytics follow the steps below:

1. You must have a Github token, if you don't have one you can create one by following [this guide](https://docs.github.com/en/enterprise-server@3.4/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).
2. Install the requirements:

```bash
pip install -r .github/analytics/requirements.txt
```
3. Run the analytics:

```bash
GITHUB_TOKEN=<token> \
python .github/analytics/get_repo_metrics.py \
--repo-owner google \
--repo-name flax
```
15 changes: 10 additions & 5 deletions .github/analytics/get_repo_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from datetime import datetime
from pathlib import Path
from typing import Callable, List
from absl import app, flags

import pandas as pd
import requests
Expand Down Expand Up @@ -300,10 +301,14 @@ def _process_issues(df: pd.DataFrame) -> pd.Series:
#-----------------------------------------------------------------------------
# main
#-----------------------------------------------------------------------------
def main(
repo_owner: str = 'google',
repo_name: str = 'flax',
):
FLAGS = flags.FLAGS
flags.DEFINE_string('repo_owner', 'google', 'User name or organization')
flags.DEFINE_string('repo_name', 'flax', 'Name of the repository')

def main(_):
repo_owner: str = FLAGS.repo_owner
repo_name: str = FLAGS.repo_name

# Download issue data
issues = GithubGrabber(
'.github/analytics/issue_activity_since_date.gql',
Expand Down Expand Up @@ -407,4 +412,4 @@ def main(
plt.show()

if __name__ == '__main__':
main()
app.run(main)
4 changes: 4 additions & 0 deletions .github/analytics/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pandas
absl-py
requests
matplotlib
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"tensorflow_datasets",
"tensorflow",
"torch",
"pandas", # get_repo_metrics script
]

__version__ = None
Expand Down