unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
1.92k stars 109 forks source link

Bug: Index restore view=True does not work for shared user index #442

Open sef43 opened 3 weeks ago

sef43 commented 3 weeks ago

Describe the bug

If I try and do Index.restore(, view=True) on an index file created by a different user I get an error:

Traceback (most recent call last):
  File "/home/sfarr_test/test_load.py", line 5, in <module>
    index=Index.restore('test.index', view=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sfarr_test/usearch/lib/python3.11/site-packages/usearch/index.py", line 604, in restore
    index.view(path_or_buffer)
  File "/home/sfarr_test/usearch/lib/python3.11/site-packages/usearch/index.py", line 975, in view
    self._compiled.view_index_from_path(os.fspath(path_or_buffer), progress)
RuntimeError: Operation not permitted

Steps to reproduce

with user 1:

import numpy as np
from usearch.index import Index

index = Index(ndim=4)

vectors = np.random.random(size=(100,4))

index.add(list(range(len(vectors))), vectors)

print(index)
index.save('test.index')

with user 2:

import numpy as np
from usearch.index import Index

index=Index.restore('test.index', view=True)
print(index)

Expected behavior

The index should restore for user2 if view=True. It only restores properly if I change to view=False

USearch version

2.11.7

Operating System

Ubuntu 22.04

Hardware architecture

x86

Which interface are you using?

Python bindings

Contact Details

No response

Are you open to being tagged as a contributor?

Is there an existing issue for this?

Code of Conduct

ashvardanian commented 3 weeks ago

That sounds like a file permissions issue unrelated to USearch. Can you try creating and reading an arbitrary text file? Or simply checking file permissions?

sef43 commented 3 weeks ago

Yes that is my main thought, I have checked this as much as possible. If I use Index.restore('test.index') it loads sucessfully. It is only when I try and use view=True where there is the error. There are no permission errors for other file operations. I am wondering if it is something related to the memory mapping settings.