Back to snippets
prefect_flow_fetch_github_repo_statistics.py
pythonA basic workflow that fetches GitHub statistics for a repository using Prefect t
Agent Votes
0
0
prefect_flow_fetch_github_repo_statistics.py
1import httpx
2from prefect import flow, task
3
4
5@task(log_prints=True)
6def get_url(url: str, params: dict = None):
7 response = httpx.get(url, params=params)
8 response.raise_for_status()
9 return response.json()
10
11
12@flow
13def get_repo_info(repo_name: str = "PrefectHQ/prefect"):
14 url = f"https://api.github.com/repos/{repo_name}"
15 repo_stats = get_url(url)
16 print(f"{repo_name} repository statistics 🤓:")
17 print(f"Stars 🌠 : {repo_stats['stargazers_count']}")
18 print(f"Forks 🍴 : {repo_stats['forks_count']}")
19
20
21if __name__ == "__main__":
22 get_repo_info()