Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions auto-update-dataset/python/prStatusCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@
REPORT_PATH = os.path.join(script_dir, "accepted.log")
MANUAL_CHECK_PATH = os.path.join(script_dir, "manual-check.log")

def fetch_status(url, original_status):

def fetch_status(url, original_status):
"""
Fetch PR status from GitHub API with caching.
"""

def cache_and_return(url, result):
"""Cache the result and return it."""
pr_status_cache[url] = result
return result

if url in pr_status_cache:
logger.debug(f"Cache hit for {url}")
return pr_status_cache[url]
return pr_status_cache[url]
match = GITHUB_URL_PATTERN.search(url)
if not match:
return cache_and_return(url, "Invalid URL")
Expand All @@ -90,6 +91,7 @@ def cache_and_return(url, result):
logger.warning(f"Exception fetching PR {url}: {e}.")
return "Fetch Error"


def process_row(filename, index, row):
"""
Only check for updates when the PR is in 'Opened' status.
Expand Down Expand Up @@ -121,6 +123,7 @@ def process_row(filename, index, row):
logger.info(msg)
return index, new_status, changed, url, msg


def parse_range(range_str):
if not range_str:
return None, None
Expand All @@ -140,6 +143,7 @@ def parse_range(range_str):
logger.error(f"Invalid range values: {range_str}")
sys.exit(1)


def main():
parser = argparse.ArgumentParser(description="Update PR statuses in CSV files.")
parser.add_argument("--prrange", type=str,
Expand Down Expand Up @@ -275,5 +279,6 @@ def main():
f.write(line + "\n")
logger.info(f"Manual check log updated for {filename}")


if __name__ == "__main__":
main()
main()