vsagar100 commited on
Commit
0dbfe24
·
1 Parent(s): 207095e

Added logging

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -10,7 +10,7 @@ import glob
10
  st.title("GitHub Repository Code Reviewer")
11
  # Variables for GitHub repository details
12
  REPO_OWNER = "vsagar100"
13
- REPO_NAME = st.text_input("Enter the GitHub repository URL:")
14
  GITHUB_BRANCH = st.text_input("Enter the branch or tag to download (default: main):", "main")
15
  GITHUB_TOKEN = "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" #os.getenv("GITHUB_TOKEN") # Specify your GitHub token
16
 
@@ -28,19 +28,28 @@ if st.button("Review Code") and GITHUB_REPO_URL:
28
  os.makedirs(output_directory, exist_ok=True)
29
 
30
  # Initialize the code reviewer and review manager
31
- code_reviewer = CodeReviewer()
32
- review_manager = ReviewManager(reviewer=code_reviewer)
 
 
33
 
34
  try:
35
  # Download GitHub repository
36
- review_manager.download_repo(GITHUB_REPO_URL, GITHUB_TOKEN, download_directory)
 
 
 
37
 
38
  # Find all YAML files in the downloaded repository
39
- yaml_files = glob.glob(os.path.join(download_directory, "**", "*.yml"), recursive=True)
40
- yaml_files += glob.glob(os.path.join(download_directory, "**", "*.yaml"), recursive=True)
 
 
41
 
42
- # Process files and generate reviews
43
- reviews = review_manager.process_files(yaml_files)
 
 
44
 
45
  # Save reviews to JSON
46
  output_json_path = os.path.join(output_directory, "code_review_results.json")
@@ -52,6 +61,10 @@ if st.button("Review Code") and GITHUB_REPO_URL:
52
  st.subheader(f"Review for {review['filename']}")
53
  st.text(review['review'])
54
 
 
 
 
 
55
  # Provide download link for JSON results
56
  with open(output_json_path, "r") as json_file:
57
  st.download_button("Download JSON Results", json_file, file_name="code_review_results.json")
 
10
  st.title("GitHub Repository Code Reviewer")
11
  # Variables for GitHub repository details
12
  REPO_OWNER = "vsagar100"
13
+ REPO_NAME = st.text_input("Enter the GitHub repository name:")
14
  GITHUB_BRANCH = st.text_input("Enter the branch or tag to download (default: main):", "main")
15
  GITHUB_TOKEN = "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" #os.getenv("GITHUB_TOKEN") # Specify your GitHub token
16
 
 
28
  os.makedirs(output_directory, exist_ok=True)
29
 
30
  # Initialize the code reviewer and review manager
31
+ with st.spinner("Initializing CodeReviewer and ReviewManager..."):
32
+ code_reviewer = CodeReviewer()
33
+ review_manager = ReviewManager(reviewer=code_reviewer)
34
+
35
 
36
  try:
37
  # Download GitHub repository
38
+ with st.spinner("Downloading GitHub repository..."):
39
+ review_manager.download_repo(GITHUB_REPO_URL, GITHUB_TOKEN, download_directory)
40
+ st.success("Repository downloaded successfully.")
41
+
42
 
43
  # Find all YAML files in the downloaded repository
44
+ with st.spinner("Searching for YAML files in the downloaded repository..."):
45
+ yaml_files = glob.glob(os.path.join(download_directory, "**", "*.yml"), recursive=True)
46
+ yaml_files += glob.glob(os.path.join(download_directory, "**", "*.yaml"), recursive=True)
47
+ st.info(f"Found {len(yaml_files)} YAML files for review.")
48
 
49
+ # Process files and generate reviews
50
+ with st.spinner("Processing files for review..."):
51
+ reviews = review_manager.process_files(yaml_files)
52
+ st.success("Files processed successfully.")
53
 
54
  # Save reviews to JSON
55
  output_json_path = os.path.join(output_directory, "code_review_results.json")
 
61
  st.subheader(f"Review for {review['filename']}")
62
  st.text(review['review'])
63
 
64
+ # Display JSON output on the UI
65
+ st.subheader("Full JSON Review Output")
66
+ st.json(reviews)
67
+
68
  # Provide download link for JSON results
69
  with open(output_json_path, "r") as json_file:
70
  st.download_button("Download JSON Results", json_file, file_name="code_review_results.json")