Home / File/ topic_repos.py — fastapi Source File

topic_repos.py — fastapi Source File

Architecture documentation for topic_repos.py, a python file in the fastapi codebase. 8 imports, 0 dependents.

File python FastAPI Responses 8 imports 1 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  1d55f460_8498_4522_950c_c96b5d5e33d9["topic_repos.py"]
  a4a63925_76bf_e8a8_bef2_cb86d161a300["logging"]
  1d55f460_8498_4522_950c_c96b5d5e33d9 --> a4a63925_76bf_e8a8_bef2_cb86d161a300
  05832956_b384_ff7e_ef60_abebb23f9723["secrets"]
  1d55f460_8498_4522_950c_c96b5d5e33d9 --> 05832956_b384_ff7e_ef60_abebb23f9723
  c16959b6_d471_41f8_1c0e_2c4fe324727a["subprocess"]
  1d55f460_8498_4522_950c_c96b5d5e33d9 --> c16959b6_d471_41f8_1c0e_2c4fe324727a
  b3e303a2_3f2d_638d_930c_3a5dcc2f5a42["pathlib"]
  1d55f460_8498_4522_950c_c96b5d5e33d9 --> b3e303a2_3f2d_638d_930c_3a5dcc2f5a42
  67785272_06f8_d6cb_1f4a_abf8bc11d004["yaml"]
  1d55f460_8498_4522_950c_c96b5d5e33d9 --> 67785272_06f8_d6cb_1f4a_abf8bc11d004
  319484c7_306f_9ec1_3de4_788004953d77["github"]
  1d55f460_8498_4522_950c_c96b5d5e33d9 --> 319484c7_306f_9ec1_3de4_788004953d77
  6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"]
  1d55f460_8498_4522_950c_c96b5d5e33d9 --> 6913fbd4_39df_d14b_44bb_522e99b65b90
  d2280984_30d0_0ee6_97ed_95cfcc358f18["pydantic_settings"]
  1d55f460_8498_4522_950c_c96b5d5e33d9 --> d2280984_30d0_0ee6_97ed_95cfcc358f18
  style 1d55f460_8498_4522_950c_c96b5d5e33d9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import logging
import secrets
import subprocess
from pathlib import Path

import yaml
from github import Github
from pydantic import BaseModel, SecretStr
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    github_repository: str
    github_token: SecretStr


class Repo(BaseModel):
    name: str
    html_url: str
    stars: int
    owner_login: str
    owner_html_url: str


def main() -> None:
    logging.basicConfig(level=logging.INFO)
    settings = Settings()

    logging.info(f"Using config: {settings.model_dump_json()}")
    g = Github(settings.github_token.get_secret_value(), per_page=100)
    r = g.get_repo(settings.github_repository)
    repos = g.search_repositories(query="topic:fastapi")
    repos_list = list(repos)
    final_repos: list[Repo] = []
    for repo in repos_list[:100]:
        if repo.full_name == settings.github_repository:
            continue
        final_repos.append(
            Repo(
                name=repo.name,
                html_url=repo.html_url,
                stars=repo.stargazers_count,
                owner_login=repo.owner.login,
                owner_html_url=repo.owner.html_url,
            )
        )
    data = [repo.model_dump() for repo in final_repos]

    # Local development
    # repos_path = Path("../docs/en/data/topic_repos.yml")
    repos_path = Path("./docs/en/data/topic_repos.yml")
    repos_old_content = repos_path.read_text(encoding="utf-8")
    new_repos_content = yaml.dump(data, sort_keys=False, width=200, allow_unicode=True)
    if repos_old_content == new_repos_content:
        logging.info("The data hasn't changed. Finishing.")
        return
    repos_path.write_text(new_repos_content, encoding="utf-8")
    logging.info("Setting up GitHub Actions git user")
    subprocess.run(["git", "config", "user.name", "github-actions[bot]"], check=True)
    subprocess.run(
        ["git", "config", "user.email", "github-actions[bot]@users.noreply.github.com"],
        check=True,
    )
    branch_name = f"fastapi-topic-repos-{secrets.token_hex(4)}"
    logging.info(f"Creating a new branch {branch_name}")
    subprocess.run(["git", "checkout", "-b", branch_name], check=True)
    logging.info("Adding updated file")
    subprocess.run(["git", "add", str(repos_path)], check=True)
    logging.info("Committing updated file")
    message = "👥 Update FastAPI GitHub topic repositories"
    subprocess.run(["git", "commit", "-m", message], check=True)
    logging.info("Pushing branch")
    subprocess.run(["git", "push", "origin", branch_name], check=True)
    logging.info("Creating PR")
    pr = r.create_pull(title=message, body=message, base="master", head=branch_name)
    logging.info(f"Created PR: {pr.number}")
    logging.info("Finished")


if __name__ == "__main__":
    main()

Domain

Subdomains

Functions

Classes

Dependencies

  • github
  • logging
  • pathlib
  • pydantic
  • pydantic_settings
  • secrets
  • subprocess
  • yaml

Frequently Asked Questions

What does topic_repos.py do?
topic_repos.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in topic_repos.py?
topic_repos.py defines 1 function(s): main.
What does topic_repos.py depend on?
topic_repos.py imports 8 module(s): github, logging, pathlib, pydantic, pydantic_settings, secrets, subprocess, yaml.
Where is topic_repos.py in the architecture?
topic_repos.py is located at scripts/topic_repos.py (domain: FastAPI, subdomain: Responses, directory: scripts).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free