Add --force flag to rerun

This commit is contained in:
Bill Thiede 2025-12-02 15:59:05 -08:00
parent 032387d81c
commit 086fc2ff3e
2 changed files with 31 additions and 6 deletions

View File

@ -90,6 +90,22 @@ To sync repositories and generate a report once:
python aocsync.py --once
```
### Force Rerun All Days
To force rerun all days even if repositories haven't changed:
```bash
python aocsync.py --once --force
```
or
```bash
python aocsync.py --once --rerun-all
```
This is useful for refreshing all data or testing changes to the script.
### Continuous Polling
To continuously poll repositories (default):

View File

@ -907,11 +907,12 @@ class HTMLGenerator:
class AOCSync:
"""Main synchronization orchestrator"""
def __init__(self, config_path: str = "config.yaml"):
def __init__(self, config_path: str = "config.yaml", force_rerun: bool = False):
self.config = Config(config_path)
self.db = Database(os.path.join(self.config.data_dir, 'results.db'))
self.html_gen = HTMLGenerator(self.config.output_dir)
self.git_manager = GitManager()
self.force_rerun = force_rerun
def process_repository(self, repo_config: dict, user_name: str):
"""Process a single repository configuration"""
@ -922,8 +923,11 @@ class AOCSync:
url = repo_config['url']
local_path = repo_config['local_path']
if self.git_manager.has_changes(url, local_path):
logger.info(f"Repository {user_name} has changes, updating...")
if self.force_rerun or self.git_manager.has_changes(url, local_path):
if self.force_rerun:
logger.info(f"Force rerun enabled, processing repository {user_name}...")
else:
logger.info(f"Repository {user_name} has changes, updating...")
if self.git_manager.clone_or_update_repo(url, local_path):
repo_path = Path(local_path)
@ -963,8 +967,11 @@ class AOCSync:
url = year_config['url']
local_path = year_config['local_path']
if self.git_manager.has_changes(url, local_path):
logger.info(f"Repository {user_name} year {year} has changes, updating...")
if self.force_rerun or self.git_manager.has_changes(url, local_path):
if self.force_rerun:
logger.info(f"Force rerun enabled, processing repository {user_name} year {year}...")
else:
logger.info(f"Repository {user_name} year {year} has changes, updating...")
if self.git_manager.clone_or_update_repo(url, local_path):
repo_path = Path(local_path)
self._run_and_store_benchmarks(repo_path, year, user_name,
@ -1034,10 +1041,12 @@ def main():
parser = argparse.ArgumentParser(description='AOC Sync - Poll and compare AOC implementations')
parser.add_argument('--config', default='config.yaml', help='Path to config file')
parser.add_argument('--once', action='store_true', help='Run once instead of continuously')
parser.add_argument('--force', '--rerun-all', action='store_true', dest='force_rerun',
help='Force rerun all days even if repository has not changed')
args = parser.parse_args()
sync = AOCSync(args.config)
sync = AOCSync(args.config, force_rerun=args.force_rerun)
if args.once:
sync.sync_all()