I'm trying to use the Python auto-generated API (`...
# dev
a
I'm trying to use the Python auto-generated API (
lakefs_client~=0.41.0
) to upload to lakeFS. Since I don't have a file, I want to use a Pythonic IO. But I get:
Copy code
Traceback (most recent call last):
  File "/home/ariels/dev/airflow-provider-lakeFS/env/lib/python3.10/site-packages/lakefs_provider/operators/upload_operator.py", line 50, in execute
    ref = hook.upload(self.repo, self.branch, self.path, self.content)
  File "/home/ariels/dev/airflow-provider-lakeFS/env/lib/python3.10/site-packages/lakefs_provider/hooks/lakefs_hook.py", line 62, in upload
    upload = client.objects.upload_object(
  File "/home/ariels/dev/airflow-provider-lakeFS/env/lib/python3.10/site-packages/lakefs_client/api_client.py", line 772, in __call__
    return self.callable(self, *args, **kwargs)
  File "/home/ariels/dev/airflow-provider-lakeFS/env/lib/python3.10/site-packages/lakefs_client/api/objects_api.py", line 990, in __upload_object
    return self.call_with_http_info(**kwargs)
  File "/home/ariels/dev/airflow-provider-lakeFS/env/lib/python3.10/site-packages/lakefs_client/api_client.py", line 834, in call_with_http_info
    return self.api_client.call_api(
  File "/home/ariels/dev/airflow-provider-lakeFS/env/lib/python3.10/site-packages/lakefs_client/api_client.py", line 409, in call_api
    return self.__call_api(resource_path, method,
  File "/home/ariels/dev/airflow-provider-lakeFS/env/lib/python3.10/site-packages/lakefs_client/api_client.py", line 174, in __call_api
    post_params.extend(self.files_parameters(files))
  File "/home/ariels/dev/airflow-provider-lakeFS/env/lib/python3.10/site-packages/lakefs_client/api_client.py", line 551, in files_parameters
    filename = os.path.basename(file_instance.name)
AttributeError: '_io.StringIO' object has no attribute 'name'
Any idea why it wants to know the name of a file, when I am anyway specifying the desired destination name? And: is there anything other than a file that I could pass it?
n
What pythonic object did you pass instead of a file?
a
I passed a
StringIO
. Eventually @Barak Amar helped me figure out that I can create a
NameStringIO
-- a
StringIO
with a
name
field. And Swagger / OpenAPI actually wants the contents in a mime part with the name "contents". So once I set
name='contents'
on my
NameStringIO
it all works.
Still hoping for something better, but it doesn't seem like our OpenAPI will be very helpful 😕
n
The python auto generated code is not so "pythonic", but I guess we have to work with what we have
a
True Python never failed, it was merely never tried.
❤️ 2
🔴 1
🔨 1