From 60bf01d8178f0ca62e5dd21bce0071a2e97d156b Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Mar 2026 20:48:31 +0000 Subject: [PATCH] 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 --- src/ndi/dataset/_dataset.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/ndi/dataset/_dataset.py b/src/ndi/dataset/_dataset.py index ce41064..39de3ce 100644 --- a/src/ndi/dataset/_dataset.py +++ b/src/ndi/dataset/_dataset.py @@ -224,33 +224,38 @@ def open_session(self, session_id: str) -> Any | None: return session - def session_list(self) -> list[dict[str, Any]]: + def session_list(self) -> tuple[list[str], list[dict[str, Any]]]: """ List all sessions in this dataset. Returns: - List of dicts with keys: - - session_id: Session identifier - - session_reference: Session reference name - - is_linked: True if linked, False if ingested - - document_id: ID of the session_in_a_dataset document + A tuple of (session_references, session_list) where: + - session_references: List of session reference strings + - session_list: List of dicts with keys: + - session_id: Session identifier + - session_reference: Session reference name + - is_linked: True if linked, False if ingested + - document_id: ID of the session_in_a_dataset document """ q = Query("").isa("session_in_a_dataset") docs = self._session.database_search(q) - result = [] + session_references = [] + session_list = [] for doc in docs: props = doc.document_properties.get("session_in_a_dataset", {}) - result.append( + ref = props.get("session_reference", "") + session_references.append(ref) + session_list.append( { "session_id": props.get("session_id", ""), - "session_reference": props.get("session_reference", ""), + "session_reference": ref, "is_linked": bool(props.get("is_linked", False)), "document_id": doc.id, } ) - return result + return session_references, session_list # ========================================================================= # Database Operations (delegated to internal session)