label-studio
label-studio copied to clipboard
Getting a "Client Error" when attempting to retrieve projects from Label-studio
I am trying to fetch all the current projects from the Label-studio, here functions check_connection
& get_session
work just fine, however, I am getting the following error while fetching the projects using get_projects
:
Code:
from label_studio_sdk import Client
LABEL_STUDIO_URL = 'http://xx.xxx.xx.xxx:xxxx'
API_KEY = 'a6eecde17b14b768085a67a6657c44fac5e0244d'
ls = Client(url=LABEL_STUDIO_URL, api_key=API_KEY)
print(ls.check_connection()) # WORKS
print(ls.get_session()) # WORKS
print(ls.get_projects()) # DOES NOT WORK
Error:
{'status': 'UP'}
<requests.sessions.Session object at 0x7f85f818a8b0>
Traceback (most recent call last):
File "/path/to/neuron-de-yolo/label_studio/test.py", line 18, in <module>
print(ls.get_projects())
File "/opt/anaconda3/lib/python3.9/site-packages/label_studio_sdk/client.py", line 143, in get_projects
return self.list_projects()
File "/opt/anaconda3/lib/python3.9/site-packages/label_studio_sdk/client.py", line 181, in list_projects
response = self.make_request(
File "/opt/anaconda3/lib/python3.9/site-packages/label_studio_sdk/client.py", line 374, in make_request
response.raise_for_status()
File "/opt/anaconda3/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: http://xx.xxx.xx.xxx:xxxx/api/projects?page_size=10000000
Hello unikill066,
I tried to reproduce this, but was unable to, for me it works. What version of LS are you using?
I am getting the exact same behavior. The image for the label-studio is 1.8, aka, heartexlabs/label-studio:latest.
It's possible that a .netrc
file was causing this issue: https://stackoverflow.com/questions/60358216/python-requests-post-request-dropping-authorization-header
I'm not too familiar with networking but removing the entry that corresponds to the Label Studio URL (e.g. localhost) will work. Obviously, it's not a good solution, but I hope it helps those coming across this issue
The problem originates from: label_studio_sdk/client.py
response = self.session.request(...)