Hi, I am following the python guide <https://docs....
# help
x
Hi, I am following the python guide https://docs.lakefs.io/using/python.html, but get error
Copy code
>>> client.branches.listBranches(repository='test').result()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/anaconda3/lib/python3.8/site-packages/bravado/http_future.py", line 271, in result
    swagger_result = self._get_swagger_result(incoming_response)
  File "/opt/anaconda3/lib/python3.8/site-packages/bravado/http_future.py", line 124, in wrapper
    return func(self, *args, **kwargs)
  File "/opt/anaconda3/lib/python3.8/site-packages/bravado/http_future.py", line 300, in _get_swagger_result
    unmarshal_response(
  File "/opt/anaconda3/lib/python3.8/site-packages/bravado/http_future.py", line 353, in unmarshal_response
    raise_on_expected(incoming_response)
  File "/opt/anaconda3/lib/python3.8/site-packages/bravado/http_future.py", line 420, in raise_on_expected
    raise make_http_exception(
bravado.exception.HTTPUnauthorized: 401 Unauthorized: error(code=401, message='unauthenticated for invalid credentials')
I am able to use requests to do the same call. so the lakeFS server should works. just stuck with the bravado library. Appreciate if someone can share some clue.
setup client as
Copy code
>>> from bravado.client import SwaggerClient
>>> http_client = RequestsClient()
>>> http_client.set_basic_auth('<https://lakefs.xxx.com>', 'xxxx', 'xxxx')
>>> client = SwaggerClient.from_url('<https://lakefs.xxxx.com/swagger.json>', http_client=http_client)
/opt/anaconda3/lib/python3.8/site-packages/swagger_spec_validator/validator20.py:49: SwaggerValidationWarning: Found "$ref: #/definitions/staging_location" with siblings that will be overwritten. See <https://stackoverflow.com/a/48114924> for more information. (path #/definitions/staging_metadata/properties/staging)
  warnings.warn(
a
Hi, Authorization seems missing. I know this is annoying, but please verify that you are setting lakefs auth key and secret, not s3 / minio. Also, maybe the server logs will contain some additional info if you set level trace ?
x
I did check, the same key secret works well with simple python requests library.
a
The Python client is being revised in https://github.com/treeverse/lakeFS/pull/1725. @Barak Amar can you advise please?
b
hi
The issue for the new python client is relevant for the next release, so unless we are using binary from master there is no need a new client.
@Xubo Fei when you browse to
Copy code
<https://lakefs.xxxx.com/swagger.json>
do you see the openapi version at the start - it is version2?
just double checking
x
Copy code
"consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "schemes": [
    "http",
    "https"
  ],
  "swagger": "2.0",
  "info": {
    "description": "lakeFS HTTP API",
    "title": "lakeFS API",
    "version": "0.1.0"
  },
b
looks good
when you call
set_basic_auth
can you pass just the domain name
it should be the name of the host as far as I remember
👏🏾 1
👍 1
👏🏽 1
x
oh yes! Thanks.
b
my pleasure