Skip to content

Commit

Permalink
Merge pull request #35 from kushalbakshi/main
Browse files Browse the repository at this point in the history
Fix `AttributeError` in NWB export for `session_with_id`
  • Loading branch information
kabilar authored Sep 19, 2023
2 parents 0705b5c + 3293368 commit 6d4681c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [0.1.6] - 2023-09-18

+ Update - NWB export checks for activated session schema to allow use of both
`session_with_id` and `session_with_datetime`


## [0.1.5] - 2023-06-20

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

[0.1.6]: https://github.com/datajoint/element-session/releases/tag/0.1.6
[0.1.5]: https://github.com/datajoint/element-session/releases/tag/0.1.5
[0.1.4]: https://github.com/datajoint/element-session/releases/tag/0.1.4
[0.1.3]: https://github.com/datajoint/element-session/releases/tag/0.1.3
Expand Down
14 changes: 11 additions & 3 deletions element_session/export/nwb.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import datetime
from uuid import uuid4
import pynwb
import datajoint as dj

from .. import session
from .. import session_with_id, session_with_datetime

if session_with_datetime.schema.is_activated():
session = session_with_datetime
elif session_with_id.schema.is_activated():
session = session_with_id
else:
raise dj.DataJointError("Session schema has not been activated.")


def session_to_nwb(
Expand All @@ -12,7 +20,7 @@ def session_to_nwb(
protocol_key: dict = None,
additional_nwbfile_kwargs=None,
) -> pynwb.NWBFile:
"""Return subject and session metadata ass NWBFile object
"""Return subject and session metadata as NWBFile object
Gather session- and subject-level metadata and use it to create an NWBFile. If there
is no subject_to_nwb export function in the current namespace, subject_id will be
Expand Down Expand Up @@ -58,7 +66,7 @@ def session_to_nwb(
session_key = (session.Session & session_key).fetch1("KEY")

session_identifier = {
k: v.isoformat() if isinstance(v, datetime.datetime) else v
k: v.isoformat() if isinstance(v, datetime.datetime) else str(v)
for k, v in session_key.items()
}

Expand Down
2 changes: 1 addition & 1 deletion element_session/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Package metadata."""
__version__ = "0.1.5"
__version__ = "0.1.6"

0 comments on commit 6d4681c

Please sign in to comment.