Skip to content

Commit

Permalink
update scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
SkafteNicki committed Jan 19, 2025
1 parent 23b7909 commit 85bc1e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 4 additions & 0 deletions tools/repo_stats/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class RepoStats(BaseModel):

num_warnings: int | None

def __repr__(self):
"""Returns a string representation of the model."""
return ",".join(f"0{d=}" for d in self.model_dump().items())


class Contributor(BaseModel):
"""Model for contributors."""
Expand Down
1 change: 1 addition & 0 deletions tools/repo_stats/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pydantic==2.9.2
requests==2.32.3
numpy==2.1.3
pillow==11.0.0
loguru==0.7.3
7 changes: 2 additions & 5 deletions tools/repo_stats/scraper.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import csv
import datetime
import json
import logging
import os
from pathlib import Path

import numpy as np
import requests
from dotenv import load_dotenv
from google.cloud.storage import Client
from loguru import logger
from models import GroupInfo, RepoContent, Report, RepoStats
from typer import Typer

Expand All @@ -17,9 +17,6 @@
GH_TOKEN = os.getenv("GH_TOKEN") or os.getenv("GITHUB_TOKEN")
headers = {"Authorization": f"Bearer {GH_TOKEN}"}

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def upload_data(file_name: str) -> None:
"""Uploads the repo stats data to GCS."""
Expand Down Expand Up @@ -163,7 +160,6 @@ def main():
group_number=group.group_number, repo_api=group.repo_api, default_branch=group.default_branch
)
num_warnings = report.check_answers

else:
num_contributors = None
num_prs = None
Expand Down Expand Up @@ -211,6 +207,7 @@ def main():
actions_passing=actions_passing,
num_warnings=num_warnings,
)
logger.info(f"Repo Stats: {repo_stat}")
repo_stats.append(repo_stat)

logger.info("Writing repo stats to file")
Expand Down

0 comments on commit 85bc1e2

Please sign in to comment.