question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

get_local_path in label_studio_tools/core/utils/io.py creates invalid path on Windows 10 when used with local storage

See original GitHub issue

Describe the bug A clear and concise description of what the bug is.

get_local_path in label_studio_tools/core/utils/io.py creates file paths with the format: local-files/folder\img.jpg

, which causes it to raise a FileNotFoundError(local-files/folder\img.jpg)

To Reproduce Steps to reproduce the behavior:

  1. Create a valid local files source storage connection according to https://labelstud.io/guide/storage.html#Set-up-connection-in-the-Label-Studio-UI-4

  2. Execute some task that calls get_local_path. E.g. attempting to run ‘Auto-Annotation’ with a ml backend in the labelling UI interface.

  3. Auto-Annotation fails with FileNotFoundError: local-files/folder\img.jpg

Expected behavior get_local_path to return a valid path for the file in question: e.g. C:/path/to/local/img.jpg

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Windows 10, running directly on OS (no container)
  • Label Studio Version 1.5.0.post0

Additional context I fixed this for my local implementation by changing lines 56-62 in io.py from:

    if is_local_file:
        dir_path, filename = url.split('/data/')[1].split('?d=')
        filename = str(urllib.parse.unquote(filename))
        filepath = os.path.join(dir_path, filename)
        if not os.path.exists(filepath):
            raise FileNotFoundError(filepath)
        return filepath

to:

    if is_local_file:
        local_files_root = os.environ['LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT']
        filename = url.split('/data/')[1].split('?d=')[1]
        filename = str(urllib.parse.unquote(filename))
        filepath = os.path.join(local_files_root, filename)
        if not os.path.exists(filepath):
            raise FileNotFoundError(filepath)
        return filepath

I don’t know if this breaks other functionality / implementations on other OS’s but I did manage to get Auto-Annotation to work on my machine

On a related note, when I export annotations in COCO format I get ‘file_name’ lines that follow the format: "file_name": "/data/local-files/?d=folder\\img.jpg"

Which, I assume is also a bug?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
makseqcommented, Jul 26, 2022

@mukeshnarendran7 Yes, you need to set LOCAL_FILES_DOCUMENT_ROOT manually.

1reaction
KonstantinKorotaevcommented, Jul 22, 2022

Could you please update your label-studio-tools to 0.0.0.dev15?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows Invalid path error - Microsoft Community
Windows 10 Home 64 bit. When windows starts a small window opens with the message 'Invalid Path: D:\Top\' What's happening?
Read more >
github/git Checkout Returns 'error: invalid path' on Windows
Clone the Git repository locally;; 'cd' into the local Git repository folder that has just been cloned;; Run git reset; Run git config...
Read more >
"error: invalid path" during git clone to Windows client
Summary. The Git cloning of repository succeeds on a Linux client but fails on a Windows client with an "invalid path" error.
Read more >
11 Ways to Fix "The System Cannot Find The Path Specified ...
Here are eleven fixes you can do to solve this problem right away. 1. Run Command Prompt as an Administrator. Windows utilities cannot...
Read more >
How to Fix "The system cannot find the path specified." Error in ...
It seems this error occurs when you have invalid paths in your PATH ... how to see the value of PATH environment variable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found