Skip to content

Commit df8d984

Browse files
authored
Merge pull request #6 from CognitiveVR/add-documentation
Add documentation
2 parents 7374722 + ccf9cf3 commit df8d984

5 files changed

Lines changed: 1328 additions & 654 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ jobs:
2424
- name: Lint with ruff
2525
run: uv run ruff check src/ tests/
2626

27+
- name: Checkout slicer fields
28+
uses: actions/checkout@v4
29+
with:
30+
repository: CognitiveVR/cvr-slicer
31+
path: ../cvr-slicer
32+
sparse-checkout: doc/slicer_fields.yaml
33+
continue-on-error: true
34+
2735
- name: Validate schema freshness
2836
run: |
2937
if [ -f "../cvr-slicer/doc/slicer_fields.yaml" ] || [ -f "../cvr-cortex/doc/slicer_fields.yaml" ]; then

CLAUDE.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# CLAUDE.md — cognitive3dpy contributor guide
2+
3+
## Dev environment
4+
5+
The project uses `uv`. To set up:
6+
7+
```bash
8+
uv sync --all-extras
9+
```
10+
11+
This installs the package, all dev dependencies, and the optional pandas extra.
12+
13+
## Running tests
14+
15+
```bash
16+
uv run pytest tests/ -q # all tests
17+
uv run pytest tests/test_transform.py -q # single file
18+
```
19+
20+
Tests use `respx` to mock HTTP calls — no real API credentials needed.
21+
22+
## Architecture
23+
24+
All data flows through a shared pipeline in `_transform.py`:
25+
26+
```
27+
API JSON → pl.DataFrame → normalize_columns() → coerce_types() → [join_scene_names()] → [select_compact()] → to_output()
28+
```
29+
30+
- `_transform.py` — all DataFrame transformation logic; the first place to look for type/schema issues
31+
- `_client.py` — HTTP client, auth headers, error handling
32+
- `_pagination.py` — session list pagination
33+
- `_lookups.py` — metadata resolution (scenes, objects, objectives); results are cached by project_id
34+
- `_filters.py` — builds the session filter payload sent to the API
35+
- Each public function lives in its own module (`sessions.py`, `events.py`, etc.)
36+
37+
## Key conventions
38+
39+
- **Polars internally, pandas only at the boundary** — all processing uses `polars.DataFrame`; `to_output()` is the only place pandas conversion happens
40+
- **Column naming**`normalize_columns()` converts everything to `snake_case`; `c3d.*` API properties become `c3d_*` (e.g. `c3d.metrics.fps_score``c3d_metrics_fps_score`)
41+
- **Numeric metric columns are always Float64**`coerce_types()` casts all `c3d_metrics_*`, `c3d_metric_components_*`, and `c3d_roomsize_meters` columns to `pl.Float64`, even when the API returns whole numbers as integers
42+
- **Empty DataFrames have explicit schemas** — functions return typed empty frames (not schema-less) when no data is found
43+
- **Date inputs** — all public functions accept `date`/`datetime` objects, epoch timestamps (int/float seconds), or `"YYYY-MM-DD"` strings
44+
45+
## Release process
46+
47+
Releases are fully automated via `python-semantic-release` on push to `main`. Use conventional commits:
48+
49+
- `fix:` → patch bump
50+
- `feat:` → minor bump
51+
- `feat!:` or `BREAKING CHANGE:` footer → major bump
52+
- `chore:` / `docs:` → no release
53+
54+
The CI workflow (`release.yml`) determines the next version, creates a git tag, builds with `uv`, and publishes to PyPI automatically. Do not manually edit the version in `pyproject.toml`.

README.html

Lines changed: 0 additions & 654 deletions
This file was deleted.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,14 @@ All data-fetching functions support these session filters:
186186
- `project_id` — override the default set by `c3d_project()`
187187
- `output``"polars"` (default) or `"pandas"`
188188
- `warn_empty` — emit a `UserWarning` when 0 rows are returned (default `True`); set to `False` to suppress
189+
190+
## Contributing
191+
192+
```bash
193+
git clone https://github.com/CognitiveVR/cognitive3dpy.git
194+
cd cognitive3dpy
195+
uv sync --all-extras # installs package + dev + pandas dependencies
196+
uv run pytest tests/ # run tests
197+
```
198+
199+
Releases are automated via [python-semantic-release](https://python-semantic-release.readthedocs.io/) on push to `main`. Use [conventional commits](https://www.conventionalcommits.org/) (`fix:`, `feat:`, `feat!:`) to trigger a release.

0 commit comments

Comments
 (0)