This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 121
Cleanup indexes in case of failure #232
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b52d2fc
Cleanup indexes in case of failure
izellevy 24bb105
Remove shell bash
izellevy 6d5d243
Move to script
izellevy 7a6f841
Fix
izellevy e9861f4
Fix env
izellevy 84b44c9
Poetry run
izellevy 0e6549f
Fix
izellevy fcc103b
Try fix
izellevy e85ab60
Try
izellevy af7ec1b
Fix
izellevy 8e1f4b9
Update secrets
izellevy beb246c
Test
izellevy 6e2944c
Fix
izellevy dd7ac45
Fail system test
izellevy fd4b34d
Improve logging
izellevy e4fd8ad
Fix lint
izellevy 6175e35
Remove exit
izellevy 9c60c36
Fix message
izellevy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import logging | ||
import sys | ||
from tests.util import cleanup_indexes | ||
|
||
|
||
def main(): | ||
logging.basicConfig(level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
if len(sys.argv) != 2: | ||
logger.info("Usage: python scripts/cleanup_indexes.py <testrun_uid>") | ||
sys.exit(1) | ||
|
||
testrun_uid = sys.argv[1] | ||
if testrun_uid: | ||
logger.info(f"Cleaning up indexes for testrun_uid '{testrun_uid}'") | ||
cleanup_indexes(testrun_uid) | ||
else: | ||
logger.info("Passed testrun_uid is empty.") | ||
|
||
|
||
if __name__ == '__main__': | ||
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import logging | ||
from datetime import datetime | ||
|
||
import pinecone | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def create_index_name(testrun_uid: str, prefix: str) -> str: | ||
today = datetime.today().strftime("%Y-%m-%d") | ||
return f"{prefix}-{testrun_uid[-6:]}-{today}" | ||
|
||
|
||
def create_system_tests_index_name(testrun_uid: str) -> str: | ||
return create_index_name(testrun_uid, "test-kb") | ||
|
||
|
||
def create_e2e_tests_index_name(testrun_uid: str) -> str: | ||
return create_index_name(testrun_uid, "test-app") | ||
|
||
|
||
def cleanup_indexes(testrun_uid: str): | ||
pinecone.init() | ||
e2e_index_name = create_e2e_tests_index_name(testrun_uid) | ||
system_index_name = create_system_tests_index_name(testrun_uid) | ||
index_names = (system_index_name, e2e_index_name) | ||
logger.info(f"Preparing to cleanup indexes: {index_names}") | ||
current_indexes = pinecone.list_indexes() | ||
for index_name in index_names: | ||
if index_name in current_indexes: | ||
logger.info(f"Deleting index '{index_name}'...") | ||
pinecone.delete_index(index_name) | ||
logger.info(f"Index '{index_name}' deleted.") | ||
else: | ||
logger.info(f"Index '{index_name}' does not exist.") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please promise me that if we're every adding even more one parameter, we're switching to
argparse
😄