Closed bjhardcastle closed 8 months ago
@samgale @arjunsridhar12345 This is fixed here: https://github.com/alleninstitute/npc_session/commit/3e9bec592e7e7fe2bce7f50dda62282fa827caa4
Try to avoid slicing SessionInfo.id
and parsing it yourself though - we might change the format at some point.
It's a SessionRecord
instance and provides attributes for all the metadata components that can be extracted - use them instead:
>>> from npc_session import SessionRecord;
>>> s = SessionRecord('//allen/programs/mindscope/workgroups/templeton/TTOC/2022-07-26_14-09-36_366122')
>>> s
'366122_2022-07-26'
>>> s.idx
0
>>> s.subject
366122
>>> s.date
'2022-07-26'
>>> s.date.dt
datetime.date(2022, 7, 26)
>>> s.date.year
2022
>>> s_1 = SessionRecord('//allen/programs/mindscope/workgroups/templeton/TTOC/2022-07-26_14-09-36_366122_1')
>>> s_1.idx
1
>>> s_2 = s_1.with_idx(2)
>>> s_2.idx
2
To make it clearer, I can change this:
>>> SessionRecord('2022-07-26_14-09-36_366122')
'366122_2022-07-26'
back to this:
>>> SessionRecord('2022-07-26_14-09-36_366122')
SessionRecord('366122_2022-07-26')
printing would still access __str__
:
>>> print(SessionRecord('2022-07-26_14-09-36_366122'))
'366122_2022-07-26'