-
Notifications
You must be signed in to change notification settings - Fork 43
Move validator business logic into every_eval_ever and update to de-duplication logic #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -223,4 +223,5 @@ vendor/ | |
| _site/ | ||
| .sass-cache/ | ||
| .jekyll-cache/ | ||
| .jekyll-metadata | ||
| .jekyll-metadataUSAGE_* | ||
| USAGE_* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
| import os | ||
| from typing import Any, Dict, List | ||
|
|
||
| from every_eval_ever.dedup import check_duplicates | ||
|
|
||
| IGNORE_KEYS = {'retrieved_timestamp', 'evaluation_id'} | ||
|
|
||
|
|
||
|
|
@@ -81,59 +83,29 @@ def main(argv: List[str] | None = None) -> int: | |
| print(f'Checking {len(file_paths)} JSON files for duplicates...') | ||
| print() | ||
|
|
||
| groups: Dict[str, List[Dict[str, Any]]] = {} | ||
| for file_path in file_paths: | ||
| try: | ||
| with open(file_path, 'r') as f: | ||
| payload = json.load(f) | ||
| except json.JSONDecodeError as e: | ||
| message = f'JSONDecodeError: {str(e)}' | ||
| annotate_error( | ||
| file_path, | ||
| message, | ||
| title='JSONDecodeError', | ||
| col=e.colno, | ||
| line=e.lineno, | ||
| ) | ||
| print(f'{file_path}') | ||
| print(' ' + message) | ||
| print() | ||
| raise | ||
|
|
||
| entry_hash = normalized_hash(payload) | ||
| groups.setdefault(entry_hash, []).append( | ||
| { | ||
| 'path': file_path, | ||
| 'evaluation_id': payload.get('evaluation_id'), | ||
| 'retrieved_timestamp': payload.get('retrieved_timestamp'), | ||
| } | ||
| ) | ||
|
|
||
| duplicate_groups = [ | ||
| entries for entries in groups.values() if len(entries) > 1 | ||
| local_paths = {file_path: file_path for file_path in file_paths} | ||
| dedup_report = check_duplicates(file_paths, local_paths, {'files': {}}) | ||
| duplicate_results = [ | ||
| result for result in dedup_report.results if result.duplicate_of | ||
| ] | ||
|
Comment on lines
+86
to
90
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like it only does local same-batch duplicate detection now. Since the manifest is always |
||
| if not duplicate_groups: | ||
|
|
||
| if not duplicate_results: | ||
| print('No duplicates found.') | ||
| print() | ||
| return 0 | ||
|
|
||
| ignore_label = ', '.join(f'`{key}`' for key in sorted(IGNORE_KEYS)) | ||
| print(f'Found duplicate entries (ignoring keys: {ignore_label}).') | ||
| print('Found duplicate entries (semantic fingerprint match).') | ||
| print() | ||
|
|
||
| for index, entries in enumerate(duplicate_groups, start=1): | ||
| print(f'Duplicate group {index} ({len(entries)} files):') | ||
| for entry in entries: | ||
| print(f' - {entry["path"]}') | ||
| print(f' evaluation_id: {entry.get("evaluation_id")}') | ||
| print( | ||
| f' retrieved_timestamp: {entry.get("retrieved_timestamp")}' | ||
| ) | ||
| annotate_error( | ||
| entry['path'], | ||
| 'Duplicate entry detected (ignoring `evaluation_id` and `retrieved_timestamp`).', | ||
| title='DuplicateEntry', | ||
| ) | ||
| for index, result in enumerate(duplicate_results, start=1): | ||
| print(f'Duplicate group {index}:') | ||
| print(f' - {result.file_path}') | ||
| print(f' duplicate_of: {result.duplicate_of}') | ||
| annotate_error( | ||
| result.file_path, | ||
| f'Duplicate entry detected; semantic fingerprint matches {result.duplicate_of}.', | ||
| title='DuplicateEntry', | ||
| ) | ||
| print() | ||
|
|
||
| return 1 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a typo?