@@ -144,13 +144,14 @@ async def download(
144
144
Downloads file located at URL to path.
145
145
146
146
>>> import skillsnetwork
147
- >>> await skillsnetwork.download("https://example.com/myfile", filename=filename)
148
- >>> with open(filename, "r") as f:
147
+ >>> path = './my_file.txt'
148
+ >>> await skillsnetwork.download("https://example.com/myfile", path)
149
+ >>> with open(path, "r") as f:
149
150
>>> content = f.read()
150
151
151
- :param url: URL where file is located.
152
- :param path: The path to which the file at URL should be downloaded.
153
- :param chunk_size: Number of bytes to read from url at a time.
152
+ :param url: The URL where the file is located.
153
+ :param path: The path to which the file at URL should be downloaded. Auto-generated from url by default.
154
+ :param chunk_size: The number of bytes to read from url at a time.
154
155
:raise FileNotFoundError: If path is invalid.
155
156
:raise skillsnetwork.InvalidURLException: If URL is invalid.
156
157
"""
@@ -173,9 +174,10 @@ async def read(url: str, chunk_size: int = DEFAULT_CHUNK_SIZE) -> bytes:
173
174
Reads file at URL into bytes
174
175
175
176
>>> import skillsnetwork
176
- >>> content = await skillsnetwork.read("https://example.com/myfile")
177
+ >>> content = await skillsnetwork.read("https://example.com/myfile") # Is bytes
178
+ >>> content_str = content.decode() # Is str
177
179
178
- :param url: str of URL where file is located.
180
+ :param url: The URL where the file is located.
179
181
:param chunk_size: Number of bytes to read from url at a time.
180
182
:returns: bytes containing file located at URL
181
183
:raise FileNotFoundError: If path is invalid.
@@ -192,8 +194,8 @@ async def prepare(url: str, path: Optional[str] = None, verbose: bool = True) ->
192
194
>>> import skillsnetwork
193
195
>>> await skillsnetwork.prepare("https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBM-ML0187EN-SkillsNetwork/labs/module%203/images/images.tar.gz")
194
196
195
- :param url: the URL to download the dataset from
196
- :param path: the path the dataset will be available at
197
+ :param url: The URL to download the dataset from.
198
+ :param path: The path the dataset will be available at. Current working directory by default.
197
199
:raise InvalidURLException: When URL is invalid.
198
200
:raise FileExistsError: it raises this when a file to be symlinked already exists.
199
201
:raise ValueError: When requested path is in /tmp.
0 commit comments