File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed
autointent/context/vector_index_client Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 33
44
55def get_db_dir (db_dir : str | Path | None = None ) -> Path :
6- """
7- Get the directory path for chroma db file.
8- Use default cache dir if not provided.
9- Save path into user config in order to remove it from cache later.
10- """
11-
12- root = Path (db_dir ) if db_dir is not None else Path .cwd ()
13- db_dir = root / "vector_db" / str (uuid4 ()) if db_dir is None else Path (db_dir )
6+ db_dir = Path .cwd () / "vector_db" / str (uuid4 ()) if db_dir is None else Path (db_dir )
147 db_dir .mkdir (parents = True , exist_ok = True )
15-
168 return db_dir
Original file line number Diff line number Diff line change 11import json
22import logging
33import shutil
4+ import stat
5+ from collections .abc import Callable
46from pathlib import Path
57
68from autointent .custom_types import LabelType
@@ -107,10 +109,15 @@ def exists(self, model_name: str) -> bool:
107109 return self ._get_index_dirpath (model_name ) is not None
108110
109111 def delete_db (self ) -> None :
110- shutil .rmtree (self .db_dir )
112+ shutil .rmtree (self .db_dir , onexc = redo_with_write )
111113
112114
113115class NonExistingIndexError (Exception ):
114116 def __init__ (self , message : str = "non-existent index was requested" ) -> None :
115117 self .message = message
116118 super ().__init__ (message )
119+
120+
121+ def redo_with_write (redo_func : Callable , path : Path , err : Exception ) -> None : # noqa: ARG001
122+ Path .chmod (path , stat .S_IWRITE )
123+ redo_func (path )
You can’t perform that action at this time.
0 commit comments