1313from yandex_cloud_ml_sdk ._types .expiration import ExpirationConfig , ExpirationPolicyAlias
1414from yandex_cloud_ml_sdk ._types .misc import UNDEFINED , PathLike , UndefinedOr , coerce_path , get_defined_value , is_defined
1515from yandex_cloud_ml_sdk ._utils .sync import run_sync , run_sync_generator
16+ from yandex_cloud_ml_sdk ._utils .doc import doc_from
1617
1718from .file import AsyncFile , File , FileTypeT
1819
19-
2020class BaseFiles (BaseDomain , Generic [FileTypeT ]):
21- """Base class for file operations in Yandex Cloud.
22- Provides methods to upload files either as bytes or from the path.
21+ """Files domain, which contains API for working with files.
22+ Files is a part of `Assistants API`_, which is the only place you could use it.
23+ Provides upload, get and list methods that allow you to work with remote file objects you created earlier.
24+
25+ .. _Assistants API: https://yandex.cloud/ru/docs/foundation-models/assistants/api-ref/Assistant/
2326 """
2427 _file_impl : type [FileTypeT ]
2528
@@ -39,17 +42,13 @@ async def _upload_bytes(
3942
4043 :param data: The byte data to upload.
4144 :param name: The name of the file.
42- Defaults to UNDEFINED.
4345 :param description: A description of the file.
44- Defaults to UNDEFINED.
4546 :param mime_type: The MIME type of the file.
46- Defaults to UNDERFINED .
47+ By default (i.e. when UNDEFINED) server will try to auto-detect mime-type and you could override this file .
4748 :param labels: Labels associated with the file.
48- Defaults to UNDEFINED.
4949 :param ttl_days: Time-to-live in days for the file.
50- Defaults to UNDEFINED.
5150 :param expiration_policy: Expiration policy for the file.
52- Defaults to UNDEFINED .
51+ Assepts for passing :static or :since_last_active strings. Should be defined if :ttl_days has been defined, otherwise both parameters should be underfined .
5352 :param timeout: Timeout for the operation in seconds.
5453 Defaults to 60 seconds.
5554 """
@@ -90,6 +89,20 @@ async def _upload(
9089 expiration_policy : UndefinedOr [ExpirationPolicyAlias ] = UNDEFINED ,
9190 timeout : float = 60 ,
9291 ) -> FileTypeT :
92+ """Uploads a file from a specified path.
93+
94+ :param path: The path of the file to upload.
95+ :param name: The name of the file.
96+ :param description: A description of the file.
97+ :param mime_type: The MIME type of the file.
98+ By default (i.e. when UNDEFINED) server will try to auto-detect mime-type and you could override this file.
99+ :param labels: Labels associated with the file.
100+ :param ttl_days: Time-to-live in days for the file.
101+ :param expiration_policy: Expiration policy for the file.
102+ Assepts for passing :static or :since_last_active strings.
103+ :param timeout: Timeout for the operation in seconds.
104+ Defaults to 60.
105+ """
93106 path = coerce_path (path )
94107 return await self ._upload_bytes (
95108 data = path .read_bytes (),
@@ -108,6 +121,12 @@ async def _get(
108121 * ,
109122 timeout : float = 60 ,
110123 ) -> FileTypeT :
124+ """Retrieves a file by its ID.
125+
126+ :param file_id: The unique identifier of the file to retrieve.
127+ :param timeout: Timeout for the operation in seconds.
128+ Defaults to 60.
129+ """
111130 # TODO: we need a global per-sdk cache on file_ids to rule out
112131 # possibility we have two Files with same ids but different fields
113132 request = GetFileRequest (file_id = file_id )
@@ -128,6 +147,12 @@ async def _list(
128147 page_size : UndefinedOr [int ] = UNDEFINED ,
129148 timeout : float = 60
130149 ) -> AsyncIterator [FileTypeT ]:
150+ """Lists files in the specified folder.
151+
152+ :param page_size: The maximum number of files to return per page.
153+ :param timeout: Timeout for the operation in seconds.
154+ Defaults to 60.
155+ """
131156 page_token_ = ''
132157 page_size_ = get_defined_value (page_size , 0 )
133158
@@ -180,7 +205,8 @@ async def upload_bytes(
180205 expiration_policy = expiration_policy ,
181206 timeout = timeout
182207 )
183-
208+
209+ @doc_from (BaseFiles ._upload )
184210 async def upload (
185211 self ,
186212 path : PathLike ,
@@ -204,6 +230,7 @@ async def upload(
204230 timeout = timeout
205231 )
206232
233+ @doc_from (BaseFiles ._get )
207234 async def get (
208235 self ,
209236 file_id : str ,
@@ -215,6 +242,7 @@ async def get(
215242 timeout = timeout
216243 )
217244
245+ @doc_from (BaseFiles ._list )
218246 async def list (
219247 self ,
220248 * ,
@@ -260,6 +288,7 @@ def upload_bytes(
260288 timeout = timeout
261289 )
262290
291+ @doc_from (BaseFiles ._upload )
263292 def upload (
264293 self ,
265294 path : PathLike ,
@@ -283,6 +312,7 @@ def upload(
283312 timeout = timeout
284313 )
285314
315+ @doc_from (BaseFiles ._get )
286316 def get (
287317 self ,
288318 file_id : str ,
@@ -294,6 +324,7 @@ def get(
294324 timeout = timeout
295325 )
296326
327+ @doc_from (BaseFiles ._list )
297328 def list (
298329 self ,
299330 * ,
0 commit comments