npc-sessions 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- npc_sessions-0.0.1/PKG-INFO +42 -0
- npc_sessions-0.0.1/README.md +25 -0
- npc_sessions-0.0.1/pyproject.toml +164 -0
- npc_sessions-0.0.1/setup.cfg +4 -0
- npc_sessions-0.0.1/src/npc_sessions/__init__.py +5 -0
- npc_sessions-0.0.1/src/npc_sessions/tracked_sessions.py +82 -0
- npc_sessions-0.0.1/src/npc_sessions/utils.py +8 -0
- npc_sessions-0.0.1/src/npc_sessions.egg-info/PKG-INFO +42 -0
- npc_sessions-0.0.1/src/npc_sessions.egg-info/SOURCES.txt +10 -0
- npc_sessions-0.0.1/src/npc_sessions.egg-info/dependency_links.txt +1 -0
- npc_sessions-0.0.1/src/npc_sessions.egg-info/requires.txt +23 -0
- npc_sessions-0.0.1/src/npc_sessions.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: npc_sessions
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Tools and interfaces for working with behavior and epyhys sessions from the Mindscope Neuropixels team, in the cloud.
|
|
5
|
+
Author-email: Ben Hardcastle <ben.hardcastle@alleninstitute.org>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
|
|
18
|
+
# npc_sessions
|
|
19
|
+
**n**euro**p**ixels **c**loud **sessions**
|
|
20
|
+
|
|
21
|
+
Tools and interfaces for working with behavior and epyhys sessions from the
|
|
22
|
+
Mindscope Neuropixels team, in the cloud.
|
|
23
|
+
|
|
24
|
+
## quickstart
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install npc_sessions
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Get some minimal info on all the tracked sessions available to work with:
|
|
31
|
+
```python
|
|
32
|
+
>>> from npc_sessions import tracked as tracked_sessions;
|
|
33
|
+
|
|
34
|
+
# each record in the sequence has info about one session:
|
|
35
|
+
>>> tracked_sessions[0]._fields
|
|
36
|
+
('session', 'subject', 'date', 'idx', 'project', 'is_ephys', 'is_sync')
|
|
37
|
+
>>> tracked_sessions[0].is_ephys
|
|
38
|
+
True
|
|
39
|
+
>>> all(s.date.year >= 2022 for s in tracked_sessions)
|
|
40
|
+
True
|
|
41
|
+
|
|
42
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# npc_sessions
|
|
2
|
+
**n**euro**p**ixels **c**loud **sessions**
|
|
3
|
+
|
|
4
|
+
Tools and interfaces for working with behavior and epyhys sessions from the
|
|
5
|
+
Mindscope Neuropixels team, in the cloud.
|
|
6
|
+
|
|
7
|
+
## quickstart
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install npc_sessions
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Get some minimal info on all the tracked sessions available to work with:
|
|
14
|
+
```python
|
|
15
|
+
>>> from npc_sessions import tracked as tracked_sessions;
|
|
16
|
+
|
|
17
|
+
# each record in the sequence has info about one session:
|
|
18
|
+
>>> tracked_sessions[0]._fields
|
|
19
|
+
('session', 'subject', 'date', 'idx', 'project', 'is_ephys', 'is_sync')
|
|
20
|
+
>>> tracked_sessions[0].is_ephys
|
|
21
|
+
True
|
|
22
|
+
>>> all(s.date.year >= 2022 for s in tracked_sessions)
|
|
23
|
+
True
|
|
24
|
+
|
|
25
|
+
```
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "npc_sessions"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Tools and interfaces for working with behavior and epyhys sessions from the Mindscope Neuropixels team, in the cloud."
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "Ben Hardcastle", email = "ben.hardcastle@alleninstitute.org" },
|
|
7
|
+
]
|
|
8
|
+
dependencies = [
|
|
9
|
+
"typing-extensions>=4.7.1",
|
|
10
|
+
"pyyaml>=6.0.1",
|
|
11
|
+
"npc-session>=0.1.1",
|
|
12
|
+
"types-PyYAML>=6.0.12.11",
|
|
13
|
+
]
|
|
14
|
+
requires-python = ">=3.9"
|
|
15
|
+
readme = "README.md"
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.9",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Operating System :: Microsoft :: Windows",
|
|
23
|
+
"Operating System :: POSIX :: Linux",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.license]
|
|
27
|
+
text = "MIT"
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = [
|
|
31
|
+
"universal-pathlib>=0.0.23",
|
|
32
|
+
"pandas[aws,excel,fss,hdf5,performance,plot]>=2.0.3",
|
|
33
|
+
"pyarrow>=12.0.1",
|
|
34
|
+
"pydantic>=2.0.3",
|
|
35
|
+
"s3fs>=2023.6.0",
|
|
36
|
+
"aiopath>=0.5.12",
|
|
37
|
+
"aiofiles>=23.1.0",
|
|
38
|
+
"httpx>=0.24.1",
|
|
39
|
+
"pydbhub>=0.0.4",
|
|
40
|
+
"requests>=2.31.0",
|
|
41
|
+
"pytest>=7.4.0",
|
|
42
|
+
"coverage[toml]>=7.2.7",
|
|
43
|
+
"ruff>=0.0.282",
|
|
44
|
+
"pytest-cov>=4.1.0",
|
|
45
|
+
"pdm-bump>=0.7.3",
|
|
46
|
+
"types-PyYAML>=6.0.12.11",
|
|
47
|
+
"mypy>=1.4.1",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[build-system]
|
|
51
|
+
requires = [
|
|
52
|
+
"setuptools>=61",
|
|
53
|
+
"wheel",
|
|
54
|
+
]
|
|
55
|
+
build-backend = "setuptools.build_meta"
|
|
56
|
+
|
|
57
|
+
[tool.pdm.scripts]
|
|
58
|
+
ruff = "ruff check src --fix-only"
|
|
59
|
+
black = "black src"
|
|
60
|
+
test = "pytest --cov"
|
|
61
|
+
mypy = "mypy src"
|
|
62
|
+
bump = "pdm bump micro"
|
|
63
|
+
|
|
64
|
+
[tool.pdm.scripts.prebuild]
|
|
65
|
+
composite = [
|
|
66
|
+
"black",
|
|
67
|
+
"ruff",
|
|
68
|
+
"test",
|
|
69
|
+
"mypy",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[tool.pdm.scripts.build]
|
|
73
|
+
composite = [
|
|
74
|
+
"prebuild",
|
|
75
|
+
"pdm build",
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
[tool.pdm.scripts.dryrun]
|
|
79
|
+
composite = [
|
|
80
|
+
"build",
|
|
81
|
+
"pdm publish --no-build --repository https://test.pypi.org/simple",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[tool.pdm.scripts.pub]
|
|
85
|
+
composite = [
|
|
86
|
+
"build",
|
|
87
|
+
"bump",
|
|
88
|
+
"pdm publish --no-build",
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
[tool.ruff]
|
|
92
|
+
fix = true
|
|
93
|
+
ignore-init-module-imports = true
|
|
94
|
+
select = [
|
|
95
|
+
"ANN",
|
|
96
|
+
"B",
|
|
97
|
+
"C",
|
|
98
|
+
"E",
|
|
99
|
+
"F",
|
|
100
|
+
"I",
|
|
101
|
+
"RUF100",
|
|
102
|
+
"N",
|
|
103
|
+
"U",
|
|
104
|
+
"W",
|
|
105
|
+
"YTT",
|
|
106
|
+
]
|
|
107
|
+
extend-exclude = [
|
|
108
|
+
"tests",
|
|
109
|
+
]
|
|
110
|
+
src = [
|
|
111
|
+
"src",
|
|
112
|
+
"tests",
|
|
113
|
+
]
|
|
114
|
+
target-version = "py39"
|
|
115
|
+
|
|
116
|
+
[tool.ruff.flake8-tidy-imports]
|
|
117
|
+
ban-relative-imports = "all"
|
|
118
|
+
|
|
119
|
+
[tool.black]
|
|
120
|
+
target-version = [
|
|
121
|
+
"py39",
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
[tool.coverage.paths]
|
|
125
|
+
source = [
|
|
126
|
+
"src",
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
[tool.coverage.run]
|
|
130
|
+
branch = true
|
|
131
|
+
source = [
|
|
132
|
+
"src",
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
[tool.coverage.report]
|
|
136
|
+
skip_covered = true
|
|
137
|
+
show_missing = true
|
|
138
|
+
skip_empty = true
|
|
139
|
+
exclude_also = [
|
|
140
|
+
"raise AssertionError",
|
|
141
|
+
"raise NotImplementedError",
|
|
142
|
+
"if __name__ == .__main__.:",
|
|
143
|
+
"@(abc.)?abstractmethod",
|
|
144
|
+
"@typing.runtime_checkable",
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
[tool.pytest.ini_options]
|
|
148
|
+
addopts = [
|
|
149
|
+
"--import-mode=importlib",
|
|
150
|
+
"--doctest-modules",
|
|
151
|
+
"--ignore-glob=*scripts*,*examples*",
|
|
152
|
+
"--cov",
|
|
153
|
+
"--doctest-glob=*README.md",
|
|
154
|
+
]
|
|
155
|
+
doctest_optionflags = [
|
|
156
|
+
"NORMALIZE_WHITESPACE",
|
|
157
|
+
"IGNORE_EXCEPTION_DETAIL",
|
|
158
|
+
"ELLIPSIS",
|
|
159
|
+
]
|
|
160
|
+
testpaths = [
|
|
161
|
+
".",
|
|
162
|
+
"src",
|
|
163
|
+
"tests",
|
|
164
|
+
]
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import pathlib
|
|
3
|
+
from collections.abc import MutableSequence
|
|
4
|
+
from typing import Literal, NamedTuple, TypeAlias
|
|
5
|
+
|
|
6
|
+
import npc_session # type: ignore
|
|
7
|
+
import yaml
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SessionInfo(NamedTuple):
|
|
11
|
+
session: npc_session.SessionRecord
|
|
12
|
+
subject: npc_session.SubjectRecord
|
|
13
|
+
date: npc_session.DateRecord
|
|
14
|
+
idx: int
|
|
15
|
+
project: npc_session.ProjectRecord
|
|
16
|
+
is_ephys: bool
|
|
17
|
+
is_sync: bool
|
|
18
|
+
"""The session has sync data, implying more than a behavior-box."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_session_info() -> tuple[SessionInfo, ...]:
|
|
22
|
+
"""Quickly get a sequence of all tracked sessions.
|
|
23
|
+
|
|
24
|
+
Each object in the sequence has info about one session:
|
|
25
|
+
>>> sessions = get_session_info()
|
|
26
|
+
>>> sessions[0].__class__.__name__
|
|
27
|
+
'SessionInfo'
|
|
28
|
+
>>> sessions[0].is_ephys
|
|
29
|
+
True
|
|
30
|
+
>>> any(s for s in sessions if s.date.year < 2021)
|
|
31
|
+
False
|
|
32
|
+
"""
|
|
33
|
+
return _get_session_info_from_local_file()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
_LOCAL_FILE = pathlib.Path(__file__).parent / "tracked_sessions.yaml"
|
|
37
|
+
FileContents: TypeAlias = dict[
|
|
38
|
+
Literal["ephys", "behavior_with_sync", "behavior"], dict[str, str]
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _get_session_info_from_local_file() -> tuple[SessionInfo, ...]:
|
|
43
|
+
"""Load yaml and parse sessions.
|
|
44
|
+
- currently assumes all sessions include behavior data
|
|
45
|
+
"""
|
|
46
|
+
f = _session_info_from_file_contents
|
|
47
|
+
if _LOCAL_FILE.suffix == ".json":
|
|
48
|
+
return f(json.loads(_LOCAL_FILE.read_text()))
|
|
49
|
+
if _LOCAL_FILE.suffix == ".yaml":
|
|
50
|
+
return f(yaml.load(_LOCAL_FILE.read_bytes(), yaml.FullLoader))
|
|
51
|
+
raise ValueError(f"Add loader for {_LOCAL_FILE.suffix}") # pragma: no cover
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _session_info_from_file_contents(contents: FileContents) -> tuple[SessionInfo, ...]:
|
|
55
|
+
sessions: MutableSequence[SessionInfo] = []
|
|
56
|
+
for session_type, projects in contents.items():
|
|
57
|
+
if not projects:
|
|
58
|
+
continue
|
|
59
|
+
sync = any(tag in session_type for tag in ("sync", "ephys"))
|
|
60
|
+
ephys = "ephys" in session_type
|
|
61
|
+
for project_name, session_ids in projects.items():
|
|
62
|
+
if not session_ids:
|
|
63
|
+
continue
|
|
64
|
+
for session_id in session_ids:
|
|
65
|
+
s = npc_session.SessionRecord(session_id)
|
|
66
|
+
sessions.append(
|
|
67
|
+
SessionInfo(
|
|
68
|
+
*(s, s.subject, s.date, s.idx),
|
|
69
|
+
project=npc_session.ProjectRecord(project_name),
|
|
70
|
+
is_ephys=ephys,
|
|
71
|
+
is_sync=sync,
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
return tuple(sessions)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
if __name__ == "__main__":
|
|
78
|
+
import doctest
|
|
79
|
+
|
|
80
|
+
doctest.testmod(
|
|
81
|
+
optionflags=(doctest.IGNORE_EXCEPTION_DETAIL | doctest.NORMALIZE_WHITESPACE)
|
|
82
|
+
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: npc-sessions
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Tools and interfaces for working with behavior and epyhys sessions from the Mindscope Neuropixels team, in the cloud.
|
|
5
|
+
Author-email: Ben Hardcastle <ben.hardcastle@alleninstitute.org>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Requires-Python: >=3.9
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
|
|
18
|
+
# npc_sessions
|
|
19
|
+
**n**euro**p**ixels **c**loud **sessions**
|
|
20
|
+
|
|
21
|
+
Tools and interfaces for working with behavior and epyhys sessions from the
|
|
22
|
+
Mindscope Neuropixels team, in the cloud.
|
|
23
|
+
|
|
24
|
+
## quickstart
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install npc_sessions
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Get some minimal info on all the tracked sessions available to work with:
|
|
31
|
+
```python
|
|
32
|
+
>>> from npc_sessions import tracked as tracked_sessions;
|
|
33
|
+
|
|
34
|
+
# each record in the sequence has info about one session:
|
|
35
|
+
>>> tracked_sessions[0]._fields
|
|
36
|
+
('session', 'subject', 'date', 'idx', 'project', 'is_ephys', 'is_sync')
|
|
37
|
+
>>> tracked_sessions[0].is_ephys
|
|
38
|
+
True
|
|
39
|
+
>>> all(s.date.year >= 2022 for s in tracked_sessions)
|
|
40
|
+
True
|
|
41
|
+
|
|
42
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/npc_sessions/__init__.py
|
|
4
|
+
src/npc_sessions/tracked_sessions.py
|
|
5
|
+
src/npc_sessions/utils.py
|
|
6
|
+
src/npc_sessions.egg-info/PKG-INFO
|
|
7
|
+
src/npc_sessions.egg-info/SOURCES.txt
|
|
8
|
+
src/npc_sessions.egg-info/dependency_links.txt
|
|
9
|
+
src/npc_sessions.egg-info/requires.txt
|
|
10
|
+
src/npc_sessions.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
typing-extensions>=4.7.1
|
|
2
|
+
pyyaml>=6.0.1
|
|
3
|
+
npc-session>=0.1.1
|
|
4
|
+
types-PyYAML>=6.0.12.11
|
|
5
|
+
|
|
6
|
+
[dev]
|
|
7
|
+
universal-pathlib>=0.0.23
|
|
8
|
+
pandas[aws,excel,fss,hdf5,performance,plot]>=2.0.3
|
|
9
|
+
pyarrow>=12.0.1
|
|
10
|
+
pydantic>=2.0.3
|
|
11
|
+
s3fs>=2023.6.0
|
|
12
|
+
aiopath>=0.5.12
|
|
13
|
+
aiofiles>=23.1.0
|
|
14
|
+
httpx>=0.24.1
|
|
15
|
+
pydbhub>=0.0.4
|
|
16
|
+
requests>=2.31.0
|
|
17
|
+
pytest>=7.4.0
|
|
18
|
+
coverage[toml]>=7.2.7
|
|
19
|
+
ruff>=0.0.282
|
|
20
|
+
pytest-cov>=4.1.0
|
|
21
|
+
pdm-bump>=0.7.3
|
|
22
|
+
types-PyYAML>=6.0.12.11
|
|
23
|
+
mypy>=1.4.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npc_sessions
|