Skip to content

Commit 60bf01d

Browse files
committed
Fix session_list to return tuple of (session_references, session_list)
The method previously returned a single list, causing a ValueError when unpacking into two variables (sessrefs, sesslist = D.session_list()). Now returns a tuple matching the MATLAB convention. https://claude.ai/code/session_011dfeoCuRP6gCP6R9FYk2rH
1 parent 106d141 commit 60bf01d

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/ndi/dataset/_dataset.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,33 +224,38 @@ def open_session(self, session_id: str) -> Any | None:
224224

225225
return session
226226

227-
def session_list(self) -> list[dict[str, Any]]:
227+
def session_list(self) -> tuple[list[str], list[dict[str, Any]]]:
228228
"""
229229
List all sessions in this dataset.
230230
231231
Returns:
232-
List of dicts with keys:
233-
- session_id: Session identifier
234-
- session_reference: Session reference name
235-
- is_linked: True if linked, False if ingested
236-
- document_id: ID of the session_in_a_dataset document
232+
A tuple of (session_references, session_list) where:
233+
- session_references: List of session reference strings
234+
- session_list: List of dicts with keys:
235+
- session_id: Session identifier
236+
- session_reference: Session reference name
237+
- is_linked: True if linked, False if ingested
238+
- document_id: ID of the session_in_a_dataset document
237239
"""
238240
q = Query("").isa("session_in_a_dataset")
239241
docs = self._session.database_search(q)
240242

241-
result = []
243+
session_references = []
244+
session_list = []
242245
for doc in docs:
243246
props = doc.document_properties.get("session_in_a_dataset", {})
244-
result.append(
247+
ref = props.get("session_reference", "")
248+
session_references.append(ref)
249+
session_list.append(
245250
{
246251
"session_id": props.get("session_id", ""),
247-
"session_reference": props.get("session_reference", ""),
252+
"session_reference": ref,
248253
"is_linked": bool(props.get("is_linked", False)),
249254
"document_id": doc.id,
250255
}
251256
)
252257

253-
return result
258+
return session_references, session_list
254259

255260
# =========================================================================
256261
# Database Operations (delegated to internal session)

0 commit comments

Comments
 (0)