llmware icon indicating copy to clipboard operation
llmware copied to clipboard

Library().delete_library does not delete the library

Open geverl opened this issue 1 year ago • 5 comments

The following code outputs "1" and "Library exists" whereas the expected output would be "1" and "Library does not exist".

LLMWareConfig().set_active_db("sqlite")
LLMWareConfig().set_vector_db("chromadb")
library_name = "lib1_library"
print(Library().delete_library(library_name=library_name)) # prints 1
if Library().check_if_library_exists(library_name):
    print("Library exists")
else:
    print("Library does not exist")

geverl avatar May 19 '24 07:05 geverl

Hi @geverl!

Thank you for reporting that issue!

May I ask which llmware version you used?

MacOS avatar May 20 '24 08:05 MacOS

llmware version 0.2.12

geverl avatar May 20 '24 08:05 geverl

@geverl - thanks for raising this - and appreciate a nice clear simple example (sometimes the most simple example produces the bug that you missed!) .... I am running the same script (copy and paste) - and getting the correct answer "Library does not exist" ... there is a typo in your script LMWareConfig().set_active_db("sqlite") which I did correct to LLMWareConfig().set_active_db("sqlite") ... could you please try to run this again? Will keep the issue open.

doberst avatar May 23 '24 15:05 doberst

Sorry, the first L got lost during copy/paste. I've added it. The problem remains, also with llmware version 0.2.15. You have to choose a real existing library.

geverl avatar May 23 '24 16:05 geverl

Sorry, the first L got lost during copy/paste. I've added it. The problem remains, also with llmware version 0.2.15.

Here is a full example, where initially no library named "lib2_library" exists:

from llmware.library import Library
from llmware.configs import LLMWareConfig

def check_lib(library_name):
    if Library().check_if_library_exists(library_name):
        print(f"Library {library_name} exists.")
    else:
        print(f"Library {library_name} does not exist.")

if __name__ == "__main__":
    LLMWareConfig().set_active_db("sqlite")
    LLMWareConfig().set_vector_db("chromadb")
    library_name = "lib2_library"
    check_lib(library_name)
    library = Library().create_new_library(library_name)
    print(Library().delete_library(library_name=library_name))
    check_lib(library_name)

Running the code two times produces the following output: Library lib2_library does not exist. 1 Library lib2_library exists. Library lib2_library exists. 1 Library lib2_library exists.

geverl avatar May 23 '24 23:05 geverl

I've created an Ubuntu 24.04 VM from scratch just to verify that I can reproduce the behavior described above. After installing Python 3.12 and llmware 0.2.15 I get exactly the same result.

geverl avatar May 25 '24 12:05 geverl

I think we should add a test case for this first.

MacOS avatar May 29 '24 12:05 MacOS

@geverl - thanks for highlighting this - it is a good catch. It has been fixed in the main branch if you pull the latest code, and will be in the next pip install release (in the next couple of days). Two issues:

(1) to delete the library, please pass "confirm_delete=True", e.g., Library().delete_library(library_name=library_name,confirm_delete=True)

(2) the bug in LLMWare was brought out by creating a fresh Library() object (which has been fixed now), rather than using the 'library state' built when creating the library. Instead, if you modify your current code to:

library = Library().create_new_library(library_name)
print(library.delete_library(library_name=library_name, confirm_delete=True))

then, I believe it should work even with llmware==0.2.15.

Could you please check and confirm back and then we will close out the issue.

doberst avatar May 30 '24 10:05 doberst

The following behaves as it should with llmware 0.2.15:

library = Library().create_new_library(library_name)
print(library.delete_library(library_name=library_name, confirm_delete=True))

With the latest llmware code, the following also works as it should:

library = Library().create_new_library(library_name)
print(Library().delete_library(library_name=library_name, confirm_delete=True))

geverl avatar May 30 '24 11:05 geverl