1111"""
1212
1313import os
14- from typing import Any , Callable , Dict , Optional , Type , TypeVar , Union
14+ from typing import Any , Dict , Optional , Type , TypeVar , Union
1515
1616from tensorbay .label import Label
17- from tensorbay .utility import FileMixin , RemoteFileMixin , ReprMixin
17+ from tensorbay .utility import URL , FileMixin , RemoteFileMixin , ReprMixin
1818
1919
2020class DataBase (ReprMixin ):
@@ -138,14 +138,15 @@ class RemoteData(DataBase, RemoteFileMixin):
138138 Arguments:
139139 remote_path: The file remote path.
140140 timestamp: The timestamp for the file.
141- _url_getter : The url getter of the remote file .
141+ url : The URL instance used to get and update url .
142142 cache_path: The path to store the cache.
143143
144144 Attributes:
145145 path: The file remote path.
146146 timestamp: The timestamp for the file.
147147 label: The :class:`~tensorbay.label.label.Label` instance that contains
148148 all the label information of the file.
149+ url: The :class:`~tensorbay.utility.file.URL` instance used to get and update url.
149150
150151 """
151152
@@ -156,16 +157,14 @@ def __init__(
156157 remote_path : str ,
157158 * ,
158159 timestamp : Optional [float ] = None ,
159- _url_getter : Optional [Callable [[str ], str ]] = None ,
160- _url_updater : Optional [Callable [[], None ]] = None ,
160+ url : Optional [URL ] = None ,
161161 cache_path : str = "" ,
162162 ) -> None :
163163 DataBase .__init__ (self , timestamp )
164164 RemoteFileMixin .__init__ (
165165 self ,
166166 remote_path ,
167- _url_getter = _url_getter ,
168- _url_updater = _url_updater ,
167+ url = url ,
169168 cache_path = cache_path ,
170169 )
171170
@@ -174,10 +173,9 @@ def from_response_body(
174173 cls : Type [_T ],
175174 body : Dict [str , Any ],
176175 * ,
177- _url_getter : Optional [Callable [[str ], str ]],
178- _url_updater : Optional [Callable [[], None ]] = None ,
179- cache_path : str = "" , # noqa: DAR101
180- ) -> _T :
176+ url : Optional [URL ] = None ,
177+ cache_path : str = "" ,
178+ ) -> _T : # noqa: DAR101
181179 """Loads a :class:`RemoteData` object from a response body.
182180
183181 Arguments:
@@ -198,9 +196,7 @@ def from_response_body(
198196 "SENTENCE": {...}
199197 }
200198 }
201-
202- _url_getter: The url getter of the remote file.
203- _url_updater: The url updater of the remote file.
199+ url: The URL instance used to get and update url.
204200 cache_path: The path to store the cache.
205201
206202 Returns:
@@ -210,8 +206,7 @@ def from_response_body(
210206 data = cls (
211207 body ["remotePath" ],
212208 timestamp = body .get ("timestamp" ),
213- _url_getter = _url_getter ,
214- _url_updater = _url_updater ,
209+ url = url ,
215210 cache_path = cache_path ,
216211 )
217212 data .label ._loads (body ["label" ]) # pylint: disable=protected-access
@@ -230,13 +225,14 @@ class AuthData(DataBase, RemoteFileMixin):
230225 cloud_path: The cloud file path.
231226 target_remote_path: The file remote path after uploading to tensorbay.
232227 timestamp: The timestamp for the file.
233- _url_getter : The url getter of the remote file .
228+ url : The URL instance used to get and update url .
234229
235230 Attributes:
236231 path: The cloud file path.
237232 timestamp: The timestamp for the file.
238233 label: The :class:`~tensorbay.label.label.Label` instance that contains
239234 all the label information of the file.
235+ url: The :class:`~tensorbay.utility.file.URL` instance used to get and update url.
240236
241237 """
242238
@@ -246,10 +242,10 @@ def __init__(
246242 * ,
247243 target_remote_path : Optional [str ] = None ,
248244 timestamp : Optional [float ] = None ,
249- _url_getter : Optional [Callable [[ str ], str ] ] = None ,
245+ url : Optional [URL ] = None ,
250246 ) -> None :
251247 DataBase .__init__ (self , timestamp )
252- RemoteFileMixin .__init__ (self , cloud_path , _url_getter = _url_getter )
248+ RemoteFileMixin .__init__ (self , cloud_path , url = url )
253249 self ._target_remote_path = target_remote_path
254250
255251 @property
0 commit comments