File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed
Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ name : ' Cleanup All'
2+ description : ' Delete all indexes and collections associated with API key'
3+
4+ inputs :
5+ PINECONE_API_KEY :
6+ description : ' The Pinecone API key'
7+ required : true
8+
9+ runs :
10+ using : ' composite'
11+ steps :
12+ - name : Set up Python
13+ uses : actions/setup-python@v4
14+ with :
15+ python-version : 3.9
16+ - name : Setup Poetry
17+ uses : ./.github/actions/setup-poetry
18+ - name : Cleanup all
19+ shell : bash
20+ run : poetry run python3 scripts/cleanup-all.py
21+ env :
22+ PINECONE_API_KEY : ${{ inputs.PINECONE_API_KEY }}
Original file line number Diff line number Diff line change 1+ name : ' Cleanup All Indexes/Collections'
2+
3+ on :
4+ workflow_dispatch : {}
5+
6+ jobs :
7+ cleanup-all :
8+ name : Cleanupu all indexes/collections
9+ runs-on : ubuntu-latest
10+ steps :
11+ - uses : actions/checkout@v4
12+ - name : Cleanup all
13+ uses : ./.github/actions/cleanup-all
14+ with :
15+ PINECONE_API_KEY : ${{ secrets.PINECONE_API_KEY }}
Original file line number Diff line number Diff line change 1+ import os
2+ from pinecone import Pinecone
3+
4+ def main ():
5+ pc = Pinecone (api_key = os .environ .get ('PINECONE_API_KEY' , None ))
6+
7+ for collection in pc .list_collections ().names ():
8+ try :
9+ print ('Deleting collection: ' + collection )
10+ pc .delete_collection (collection )
11+ except Exception as e :
12+ print ('Failed to delete collection: ' + collection + ' ' + str (e ))
13+ pass
14+
15+ for index in pc .list_indexes ().names ():
16+ try :
17+ print ('Deleting index: ' + index )
18+ pc .delete_index (index )
19+ except Exception as e :
20+ print ('Failed to delete index: ' + index + ' ' + str (e ))
21+ pass
22+
23+ if __name__ == '__main__' :
24+ main ()
25+
You can’t perform that action at this time.
0 commit comments