Skip to content

Commit

Permalink
Test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie committed Sep 3, 2024
1 parent 2fa72f8 commit b4a52c0
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 121 deletions.
4 changes: 2 additions & 2 deletions darwin/cli_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,8 @@ def file_upload_callback(
_error(f"No dataset with name '{e.name}'")
except UnsupportedFileType as e:
_error(f"Unsupported file type {e.path.suffix} ({e.path.name})")
except ValueError:
_error("No files found")
except ValueError as e:
_error(f"{e}")


def dataset_import(
Expand Down
2 changes: 1 addition & 1 deletion darwin/dataset/remote_dataset_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def push(
)
if preserve_folders:
raise TypeError(
"`item_merge_mode` does not support preserving local file structures with `preserve_folders` or `--folders`"
"`item_merge_mode` does not support preserving local file structures with `preserve_folders`"
)

# Direct file paths
Expand Down
10 changes: 8 additions & 2 deletions darwin/dataset/upload_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from darwin.doc_enum import DocEnum
from darwin.path_utils import construct_full_path
from darwin.utils import chunk
from darwin.utils.utils import is_image_extension_allowed_by_filename

if TYPE_CHECKING:
from darwin.client import Client
Expand Down Expand Up @@ -254,6 +255,11 @@ def _create_layout(self):
"type": "grid",
}
elif self.merge_mode == ItemMergeMode.CHANNELS:
self.files = [
file
for file in self.files
if is_image_extension_allowed_by_filename(str(file.local_path))
] # Currently, only image files are supported in multi-channel items. This is planned to change in the future
if len(self.files) > 16:
raise ValueError(
f"No multi-channel item can have more than 16 files. The following directory has {len(self.files)} files: {self.directory}"
Expand Down Expand Up @@ -578,8 +584,8 @@ def upload_function(
for item in self.pending_items:
for slot in item.slots:
upload_id = slot["upload_id"]
slot_path = item.path + (slot["file_name"])
file = file_lookup.get(slot_path)
slot_path = Path(item.path) / Path((slot["file_name"]))
file = file_lookup.get(str(slot_path))
if not file:
raise ValueError(
f"Cannot match {slot_path} from payload with files to upload"
Expand Down
Binary file modified tests/darwin/data/push_test_dir.zip
Binary file not shown.
Loading

0 comments on commit b4a52c0

Please sign in to comment.