Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Async for files.py functions - #586

Open
shilpakancharla wants to merge 5 commits into
google-gemini:mainfrom
shilpakancharla:async_file
Open

shilpakancharla wants to merge 5 commits into
google-gemini:mainfrom
shilpakancharla:async_file

Conversation

@shilpakancharla

Copy link
Copy Markdown
Contributor

Added asyncio methods for all the file methods.

However, how should we test these asyncio methods?

@github-actions github-actions Bot added status:awaiting review PR awaiting review from a maintainer component:python sdk Issue/PR related to Python SDK labels Oct 5, 2024
yield file_types.File(proto)


async def list_files_async(*args, **kwargs):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will fail because we want an async iterator to be returned here.

Can you copy the list_files code and add the missing asyncs?



async def get_file_async(*args, **kwargs):
return await asyncio.to_thread(get_file, *args, **kwargs)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an async client, we should use it. Let's copy-paste the code, and add the missing asyncs

client.delete_file(request=request)


async def delete_file_async(*args, **kwargs):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Comment thread samples/files.py
# [END files_delete]


class AsyncTests(absltest.TestCase, unittest.IsolatedAsyncioTestCase):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test all the methods, I think list is broken right now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When sieving through the code I saw that the SDK does have a FileServiceAsyncClient class in client.py, but there are no corresponding async examples in the samples/files.py file. There is missing AsyncTests class with async test method for checking the list. If the issue is open I would love to work on this.

@demoncoder-crypto

Copy link
Copy Markdown

Is this issue open?

@Annhiluc Annhiluc added type:feature request New feature request/enhancement status:triaged Issue/PR triaged to the corresponding sub-team p3 labels Mar 27, 2025

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

component:python sdk Issue/PR related to Python SDK p3 status:awaiting review PR awaiting review from a maintainer status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request/enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants