Skip to content

Commit e33c210

Browse files
committed
Raise an error when downloading non-existent files
from a data object
1 parent c1a8c4c commit e33c210

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

docs/CHANGELOG.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ Change Log
44

55
All notable changes to this project are documented in this file.
66

7+
==========
8+
Unreleased
9+
==========
10+
11+
Fixed
12+
-----
13+
- Raise an error if a user calls the download method
14+
on a data object and inputs a non-existing file or field name
15+
16+
717
===================
818
22.2.3 - 2026-02-18
919
===================

src/resdk/resources/data.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ def download(
284284
file_names = self.files(file_name, field_name)
285285
files = ["{}/{}".format(self.id, fname) for fname in file_names]
286286

287+
if not files:
288+
raise ValueError(
289+
f"Data object contains no files with "
290+
f"{'file name: ' + repr(file_name) if file_name else 'field name: ' + repr(field_name)}."
291+
)
292+
287293
self.resolwe._download_files(
288294
files=files, download_dir=download_dir, show_progress=show_progress
289295
)

tests/functional/docs/e2e_docs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ def test_start(self):
165165
replace_lines=[
166166
(4, "res = resdk.Resolwe(url='{}')\n".format(URL)),
167167
(5, "res.login('{}', '{}')\n".format(USER_EMAIL, USER_PASSWORD)),
168+
# Skip download, since data objects have not finished processing
169+
(49, "\n"),
168170
],
169171
)
170172

@@ -233,6 +235,10 @@ def test_tutorial_create(self):
233235
# is replaced with an empty line. There is now way to perform
234236
# download if data objects are still processing and/or have not
235237
# produced any stdout.txt. So just write an empty line:
238+
(9, "\n"),
239+
(10, "\n"),
240+
(11, "\n"),
241+
(12, "\n"),
236242
(107, "\n"),
237243
],
238244
)

0 commit comments

Comments
 (0)