aind-behavior-vr-foraging 0.6.0__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.
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: aind-behavior-vr-foraging
3
+ Version: 0.6.0
4
+ Summary: A library that defines AIND data schema for the Aind Behavior VR Foraging experiment.
5
+ Author: Bruno Cruz
6
+ Author-email: Bruno Cruz <bruno.cruz@alleninstitute.org>
7
+ License-Expression: MIT
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Operating System :: Microsoft :: Windows
10
+ Requires-Dist: aind-behavior-services>=0.12,<0.13
11
+ Requires-Dist: pydantic-settings
12
+ Requires-Dist: contraqctor<0.6.0 ; extra == 'data'
13
+ Requires-Dist: aind-clabe[aind-services]>=0.8.0,<0.9.0 ; extra == 'launcher'
14
+ Requires-Dist: aind-data-schema>=2 ; extra == 'launcher'
15
+ Requires-Dist: aind-behavior-vr-foraging[data] ; extra == 'launcher'
16
+ Requires-Python: >=3.11
17
+ Project-URL: Changelog, https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/releases
18
+ Project-URL: Documentation, https://allenneuraldynamics.github.io/Aind.Behavior.VrForaging/
19
+ Project-URL: Issues, https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/issues
20
+ Project-URL: Repository, https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/
21
+ Provides-Extra: data
22
+ Provides-Extra: launcher
23
+ Description-Content-Type: text/markdown
24
+
25
+ # aind-vr-foraging
26
+
27
+ ![CI](https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/actions/workflows/vr-foraging-cicd.yml/badge.svg)
28
+ [![PyPI - Version](https://img.shields.io/pypi/v/aind-behavior-vr-foraging)](https://pypi.org/project/aind-behavior-vr-foraging/)
29
+ [![License](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
30
+ [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
31
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
32
+
33
+ A repository for the VR Foraging task.
34
+
35
+ ---
36
+
37
+ ## 📋 General instructions
38
+
39
+ This repository follows the project structure laid out in the [Aind.Behavior.Services repository](https://github.com/AllenNeuralDynamics/Aind.Behavior.Services).
40
+
41
+ ---
42
+
43
+ ## 🔧 Prerequisites
44
+
45
+ [Pre-requisites for running the project can be found here](https://allenneuraldynamics.github.io/Aind.Behavior.Services/articles/requirements.html).
46
+
47
+ ---
48
+
49
+ ## 🚀 Deployment
50
+
51
+ For convenience, once third-party dependencies are installed, `Bonsai` and `python` virtual environments can be bootstrapped by running:
52
+
53
+ ```powershell
54
+ ./scripts/deploy.ps1
55
+ ```
56
+
57
+ from the root of the repository.
58
+
59
+ ## ⚙️ Generating settings files
60
+
61
+ The VR Foraging tasks is instantiated by a set of three settings files that strictly follow a DSL schema. These files are:
62
+
63
+ - `task_logic.json`
64
+ - `rig.json`
65
+ - `session.json`
66
+
67
+ Examples on how to generate these files can be found in the `./Examples` directory of the repository. Once generated, these are the the only required inputs to run the Bonsai workflow in `./src/main.bonsai`.
68
+
69
+ The workflow can thus be executed using the [Bonsai CLI](https://bonsai-rx.org/docs/articles/cli.html):
70
+
71
+ ```powershell
72
+ "./bonsai/bonsai.exe" "./src/main.bonsai" -p SessionPath=<path-to-session.json> -p RigPath=<path-to-rig.json> -p TaskLogicPath=<path-to-task_logic.json>
73
+ ```
74
+
75
+ However, for a better experiment management user experience, it is recommended to use the provided experiment launcher below.
76
+
77
+ ## [> ] CLI tools
78
+
79
+ The platform exposes a few CLI tools to facilitate various tasks. Tools are available via:
80
+
81
+ ```powershell
82
+ uv run vr-foraging <subcommand>
83
+ ```
84
+
85
+ for a list of all sub commands available:
86
+
87
+ ```powershell
88
+ uv run vr-foraging -h
89
+ ```
90
+
91
+ You may need to install optional dependencies depending on the sub-commands you run.
92
+
93
+ ## 🎮 Experiment launcher (CLABE)
94
+
95
+ To manage experiments and input files, this repository contains a launcher script that can be used to run the VR Foraging task. This script is located at `./src/aind_behavior_vr_foraging/launcher.py`. It can be run from the command line as follows:
96
+
97
+ ```powershell
98
+ uv run vr-foraging clabe
99
+ ```
100
+
101
+ Additional arguments can be passed to the script as needed:
102
+
103
+ ```powershell
104
+ uv run vr-foraging clabe -h
105
+ ```
106
+
107
+ or via a `./local/clabe.yml` file. (An example can be found in `./Examples/clabe.yml`)
108
+
109
+ In order to run the launcher script, optional dependencies should be installed via:
110
+
111
+ Additional custom launcher scripts can be created and used as needed.
112
+
113
+ ## 🔍 Primary data quality-control
114
+
115
+ Once an experiment is collected, the primary data quality-control script can be run to check the data for issues. This script can be launcher using:
116
+
117
+ ```powershell
118
+ uv run vr-foraging data-qc <path-to-data-dir>
119
+ ```
120
+
121
+ ## 🌉 Mapping to aind-data-schema
122
+
123
+ Once an experiment is collected, data can be mapped to aind-data-schema using the `data-mapper` sub-command:
124
+
125
+ ```powershell
126
+ uv run vr-foraging data-mapper
127
+ ```
128
+
129
+ ## 🔄 Regenerating schemas
130
+
131
+ DSL schemas can be modified in `./src/aind_behavior_vr_foraging/rig.py` (or `(...)/task_logic`.py`).
132
+
133
+ Once modified, changes to the DSL must be propagated to `json-schema` and `csharp` API. This can be done by running:
134
+
135
+ ```powershell
136
+ uv run vr-foraging regenerate
137
+ ```
138
+
139
+ ## 📖 Curricula
140
+
141
+ The VrForaging platform supports a curricula structure that allows for the organization and management of different learning paths and experiences. The implementation relies on the a common definition of "curriculum" progression provided by [`aind-behavior-curriculum`](https://github.com/AllenNeuralDynamics/aind-behavior-curriculum).
142
+
143
+ Curricula are expected to be defined in `src/aind_behavior_vr_foraging/curricula/` by adding individual submodules that follow the structure of [`https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging.Curricula`](https://allenneuraldynamics.github.io/Aind.Behavior.VrForaging.Curricula/). Updates to the curriculum will therefore require, by design, explicitly updating the submodule reference via a reviewed pull request.
@@ -0,0 +1,119 @@
1
+ # aind-vr-foraging
2
+
3
+ ![CI](https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/actions/workflows/vr-foraging-cicd.yml/badge.svg)
4
+ [![PyPI - Version](https://img.shields.io/pypi/v/aind-behavior-vr-foraging)](https://pypi.org/project/aind-behavior-vr-foraging/)
5
+ [![License](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
6
+ [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
7
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
8
+
9
+ A repository for the VR Foraging task.
10
+
11
+ ---
12
+
13
+ ## 📋 General instructions
14
+
15
+ This repository follows the project structure laid out in the [Aind.Behavior.Services repository](https://github.com/AllenNeuralDynamics/Aind.Behavior.Services).
16
+
17
+ ---
18
+
19
+ ## 🔧 Prerequisites
20
+
21
+ [Pre-requisites for running the project can be found here](https://allenneuraldynamics.github.io/Aind.Behavior.Services/articles/requirements.html).
22
+
23
+ ---
24
+
25
+ ## 🚀 Deployment
26
+
27
+ For convenience, once third-party dependencies are installed, `Bonsai` and `python` virtual environments can be bootstrapped by running:
28
+
29
+ ```powershell
30
+ ./scripts/deploy.ps1
31
+ ```
32
+
33
+ from the root of the repository.
34
+
35
+ ## ⚙️ Generating settings files
36
+
37
+ The VR Foraging tasks is instantiated by a set of three settings files that strictly follow a DSL schema. These files are:
38
+
39
+ - `task_logic.json`
40
+ - `rig.json`
41
+ - `session.json`
42
+
43
+ Examples on how to generate these files can be found in the `./Examples` directory of the repository. Once generated, these are the the only required inputs to run the Bonsai workflow in `./src/main.bonsai`.
44
+
45
+ The workflow can thus be executed using the [Bonsai CLI](https://bonsai-rx.org/docs/articles/cli.html):
46
+
47
+ ```powershell
48
+ "./bonsai/bonsai.exe" "./src/main.bonsai" -p SessionPath=<path-to-session.json> -p RigPath=<path-to-rig.json> -p TaskLogicPath=<path-to-task_logic.json>
49
+ ```
50
+
51
+ However, for a better experiment management user experience, it is recommended to use the provided experiment launcher below.
52
+
53
+ ## [> ] CLI tools
54
+
55
+ The platform exposes a few CLI tools to facilitate various tasks. Tools are available via:
56
+
57
+ ```powershell
58
+ uv run vr-foraging <subcommand>
59
+ ```
60
+
61
+ for a list of all sub commands available:
62
+
63
+ ```powershell
64
+ uv run vr-foraging -h
65
+ ```
66
+
67
+ You may need to install optional dependencies depending on the sub-commands you run.
68
+
69
+ ## 🎮 Experiment launcher (CLABE)
70
+
71
+ To manage experiments and input files, this repository contains a launcher script that can be used to run the VR Foraging task. This script is located at `./src/aind_behavior_vr_foraging/launcher.py`. It can be run from the command line as follows:
72
+
73
+ ```powershell
74
+ uv run vr-foraging clabe
75
+ ```
76
+
77
+ Additional arguments can be passed to the script as needed:
78
+
79
+ ```powershell
80
+ uv run vr-foraging clabe -h
81
+ ```
82
+
83
+ or via a `./local/clabe.yml` file. (An example can be found in `./Examples/clabe.yml`)
84
+
85
+ In order to run the launcher script, optional dependencies should be installed via:
86
+
87
+ Additional custom launcher scripts can be created and used as needed.
88
+
89
+ ## 🔍 Primary data quality-control
90
+
91
+ Once an experiment is collected, the primary data quality-control script can be run to check the data for issues. This script can be launcher using:
92
+
93
+ ```powershell
94
+ uv run vr-foraging data-qc <path-to-data-dir>
95
+ ```
96
+
97
+ ## 🌉 Mapping to aind-data-schema
98
+
99
+ Once an experiment is collected, data can be mapped to aind-data-schema using the `data-mapper` sub-command:
100
+
101
+ ```powershell
102
+ uv run vr-foraging data-mapper
103
+ ```
104
+
105
+ ## 🔄 Regenerating schemas
106
+
107
+ DSL schemas can be modified in `./src/aind_behavior_vr_foraging/rig.py` (or `(...)/task_logic`.py`).
108
+
109
+ Once modified, changes to the DSL must be propagated to `json-schema` and `csharp` API. This can be done by running:
110
+
111
+ ```powershell
112
+ uv run vr-foraging regenerate
113
+ ```
114
+
115
+ ## 📖 Curricula
116
+
117
+ The VrForaging platform supports a curricula structure that allows for the organization and management of different learning paths and experiences. The implementation relies on the a common definition of "curriculum" progression provided by [`aind-behavior-curriculum`](https://github.com/AllenNeuralDynamics/aind-behavior-curriculum).
118
+
119
+ Curricula are expected to be defined in `src/aind_behavior_vr_foraging/curricula/` by adding individual submodules that follow the structure of [`https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging.Curricula`](https://allenneuraldynamics.github.io/Aind.Behavior.VrForaging.Curricula/). Updates to the curriculum will therefore require, by design, explicitly updating the submodule reference via a reviewed pull request.
@@ -0,0 +1,77 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.8.22"]
3
+ build-backend = "uv_build"
4
+
5
+ [project]
6
+ name = "aind-behavior-vr-foraging"
7
+ description = "A library that defines AIND data schema for the Aind Behavior VR Foraging experiment."
8
+ authors = [ {name = "Bruno Cruz", email = "bruno.cruz@alleninstitute.org"}]
9
+ license = "MIT"
10
+ requires-python = ">=3.11"
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3.11",
13
+ "Operating System :: Microsoft :: Windows",
14
+ ]
15
+ version = "0.6.0"
16
+ readme = {file = "README.md", content-type = "text/markdown"}
17
+
18
+ dependencies = [
19
+ "aind_behavior_services>=0.12, <0.13",
20
+ "pydantic-settings"
21
+ ]
22
+
23
+ [project.urls]
24
+ Documentation = "https://allenneuraldynamics.github.io/Aind.Behavior.VrForaging/"
25
+ Repository = "https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/"
26
+ Issues = "https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/issues"
27
+ Changelog = "https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/releases"
28
+
29
+ [project.optional-dependencies]
30
+
31
+ data = ["contraqctor<0.6.0"]
32
+
33
+ launcher = [
34
+ "aind-clabe[aind-services] >= 0.8.0 ,<0.9.0",
35
+ "aind-data-schema>=2",
36
+ "aind_behavior_vr_foraging[data]",
37
+ ]
38
+
39
+ [dependency-groups]
40
+
41
+ dev = [
42
+ "aind_behavior_vr_foraging[launcher]",
43
+ "aind_behavior_vr_foraging[data]",
44
+ "ruff",
45
+ "codespell"
46
+ ]
47
+
48
+ docs = [
49
+ 'Sphinx',
50
+ 'furo',
51
+ 'sphinx-jinja',
52
+ 'autodoc_pydantic[erdantic]',
53
+ 'myst_parser',
54
+ 'sphinx-jsonschema',
55
+ "aind_behavior_vr_foraging[data]", # Necessary for the data contract rendering
56
+ ]
57
+
58
+ [project.scripts]
59
+ vr-foraging = "aind_behavior_vr_foraging.cli:main"
60
+
61
+ [tool.ruff]
62
+ line-length = 120
63
+ target-version = 'py311'
64
+
65
+ [tool.ruff.lint]
66
+ extend-select = ['Q', 'RUF100', 'C90', 'I']
67
+ extend-ignore = []
68
+ mccabe = { max-complexity = 14 }
69
+ pydocstyle = { convention = 'google' }
70
+
71
+ [tool.codespell]
72
+ skip = '.git,*.pdf,*.svg,./bonsai,*.bonsai,./docs/_build,uv.lock,*Generated.cs'
73
+ ignore-words-list = 'nd'
74
+
75
+ [tool.uv]
76
+ default-groups = ['dev']
77
+ required-version = '>=0.8.4'
@@ -0,0 +1,30 @@
1
+ import re
2
+ from importlib.metadata import PackageNotFoundError, version
3
+
4
+
5
+ def pep440_to_semver(ver: str) -> str:
6
+ """
7
+ Convert a PEP 440 version to a SemVer-compatible string.
8
+
9
+ Examples:
10
+ 1.2.3rc2 -> 1.2.3-rc2
11
+ 1.2.3a1 -> 1.2.3-a1
12
+ 1.2.3b1 -> 1.2.3-b1
13
+ 1.2.3.dev4 -> 1.2.3-dev4
14
+ 1.2.3.post1 -> 1.2.3+post1
15
+ """
16
+ # pre-release: a, b, rc -> -aN, -bN, -rcN
17
+ ver = re.sub(r"(?<=\d)(a|b|rc)(\d+)", r"-\1\2", ver)
18
+ # dev release: .devN -> -devN
19
+ ver = re.sub(r"\.dev(\d+)", r"-dev\1", ver)
20
+ # post release: .postN -> +postN
21
+ ver = re.sub(r"\.post(\d+)", r"+post\1", ver)
22
+ return ver
23
+
24
+
25
+ try:
26
+ __version__ = version(__name__)
27
+ except PackageNotFoundError:
28
+ __version__ = "0.0.0"
29
+
30
+ __semver__ = pep440_to_semver(__version__)
@@ -0,0 +1,48 @@
1
+ import typing as t
2
+
3
+ from pydantic import Field, RootModel
4
+ from pydantic_settings import BaseSettings, CliApp, CliSubCommand
5
+
6
+ from aind_behavior_vr_foraging import __semver__, regenerate
7
+ from aind_behavior_vr_foraging.data_mappers import DataMapperCli
8
+ from aind_behavior_vr_foraging.data_qc import DataQcCli
9
+ from aind_behavior_vr_foraging.launcher import ClabeCli
10
+
11
+
12
+ class VersionCli(RootModel):
13
+ root: t.Any
14
+
15
+ def cli_cmd(self) -> None:
16
+ print(__semver__)
17
+
18
+
19
+ class DslRegenerateCli(RootModel):
20
+ root: t.Any
21
+
22
+ def cli_cmd(self) -> None:
23
+ regenerate.main()
24
+
25
+
26
+ class VrForagingCli(BaseSettings, cli_prog_name="vr-foraging", cli_kebab_case=True):
27
+ data_mapper: CliSubCommand[DataMapperCli] = Field(description="Generate metadata for aind-data-schema.")
28
+ data_qc: CliSubCommand[DataQcCli] = Field(description="Run data quality checks.")
29
+ version: CliSubCommand[VersionCli] = Field(
30
+ description="Print the version of the vr-foraging package.",
31
+ )
32
+ regenerate: CliSubCommand[DslRegenerateCli] = Field(
33
+ description="Regenerate the vr-foraging dsl dependencies.",
34
+ )
35
+ clabe: CliSubCommand[ClabeCli] = Field(
36
+ description="Run the Clabe CLI.",
37
+ )
38
+
39
+ def cli_cmd(self):
40
+ return CliApp().run_subcommand(self)
41
+
42
+
43
+ def main():
44
+ CliApp().run(VrForagingCli)
45
+
46
+
47
+ if __name__ == "__main__":
48
+ main()
@@ -0,0 +1,49 @@
1
+ import os
2
+ import typing as t
3
+ from functools import partial
4
+ from pathlib import Path
5
+
6
+ import contraqctor
7
+ import semver
8
+
9
+ from aind_behavior_vr_foraging import __semver__
10
+
11
+
12
+ def _dataset_lookup_helper(version: str) -> t.Callable[[Path], contraqctor.contract.Dataset]:
13
+ parsed_version = semver.Version.parse(version)
14
+ # Ignore release candidate suffix for version comparison
15
+ parsed_version = semver.Version(parsed_version.major, parsed_version.minor, parsed_version.patch)
16
+ if semver.Version.parse("0.4.0") <= parsed_version < semver.Version.parse("0.5.0"):
17
+ from .v0_4_0 import dataset as _dataset
18
+ elif semver.Version.parse("0.5.0") <= parsed_version < semver.Version.parse("0.6.0"):
19
+ from .v0_5_0 import dataset as _dataset
20
+ elif parsed_version >= semver.Version.parse("0.6.0"):
21
+ from .v0_6_0 import dataset as _dataset
22
+ else:
23
+ raise ValueError(f"Unsupported version: {version}")
24
+ return partial(_dataset, version=version)
25
+
26
+
27
+ def dataset(path: os.PathLike, version: str = __semver__) -> contraqctor.contract.Dataset:
28
+ """
29
+ Loads the dataset for the Aind VR Foraging project from a specified version.
30
+
31
+ Args:
32
+ path (os.PathLike): The path to the dataset root directory.
33
+ version (str): The version of the dataset to load. By default, it uses the package version.
34
+
35
+ Returns:
36
+ contraqctor.contract.Dataset: The loaded dataset.
37
+ """
38
+ dataset_constructor = _dataset_lookup_helper(version)
39
+ return dataset_constructor(Path(path))
40
+
41
+
42
+ def render_dataset(version: str = __semver__) -> str:
43
+ """Renders the dataset as a tree-like structure for visualization."""
44
+ from contraqctor.contract.utils import print_data_stream_tree_html
45
+
46
+ dataset_constructor = _dataset_lookup_helper(version)
47
+ return print_data_stream_tree_html(
48
+ dataset_constructor(Path("<RootPath>")), show_missing_indicator=False, show_type=True
49
+ )