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

docs: popular issues file generator #4971

Merged
merged 6 commits into from
Jun 10, 2024
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
136 changes: 136 additions & 0 deletions argilla-sdk/docs/scripts/gen_popular_issues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Copyright 2024-present, Argilla, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from datetime import datetime

import pandas as pd
import requests
import mkdocs_gen_files


REPOSITORY = "argilla-io/argilla"
DATA_PATH = "community/popular_issues.md"

GITHUB_ACCESS_TOKEN = os.environ["GITHUB_ACCESS_TOKEN"]


def fetch_data_from_github(repository, auth_token):
headers = {"Authorization": f"token {auth_token}", "Accept": "application/vnd.github.v3+json"}
issues_data = []

print(f"Fetching issues from {repository}...")
with requests.Session() as session:
session.headers.update(headers)

owner, repo_name = repository.split("/")
issues_url = f"https://api.github.com/repos/{owner}/{repo_name}/issues?state=all"

while issues_url:
response = session.get(issues_url)
issues = response.json()

for issue in issues:
issues_data.append(
{
"Issue": f"{issue['number']} - {issue['title']}",
"State": issue["state"],
"Created at": issue["created_at"],
"Closed at": issue.get("closed_at", None),
"Last update": issue["updated_at"],
"Labels": [label["name"] for label in issue["labels"]],
"Milestone": (issue.get("milestone") or {}).get("title"),
"Reactions": issue["reactions"]["total_count"],
"Comments": issue["comments"],
"URL": issue["html_url"],
"Repository": repo_name,
"Author": issue["user"]["login"],
}
)

issues_url = response.links.get("next", {}).get("url", None)

return pd.DataFrame(issues_data)


def get_org_members(auth_token):
headers = {"Authorization": f"token {auth_token}", "Accept": "application/vnd.github.v3+json"}
members_list = []

members_url = "https://api.github.com/orgs/argilla-io/members"

while members_url:
response = requests.get(members_url, headers=headers)
members = response.json()

for member in members:
members_list.append(member["login"])

members_list.extend(["pre-commit-ci[bot]"])

members_url = response.links.get("next", {}).get("url", None)

return members_list


with mkdocs_gen_files.open(DATA_PATH, "w") as f:
df = fetch_data_from_github(REPOSITORY, GITHUB_ACCESS_TOKEN)

open_issues = df.loc[df["State"] == "open"]
engagement_df = (
open_issues[["URL", "Issue", "Repository", "Reactions", "Comments"]]
.sort_values(by=["Reactions", "Comments"], ascending=False)
.head(10)
.reset_index()
)

members = get_org_members(GITHUB_ACCESS_TOKEN)
community_issues = df.loc[~df["Author"].isin(members)]
community_issues_df = (
community_issues[["URL", "Issue", "Repository", "Created at", "Author", "State"]]
.sort_values(by=["Created at"], ascending=False)
.head(10)
.reset_index()
)

planned_issues = df.loc[df["Milestone"].notna()]
planned_issues_df = (
planned_issues[["URL", "Issue", "Repository", "Created at", "Milestone", "State"]]
.sort_values(by=["Milestone"], ascending=False)
.head(10)
.reset_index()
)

f.write('=== "Most engaging open issues"\n\n')
f.write(" | Rank | Issue | Reactions | Comments |\n")
f.write(" |------|-------|:---------:|:--------:|\n")
for ix, row in engagement_df.iterrows():
f.write(f" | {ix+1} | [{row['Issue']}]({row['URL']}) | 👍 {row['Reactions']} | 💬 {row['Comments']} |\n")

f.write('\n=== "Latest issues open by the community"\n\n')
f.write(" | Rank | Issue | Author |\n")
f.write(" |------|-------|:------:|\n")
for ix, row in community_issues_df.iterrows():
state = "🟢" if row["State"] == "open" else "🟣"
f.write(f" | {ix+1} | {state} [{row['Issue']}]({row['URL']}) | by **{row['Author']}** |\n")

f.write('\n=== "Planned issues for upcoming releases"\n\n')
f.write(" | Rank | Issue | Milestone |\n")
f.write(" |------|-------|:------:|\n")
for ix, row in planned_issues_df.iterrows():
state = "🟢" if row["State"] == "open" else "🟣"
f.write(f" | {ix+1} | {state} [{row['Issue']}]({row['URL']}) | **{row['Milestone']}** |\n")

today = datetime.today().date()
f.write(f"\nLast update: {today}\n")
2 changes: 2 additions & 0 deletions argilla-sdk/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ plugins:
- gen-files:
scripts:
- docs/scripts/gen_changelog.py
- docs/scripts/gen_popular_issues.py
# - docs/scripts/gen_ref_pages.py
- literate-nav:
nav_file: SUMMARY.md
Expand Down Expand Up @@ -145,6 +146,7 @@ nav:
- Community:
- community/index.md
- How to contribute?: community/contributor.md
- Issue dashboard: community/popular_issues.md
- Changelog: community/changelog.md
- UI Demo ↗:
- https://demo.argilla.io/sign-in?auth=ZGVtbzoxMjM0NTY3OA==
Loading