Skip to content

Commit 6d4681c

Browse files
authored
Merge pull request #35 from kushalbakshi/main
Fix `AttributeError` in NWB export for `session_with_id`
2 parents 0705b5c + 3293368 commit 6d4681c

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
44

5+
## [0.1.6] - 2023-09-18
6+
7+
+ Update - NWB export checks for activated session schema to allow use of both
8+
`session_with_id` and `session_with_datetime`
9+
10+
511
## [0.1.5] - 2023-06-20
612

713
+ Update - GitHub Actions workflows
@@ -39,6 +45,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
3945
+ Add - GitHub Action release process
4046
+ Add - `session` schema
4147

48+
[0.1.6]: https://github.com/datajoint/element-session/releases/tag/0.1.6
4249
[0.1.5]: https://github.com/datajoint/element-session/releases/tag/0.1.5
4350
[0.1.4]: https://github.com/datajoint/element-session/releases/tag/0.1.4
4451
[0.1.3]: https://github.com/datajoint/element-session/releases/tag/0.1.3

element_session/export/nwb.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import datetime
22
from uuid import uuid4
33
import pynwb
4+
import datajoint as dj
45

5-
from .. import session
6+
from .. import session_with_id, session_with_datetime
7+
8+
if session_with_datetime.schema.is_activated():
9+
session = session_with_datetime
10+
elif session_with_id.schema.is_activated():
11+
session = session_with_id
12+
else:
13+
raise dj.DataJointError("Session schema has not been activated.")
614

715

816
def session_to_nwb(
@@ -12,7 +20,7 @@ def session_to_nwb(
1220
protocol_key: dict = None,
1321
additional_nwbfile_kwargs=None,
1422
) -> pynwb.NWBFile:
15-
"""Return subject and session metadata ass NWBFile object
23+
"""Return subject and session metadata as NWBFile object
1624
1725
Gather session- and subject-level metadata and use it to create an NWBFile. If there
1826
is no subject_to_nwb export function in the current namespace, subject_id will be
@@ -58,7 +66,7 @@ def session_to_nwb(
5866
session_key = (session.Session & session_key).fetch1("KEY")
5967

6068
session_identifier = {
61-
k: v.isoformat() if isinstance(v, datetime.datetime) else v
69+
k: v.isoformat() if isinstance(v, datetime.datetime) else str(v)
6270
for k, v in session_key.items()
6371
}
6472

element_session/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Package metadata."""
2-
__version__ = "0.1.5"
2+
__version__ = "0.1.6"

0 commit comments

Comments
 (0)