TileDB-Py icon indicating copy to clipboard operation
TileDB-Py copied to clipboard

Linux filepaths do not work on Windows

Open codie3611 opened this issue 4 years ago • 1 comments

I've got the following relative filepath "./test/jobs/store/python-save-vars/x" where x is simply a file. When accesing on windows with:

impor tiledb
vfs = tiledb.VFS()
uri = "./test/jobs/store/python-save-vars/x"
vfs.file_size(uri)

I get the following error:

Traceback (most recent call last):
  File "tiledb/libtiledb.pyx", line 5227, in tiledb.libtiledb.VFS.file_size
  File "tiledb/libtiledb.pyx", line 453, in tiledb.libtiledb._raise_ctx_err
  File "tiledb/libtiledb.pyx", line 438, in tiledb.libtiledb._raise_tiledb_error
tiledb.libtiledb.TileDBError: [TileDB::IO] Error: Failed to get file size for \'\\test\\jobs\\store\\python-save-vars\\x\'

Though if I convert slashes do backslashes it works:

uri2 = uri.replace("/","\\")
vfs.file_size(uri2)

I would expect tiledb to also handle slashes on windows.

I'm using tiledb=0.6.1 (libtiledb=2.0.2) on Windows with Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32.


[#294]

codie3611 avatar Jun 19 '20 14:06 codie3611

Late to the party, but there are 2 OS-agnostic ways to declare path joins like this:

  1. The os.path.join will add the appropriate OS file separator in between the parts to be joined. Use it as follows:

    uri = os.path.join("test", "jobs", "store", "python-save-vars", "x")
    
  2. If you don't want to use the join method (why not though) you can concat the path manually and add the os.sep in between:

    uri = "test" + os.sep + "jobs" + os.sep + "store" + os.sep + "python-save-vars" + os.sep + "x"
    

JohnMoutafis avatar Oct 13 '23 10:10 JohnMoutafis