Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ npx wait-on http://127.0.0.1:8000/docs/ # backend must also be running (pip in
npm run test:e2e # runs mocha against src/tests/*.spec.ts
```
Run a single e2e spec: `mocha -r ts-node/register src/tests/plot-ui.spec.ts`.

Reactivity benchmark (opt-in, not part of `test:e2e` — its glob is not recursive):
```bash
npm run start:e2e & # same app instance as the e2e suite
npm run test:perf # src/tests/perf/*.perf.spec.ts
```
It builds a canvas with a 2D `equilibrium/time_slice/profiles_2d/psi` heatmap
plus 1D traces and asserts on *counts* (backend requests, Plotly redraws), never
on wall-clock times. The renderer-side counters live in
`src/renderer/utils/perf.ts` and are installed only when `E2E_TEST=true`;
`src/tests/perf/BASELINE.md` records the measured numbers.

On a headless machine wrap the run in `xvfb-run --auto-servernum` as CI does.

`E2E_TEST=true` changes app behaviour in two places: `src/preload.ts` swaps the
Expand Down
12 changes: 12 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ npx wait-on http://127.0.0.1:8000/docs/ # backend must also be running (pip in
npm run test:e2e # runs mocha against src/tests/*.spec.ts
```
Run a single e2e spec: `mocha -r ts-node/register src/tests/plot-ui.spec.ts`.

Reactivity benchmark (opt-in, not part of `test:e2e` — its glob is not recursive):
```bash
npm run start:e2e & # same app instance as the e2e suite
npm run test:perf # src/tests/perf/*.perf.spec.ts
```
It builds a canvas with a 2D `equilibrium/time_slice/profiles_2d/psi` heatmap
plus 1D traces and asserts on *counts* (backend requests, Plotly redraws), never
on wall-clock times. The renderer-side counters live in
`src/renderer/utils/perf.ts` and are installed only when `E2E_TEST=true`;
`src/tests/perf/BASELINE.md` records the measured numbers.

On a headless machine wrap the run in `xvfb-run --auto-servernum` as CI does.

`E2E_TEST=true` changes app behaviour in two places: `src/preload.ts` swaps the
Expand Down
2 changes: 1 addition & 1 deletion backend/ibex/data_source/imas_python_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _jsonify_metadata(self, metadata: IDSMetadata, recursive: bool = False, show
result["is_geometry_node"] = self._is_geometry_node(metadata)

if recursive:
result["children"] = [self._jsonify_metadata(child, recursive) for child in metadata]
result["children"] = [self._jsonify_metadata(child, recursive, show_error_bars) for child in metadata]
else:
result["children"] = [
{
Expand Down
2 changes: 1 addition & 1 deletion backend/ibex/endpoints/ids_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def node_info(uri: str, show_error_bars: bool = False) -> dict:
:return: JSON response

"""
return ibex_service.get_node_info(uri.strip(), show_error_bars)
return ibex_service.get_node_info(uri.strip(), show_error_bars=show_error_bars)


@router.get(
Expand Down
45 changes: 45 additions & 0 deletions backend/tests/test_ids_info_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from packaging.version import Version
from pytest_unordered import unordered

from ibex.endpoints import ids_info


def test_node_info_coordinates(entry_path):
test_dict = {
Expand Down Expand Up @@ -247,3 +249,46 @@ def test_show_error_bars_option(entry_path):
assert "r0_error_upper" in [child["name"] for child in response.json()["children"]], (
"Error bars filtering failed. 'r0_error_upper' nodes was not returned, but it should be."
)


def test_node_info_never_requests_the_recursive_tree(entry_path, monkeypatch):
"""`show_error_bars` used to be passed positionally into `get_node_info`, whose second
parameter is `recursive`. Switching the option on therefore built the metadata of the whole
subtree - which the response model then discarded - and never applied the error bar filter.
The response looks the same either way, so guard the delegation itself.
"""
calls = []

def spy(uri, recursive=False, show_error_bars=False):
calls.append({"uri": uri, "recursive": recursive, "show_error_bars": show_error_bars})
return {
"name": "vacuum_toroidal_field",
"type": "structure",
"ndim": 0,
"shape": [],
"is_geometry_node": False,
"children": [],
"coordinates": [],
}

monkeypatch.setattr(ids_info.ibex_service, "get_node_info", spy)

for show_error_bars in (True, False):
parameters = {
"uri": f"imas:hdf5?path={entry_path}#core_profiles/vacuum_toroidal_field",
"show_error_bars": show_error_bars,
}
assert pytest.test_client.get("/ids_info/node_info", params=parameters).status_code == 200

assert calls == [
{
"uri": f"imas:hdf5?path={entry_path}#core_profiles/vacuum_toroidal_field",
"recursive": False,
"show_error_bars": True,
},
{
"uri": f"imas:hdf5?path={entry_path}#core_profiles/vacuum_toroidal_field",
"recursive": False,
"show_error_bars": False,
},
]
3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"format": "prettier --write .",
"debug": "DEBUG=electron-forge:* electron-forge start",
"start:e2e": "cross-env E2E_TEST=true electron-forge start -- --remote-debugging-port=9222 --no-watch",
"test:e2e": "mocha -r ts-node/register src/tests/*.spec.ts"
"test:e2e": "mocha -r ts-node/register src/tests/*.spec.ts",
"test:perf": "mocha -r ts-node/register src/tests/perf/*.perf.spec.ts"
},
"devDependencies": {
"@electron-forge/cli": "7.11.2",
Expand Down
Loading
Loading