Skip to content

Commit ac5b3b2

Browse files
committed
more cleanup
1 parent a11b951 commit ac5b3b2

File tree

4 files changed

+31
-26
lines changed

4 files changed

+31
-26
lines changed

GitHub/merge-report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Run merge-report for ml, ai, or both.
33
"""
4-
import GitHub.utilities.merge_report as m
4+
from utilities import merge_report as m
55
import argparse
66
# Create the parser
77
parser = argparse.ArgumentParser(description="Find number of days and which service.")

GitHub/pr-report.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,15 @@
8383
renamed = len(renamed_files)
8484

8585
print(f"PR {pr} changes {len(prfiles)} files.")
86-
print(f"ADDED: {len(added_files)}") # just for info about the PR
87-
print(f"MODIFIED: {modified}")
88-
print(f"DELETED: {deleted}")
89-
print(f"RENAMED: {renamed}\n")
86+
if len(added_files) > 0:
87+
print(f"ADDED {len(added_files)} files. (Added files won't cause a problem.)")
88+
if modified > 0:
89+
print(f"MODIFIED {modified} files.")
90+
if deleted > 0:
91+
print(f"DELETED {deleted} files.")
92+
if renamed > 0:
93+
print(f"RENAMED {renamed} files.\n")
94+
9095
# print("\nChanges that may affect azure-ai-docs-pr:\n")
9196
data = [] # create an empty list to hold data for modified files that are referenced
9297
nb_mods = [] # create an empty list to hold data for modified notebooks
@@ -127,7 +132,7 @@
127132
# print(f"*** {cell}")
128133
if data == []:
129134
print(
130-
"No problems with any of the modified files.\n"
135+
"No problems with any of the modified files.\n"
131136
)
132137
else:
133138
# Group the data by 'Modified File' and 'Referenced In'
@@ -137,10 +142,8 @@
137142
if key not in grouped_data:
138143
grouped_data[key] = []
139144
grouped_data[key].append(item["Cell"])
140-
print(f"Potential problems found in {len(grouped_data)} files.")
141-
print(
142-
"Fix these references in azure-ai-docs-pr before approving this PR:\n"
143-
) # Print the grouped data
145+
print(f"Potential problems found in {len(grouped_data)} files. \n")
146+
# Print the grouped data
144147
for (modified_file, referenced_in), cells in grouped_data.items():
145148
print(f"Modified File: {modified_file} \n Referenced in:")
146149
refs = referenced_in.split("\n")
@@ -155,14 +158,16 @@
155158

156159
h.compare_branches(repo, file, "main", "temp-fix")
157160
# also print all the modified notebooks
161+
print("⚠️ Fix all references to modified files before approving this PR.\n")
162+
158163
if nb_mods:
159164
print(
160165
"MODIFIED NOTEBOOKS\nFollow each link to ensure notebooks are valid before approving the PR:"
161166
)
162167
nb_mods = list(set(nb_mods)) # remove duplicates
163168
for file in nb_mods:
164169
print(f"* {file}\n")
165-
print("Fix all references to modified files before approving this PR.\n")
170+
print("⚠️ Fix all references to modified files before approving this PR.\n")
166171

167172
### DELETED FILES
168173
if deleted > 0:
@@ -182,10 +187,10 @@
182187
found = +1
183188
if found == 0:
184189
print(
185-
"No problems with any of the deleted files.\n"
190+
"No problems with any of the deleted files.\n"
186191
)
187192
else:
188-
print("Fix all references to deleted files before approving this PR.\n")
193+
print("⚠️ Fix all references to deleted files before approving this PR.\n")
189194

190195
### RENAMED FILES
191196
if renamed > 0:
@@ -205,10 +210,10 @@
205210
found = +1
206211
if found == 0:
207212
print(
208-
"No problems with any of the renamed files.\n"
213+
"No problems with any of the renamed files.\n"
209214
)
210215
else:
211-
print("Fix all references to renamed files before approving this PR.\n")
216+
print("⚠️ Fix all references to renamed files before approving this PR.\n")
212217

213218
print(f"\n================ {repo_name} PR summary: {pr} ===================")
214219

GitHub/utilities/find_pr_files.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
def find_pr_files(owner_name, repo_name, snippets, days):
44
import requests
55
import pandas as pd
6-
import GitHub.utilities.gh_auth as a
6+
from utilities import gh_auth as a
77
from datetime import datetime, timedelta
88

99
# Calculate the date to filter by
@@ -23,7 +23,7 @@ def find_pr_files(owner_name, repo_name, snippets, days):
2323
data = response.json()
2424

2525
print(
26-
f"\n================= {datetime.now().date()} MERGED IN LAST {days} DAYS in {repo_name} ================\n"
26+
f"\n================= {repo_name}: {datetime.now().date()} MERGED IN LAST {days} DAYS ================\n"
2727
)
2828
# Filter the PRs that were merged in the last 7 days
2929
merged_prs = [
@@ -60,7 +60,7 @@ def find_pr_files(owner_name, repo_name, snippets, days):
6060

6161
df = pd.DataFrame(data) # Convert the list to a DataFrame
6262
if df.empty:
63-
print("\nNothing to do here :-) There are no PRs that impacted references.\n")
63+
print("\n ✅ Nothing to do here :-) There are no PRs that impacted references.\n")
6464
return
6565
else:
6666
print(" These PRs impacted references:\n")
@@ -99,8 +99,8 @@ def find_pr_files(owner_name, repo_name, snippets, days):
9999
for ref in sorted(refs.unique()):
100100
i += 1
101101
print(f"{i} {ref.strip()}")
102-
print(
103-
f"\n============================== /MERGED IN LAST {days} DAYS ==============================\n"
104-
)
102+
# print(
103+
# f"\n============================== /MERGED IN LAST {days} DAYS ==============================\n"
104+
# )
105105
return
106106

GitHub/utilities/merge_report.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
def merge_report(days, service):
1717

18-
import GitHub.utilities.helpers as h
19-
import GitHub.utilities.find_pr_files as f
18+
from utilities import helpers as h
19+
from utilities import find_pr_files as f
2020
import os
2121

2222
if service == "ai":
@@ -32,13 +32,13 @@ def merge_report(days, service):
3232
# loop through all the repos that contain snippets for this service
3333
for owner_name, repo_name in zip(owner_name, repo_name):
3434
# get the refs-found file for this service
35-
fn = os.path.join(os.path.dirname(mydir), f"refs-found-{repo_name}.csv")
36-
print(f"Reading {fn} for {repo_name} snippets")
35+
fn = os.path.join(os.path.dirname(os.path.dirname(mydir)), f"refs-found-{repo_name}.csv")
36+
# print(f"Reading {fn} for {repo_name} snippets")
3737
# read the snippets for this repo
3838
snippets = h.read_snippets(fn) # read the snippets file
3939
f.find_pr_files(owner_name, repo_name, snippets, days)
4040
return
4141

4242
if __name__ == "__main__":
4343

44-
merge_report(9, "ml")
44+
merge_report(9, "ai")

0 commit comments

Comments
 (0)