-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) pre commit hook to sync backup context_window mapping
- Loading branch information
1 parent
8b57115
commit 70f3607
Showing
3 changed files
with
15 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,32 @@ | ||
import sys | ||
import filecmp | ||
import difflib | ||
|
||
|
||
def show_diff(file1, file2): | ||
with open(file1, "r") as f1, open(file2, "r") as f2: | ||
lines1 = f1.readlines() | ||
lines2 = f2.readlines() | ||
|
||
diff = difflib.unified_diff(lines1, lines2, lineterm="") | ||
|
||
for line in diff: | ||
print(line) | ||
import shutil | ||
|
||
|
||
def main(argv=None): | ||
print( | ||
"comparing model_prices_and_context_window, and litellm/model_prices_and_context_window_backup.json files.......... checking they match", | ||
argv, | ||
"Comparing model_prices_and_context_window and litellm/model_prices_and_context_window_backup.json files... checking if they match." | ||
) | ||
|
||
file1 = "model_prices_and_context_window.json" | ||
file2 = "litellm/model_prices_and_context_window_backup.json" | ||
|
||
cmp_result = filecmp.cmp(file1, file2, shallow=False) | ||
|
||
if cmp_result: | ||
print(f"Passed ! Files {file1} and {file2} match.") | ||
print(f"Passed! Files {file1} and {file2} match.") | ||
return 0 | ||
else: | ||
# show the diff | ||
print(f"Failed ! Files {file1} and {file2} do not match.") | ||
print("\nDiff") | ||
show_diff(file1, file2) | ||
|
||
print( | ||
f"Failed! Files {file1} and {file2} do not match. Copying content from {file1} to {file2}." | ||
) | ||
copy_content(file1, file2) | ||
return 1 | ||
|
||
|
||
def copy_content(source, destination): | ||
shutil.copy2(source, destination) | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters