session_pipeline¶
Per-session pipeline factory. Selects the correct processor set for a dataset version and provides helpers to run processors and write parquet outputs.
Version dispatch is automatic: datasets with schema version < 0.6.0 receive
legacy processor variants; all others use the current implementations.
session
¶
Single-session pipeline: version dispatch, fan-out, and output writing.
Selects the correct processor set for a dataset version and returns it ready
to pass to NwbSession.run(). Version dispatch is automatic: datasets with
schema version < 0.6.0 receive the legacy processor variants.
See docs/guides/session-from-disk.md for usage examples.
create_processors(dataset, *, strict_parsing=False, include=(), exclude=())
¶
Return the ordered processor list for dataset, dispatching on version.
Parameters¶
dataset:
The loaded contraqctor Dataset. Its .version attribute determines
which processor variants are selected.
strict_parsing:
Passed through to every processor. When True, any parsing anomaly
raises; when False (default) it logs a warning and continues.
include:
If non-empty, keep only processors whose output_name is listed.
exclude:
Drop processors whose output_name is listed. Applied after
include, so an name in both is dropped.
Returns¶
list[AbstractProcessor]
Processors in the order they must be applied; session is always
first and is never filtered out — it carries the session's identity, so
every other table would lose its join key without it.
:class:~.processing.SessionMetadataProcessor is also unconditional in
the sense that it needs no arguments: it derives the session root from
the dataset's own Session stream.
Source code in src/aind_behavior_vr_foraging_packaging/pipeline/session.py
filter_processors(processors, *, include=(), exclude=())
¶
Select processors by output_name, always keeping session.
Empty include means "keep everything"; exclude is applied second.
session survives both, because dropping it would leave every other
table without the identity row it joins to.
Source code in src/aind_behavior_vr_foraging_packaging/pipeline/session.py
resolve_site_table_processor(dataset, *, strict_parsing=False)
¶
Return the correct site-table processor for dataset's version.
Source code in src/aind_behavior_vr_foraging_packaging/pipeline/session.py
resolve_position_velocity_processor(dataset, *, sampling_rate_hz=250.0, strict_parsing=False)
¶
Return the correct position/velocity processor for dataset's version.
Source code in src/aind_behavior_vr_foraging_packaging/pipeline/session.py
process_session(dataset, output_dir='.', *, strict_parsing=False, include=(), exclude=(), processors=None, on_error=None, write_parquet=True, write_nwb=False)
¶
Run every processor and write the outputs chosen by write_parquet / write_nwb.
Each processor's output_name attribute determines its parquet filename,
e.g. sites.parquet, position_velocity.parquet, etc.
The two output formats are independent switches over the same computed frames. Every processor runs regardless — the flags choose what reaches disk, not what is computed — so the returned dict is the same either way.
Log lines are prefixed with the session id, taken from the dataset, so per-processor progress stays grep-able when many sessions run in one batch.
Parameters¶
dataset:
A loaded contraqctor Dataset, or the path to a raw session directory to
load one from. Its version determines which processor variants are
selected (legacy vs current).
output_dir:
Directory where outputs are written; defaults to the current working
directory. Created if absent, unless both write_parquet and
write_nwb are False, in which case nothing is written and no
directory is made.
strict_parsing:
Passed to all processors.
include, exclude:
Processor output_name filters, forwarded to
:func:create_processors. session is never filtered out. Ignored
when processors is given, since that list is already final.
processors:
Use this exact, already-constructed processor list instead of calling
:func:create_processors internally — the escape hatch for a custom or
third-party processor. strict_parsing, include and exclude are
then irrelevant to processor construction. None (default) builds
the list from the dataset.
on_error:
Called as on_error(processor, exception) when a processor's
compute() raises, instead of letting the exception propagate.
The callback decides what happens next: returning normally skips that
processor and continues with the rest; re-raising aborts the run
immediately (the callback's own raised exception propagates out of
this function). None (default) means an exception propagates
immediately, same as before this parameter existed — every existing
caller keeps its current behavior unchanged.
write_parquet:
When True (default), write one output_dir/{output_name}.parquet
per processor, with provenance promoted into the parquet schema. Set to
False to compute without touching disk — the frames still come back
in the return value.
write_nwb:
When True, write output_dir/{session_id}.nwb.zarr from the same
processor list, so one filtered selection can produce both output
formats. Requires the AIND metadata JSON files in the session root; a
session missing them fails the NWB step, and that failure propagates
like any other. Defaults to False.
Returns¶
dict[str, pd.DataFrame]
DataFrames for every processor that computed successfully, keyed by
output_name — independent of which formats were written. A processor
whose compute() raised and whose failure was absorbed by on_error
(rather than re-raised) is simply absent from this dict.
Source code in src/aind_behavior_vr_foraging_packaging/pipeline/session.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |