From 636a744192ba06d759b2639a106bff93537d96ad Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Wed, 3 Jan 2024 23:18:46 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80first=20successful=20data=20collect?= =?UTF-8?q?ion=20and=20dump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- README.md | 6 ++++++ data/data.csv | 2 ++ startrack/app.py | 52 +++++++++++++++++++++++++++++++++++++++-------- startrack/core.py | 20 ++++++++++++++++++ 5 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 data/data.csv diff --git a/.gitignore b/.gitignore index 352ba42..ca5e3f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ venv/ -idea/ \ No newline at end of file +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index 37ae6f5..1e998a0 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,9 @@ Star-Track is a user-friendly utility for tracking GitHub repository statistics. ```bash pip install -r requirements.txt ``` + +## ⚙️ execute + +```bash +python -m startrack.app +``` \ No newline at end of file diff --git a/data/data.csv b/data/data.csv new file mode 100644 index 0000000..9b75351 --- /dev/null +++ b/data/data.csv @@ -0,0 +1,2 @@ +,roboflow/TFRecords,roboflow/voc2coco,roboflow/heatmap.node,roboflow/BCCD_Dataset,roboflow/tensorflow-object-detection-faster-rcnn,roboflow/yolov3,roboflow/cornelius,roboflow/EfficientDet,roboflow/Monk_Object_Detection,roboflow/synthetic-fruit-dataset,roboflow/floodfill.js,roboflow/keras-yolo3,roboflow/fast-ai-resnet32,roboflow/roboflow-node,roboflow/darknet,roboflow/roboflow-python,roboflow/pytorch-YOLOv4,roboflow/tfjs-models,roboflow/ScaledYOLOv4,roboflow/roboflow-nest,roboflow/supabase-js,roboflow/streamlit-bccd,roboflow/tfjs,roboflow/inference-server-old,roboflow/jetson,roboflow/firebaseui-web,roboflow/video-inference,roboflow/roboflow-api-snippets,roboflow/roboflow-jetson-license-plate,roboflow/blobconverter,roboflow/rabbit-deterrence,roboflow/yolor,roboflow/YOLOX,roboflow/roboflow-object-tracking,roboflow/neuralhash-collisions,roboflow/zero-shot-object-tracking,roboflow/tensorrtx,roboflow/blackjack-basic-strategy,roboflow/yolov5-custom-training-tutorial,roboflow/server-benchmark,roboflow/ghost-detector,roboflow/neuralhash_prefix_caption,roboflow/yolov5,roboflow/markdown-it-imsize,roboflow/smooth-frame,roboflow/rickblocker,roboflow/RoboflowExpoExample,roboflow/roboflow-100-benchmark,roboflow/expo-image-picker-multiple,roboflow/YOLOv6,roboflow/FastMOT,roboflow/.github,roboflow/stacked-boxes-email-notification,roboflow/template-python,roboflow/tao-toolkit-with-roboflow,roboflow/external-bugtracker,roboflow/dji-aerial-georeferencing,roboflow/roboflow-ios-starter,roboflow/clip-benchmark,roboflow/roboflow-computer-vision-utilities,roboflow/roboflow-react-app,roboflow/cra-template-roboflow-react-app,roboflow/OBS-Controller,roboflow/yolov7,roboflow/roboflow-100-3d-website,roboflow/stable-diffusion-demo,roboflow/roboflow-cli,roboflow/deploy-models-with-grpc-pytorch-asyncio,roboflow/notebooks,roboflow/supervision,roboflow/ppe-detection,roboflow/auto-annotate,roboflow/streamlit-web-app,roboflow/rtsp-server,roboflow/trt-demos,roboflow/cookbooks,roboflow/ultralytics-roboflow,roboflow/supashim,roboflow/quickstart-python,roboflow/homepage-demo,roboflow/polygonzone,roboflow/magic-scissors,roboflow/ODinW-RF100-challenge-issues,roboflow/scavenger-hunt,roboflow/roboflow-collect,roboflow/celebrity-doppelganger,roboflow/cvevals,roboflow/GroundingDINO_old,roboflow/segment-anything,roboflow/yolov8-OpenVINO,roboflow/roboflow-swift,roboflow/GroundingDINO,roboflow/roboflow-swift-examples,roboflow/Grounded-Segment-Anything,roboflow/ultralytics-yolov8-seg-coreml-nms,roboflow/inference,roboflow/roboflow-swift-macos,roboflow/inference-client,roboflow/inference-dashboard-example,roboflow/lenny,roboflow/roboflow-red,roboflow/CLIP,roboflow/universe-widget,roboflow/supervision-annotators-hf-space,roboflow/clip_video_app,roboflow/roboflow_cloud_upload,roboflow/webcamGPT,roboflow/awesome-openai-vision-api-experiments,roboflow/ezautodistill,roboflow/foundation-vision-benchmark,roboflow/gpt-checkup,roboflow/SoM,roboflow/multimodal-maestro,roboflow/cog-vlm-client,autodistill/autodistill-clip,autodistill/autodistill-owl-vit,autodistill/autodistill-detic,autodistill/autodistill-yolov5,autodistill/autodistill-detr,autodistill/autodistill-yolonas,autodistill/autodistill,autodistill/autodistill-grounded-sam,autodistill/autodistill-yolov8,autodistill/.github,autodistill/autodistill-grounding-dino,autodistill/autodistill-vit,autodistill/autodistill-dinov2,autodistill/autodistill-sam-clip,autodistill/autodistill-base-model-template,autodistill/autodistill-target-model-template,autodistill/autodistill-blip,autodistill/autodistill-albef,autodistill/autodistill-open-flamingo,autodistill/autodistill-fastsam,autodistill/autodistill-blipv2,autodistill/autodistill-seggpt,autodistill/autodistill-llava,autodistill/autodistill-fastvit,autodistill/autodistill-kosmos-2,autodistill/autodistill-fuyu,autodistill/autodistill-metaclip,autodistill/autodistill-owlv2,autodistill/autodistill-rekognition,autodistill/autodistill-azure-vision,autodistill/autodistill-gcp-vision,autodistill/autodistill-gpt-4v,autodistill/autodistill-roboflow-universe,autodistill/autodistill-altclip,autodistill/autodistill-codet,autodistill/autodistill-vlpart,autodistill/autodistill-transformers,autodistill/autodistill-hls-geospatial,autodistill/autodistill-segment-anything,autodistill/autodistill-sam-hq,autodistill/sam-hq,autodistill/SLiMe,autodistill/autodistill-remote-clip,autodistill/autodistill-grounded-edgesam,autodistill/EdgeSAM,autodistill/autodistill-gemini +2024-01-03,2,99,1,1,78,11,0,2,19,3,1,18,2,3,57,163,34,1,2,7,0,3,0,13,0,0,39,17,3,0,14,5,14,1,147,343,0,24,8,0,0,1,4,0,1,11,12,206,0,0,0,0,1,38,1,1,138,12,1,27,6,0,5,0,4,3,5,22,3559,8357,0,34,6,3,3,6,0,15,21,20,12,9,1,4,17,0,28,0,0,5,2,3,2,1,0,690,0,11,4,1,2,0,0,4,13,0,216,1522,0,3,7,2,841,10,5,3,10,1,1,4,1194,28,34,0,8,2,7,8,3,0,4,1,0,4,1,2,3,0,3,2,16,1,0,0,0,24,1,0,0,5,1,0,1,3,0,0,2,22,2,1 diff --git a/startrack/app.py b/startrack/app.py index 1a7cd39..d210514 100644 --- a/startrack/app.py +++ b/startrack/app.py @@ -1,12 +1,34 @@ import os +from datetime import datetime from typing import List +import pandas as pd from startrack.config import GITHUB_TOKEN_ENV -from startrack.core import list_organization_repositories, RepositoryType, \ - RepositoryData +from startrack.core import ( + list_organization_repositories, + RepositoryType, + RepositoryData, + to_dataframe +) GITHUB_TOKEN = os.environ.get(GITHUB_TOKEN_ENV, None) -ORGANIZATION_NAME = "roboflow" +ORGANIZATION_NAMES = ["roboflow", "autodistill"] + + +def save_to_csv(df: pd.DataFrame, directory: str, filename: str) -> None: + """ + Save a DataFrame to a CSV file in the specified directory. + + Args: + df (pd.DataFrame): The DataFrame to save. + directory (str): The directory where the CSV file will be saved. + filename (str): The name of the CSV file. + """ + if not os.path.exists(directory): + os.makedirs(directory) + + file_path = os.path.join(directory, filename) + df.to_csv(file_path) def get_all_organization_repositories( @@ -30,13 +52,25 @@ def get_all_organization_repositories( return all_repositories -repositories_json = get_all_organization_repositories( - github_token=GITHUB_TOKEN, - organization_name=ORGANIZATION_NAME, - repository_type=RepositoryType.PUBLIC) +all_repositories_json = [] +for organization_name in ORGANIZATION_NAMES: + repositories_json = get_all_organization_repositories( + github_token=GITHUB_TOKEN, + organization_name=organization_name, + repository_type=RepositoryType.PUBLIC) + all_repositories_json.extend(repositories_json) + repositories = [ RepositoryData.from_json(repository_json) for repository_json - in repositories_json] + in all_repositories_json] +df = to_dataframe(repositories) +df = df.set_index('full_name').T + +current_date = datetime.now().strftime("%Y-%m-%d") +df.index = [current_date] -print(repositories) +save_to_csv( + df=df, + directory='data', + filename='data.csv') diff --git a/startrack/core.py b/startrack/core.py index 5e58bd9..f4f08ff 100644 --- a/startrack/core.py +++ b/startrack/core.py @@ -2,6 +2,7 @@ from enum import Enum from typing import List, Dict, Any +import pandas as pd import requests @@ -85,3 +86,22 @@ def list_organization_repositories( response = requests.get(url, headers=headers, params=params) return response.json() + + +def to_dataframe(repositories: List[RepositoryData]) -> pd.DataFrame: + """ + Convert a list of RepositoryData objects into a pandas DataFrame. + + Args: + repositories (List[RepositoryData]): A list of RepositoryData objects. + + Returns: + pd.DataFrame: A DataFrame where each row represents a repository, with columns + for the repository's name and star count. + """ + data = [ + {'full_name': repository.full_name, 'star_count': repository.star_count} + for repository + in repositories + ] + return pd.DataFrame(data)