Skip to content

Commit 281a69e

Browse files
authored
fix: Improve dynamo.connect Error Reporting (#1524)
1 parent 99e67e6 commit 281a69e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

examples/multimodal/connect/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,17 @@ def __init__(
208208
if isinstance(remote_descriptors, list) and len(remote_descriptors) == 1:
209209
remote_descriptors = remote_descriptors[0]
210210

211-
if (isinstance(local_descriptors, list) and isinstance(remote_descriptors, list) and len(local_descriptors) != len(remote_descriptors)):
212-
raise ValueError("When `local_descriptors` and `remote_descriptors` are lists, they must have the same length.")
213-
elif isinstance(local_descriptors, list) != isinstance(remote_descriptors, list):
211+
if isinstance(local_descriptors, list) != isinstance(remote_descriptors, list):
214212
raise ValueError("Both `local_descriptors` and `remote_descriptors` must be either lists or single descriptors.")
213+
# Ensure that the descriptors are of the same size here to avoid confusing errors from NIXL.
214+
if isinstance(local_descriptors, list) and isinstance(remote_descriptors, list):
215+
if len(local_descriptors) != len(remote_descriptors):
216+
raise ValueError(f"When `local_descriptors` and `remote_descriptors` are lists, they must have the same length. {len(local_descriptors)} != {len(remote_descriptors)}.")
217+
for i in range(len(local_descriptors)):
218+
if local_descriptors[i].size != remote_descriptors[i].size:
219+
raise ValueError(f"Descriptor length mismatch: `local_descriptors` and `remote_descriptors` descriptor at {i} must have the same size. {local_descriptors[i].size} != {remote_descriptors[i].size}.")
220+
elif (isinstance(local_descriptors, Descriptor) and isinstance(remote_descriptors, Descriptor)) and local_descriptors.size != remote_descriptors.size:
221+
raise ValueError(f"Local and remote descriptors must be the same size. {local_descriptors.size} != {remote_descriptors.size}.")
215222
if not isinstance(notification_key, str):
216223
raise TypeError("Argument `notification_key` must be `str`.")
217224
if len(notification_key) == 0:

0 commit comments

Comments
 (0)