Skip to content

Commit 31c4571

Browse files
committed
Merge branch 'main' into data_view_meta
* main: test(data frame): Verify that data frame's outputs are reset before moving forward (#1383) Send busy/idle at the right times (#1380) feat(data frame): Restore `input.<ID>_selected_rows()`. Rename `input.<ID>_data_view_indices` to `input.<ID>_data_view_rows` (#1377)
2 parents 43a5168 + 8983b34 commit 31c4571

File tree

11 files changed

+63
-21
lines changed

11 files changed

+63
-21
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [UNRELEASED]
99

10-
### Breaking Changes
10+
### `input` key changes
11+
12+
* Restored `@render.data_frame`'s (prematurely removed in v0.9.0) input value `input.<ID>_selected_rows()`. Please use `<ID>.input_cell_selection()["rows"]` and consider `input.<ID>_selected_rows()` deprecated. (#1345, #1377)
13+
14+
* `@render.data_frame`'s input value `input.<ID>_data_view_indices` has been renamed to `input.<ID>_data_view_rows` for consistent naming. Please use `input.<ID>_data_view_rows` and consider `input.<ID>_data_view_indices` deprecated. (#1377)
1115

1216
* `@render.data_frame`'s input value `input.<ID>_data_view_indices` has been renamed to `input.<ID>_data_view_rows` for consistent naming. Please use `input.<ID>_data_view_rows` and consider `input.<ID>_data_view_indices` deprecated. (#1374)
1317

@@ -27,7 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2731

2832
* Fixed an issue that prevented Shiny from serving the `font.css` file referenced in Shiny's Bootstrap CSS file. (#1342)
2933

30-
* Removed temporary state where a data frame renderer would try to subset to selected rows that did not exist. (#1351)
34+
* Removed temporary state where a data frame renderer would try to subset to selected rows that did not exist. (#1351, #1377)
3135

3236
### Other changes
3337

js/data-frame/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = ({
346346
}, [id, columnFilters]);
347347
useEffect(() => {
348348
if (!id) return;
349+
349350
// Already prefiltered rows!
350351
const shinyValue: RowModel<unknown[]> = table.getSortedRowModel();
351352

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ test =
9393
folium
9494
palmerpenguins
9595
faicons
96+
ridgeplot
9697
dev =
9798
black>=24.0
9899
flake8>=6.0.0

shiny/express/_stub_session.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ async def _send_message(self, message: dict[str, object]) -> None:
119119
def _send_message_sync(self, message: dict[str, object]) -> None:
120120
return
121121

122+
def _increment_busy_count(self) -> None:
123+
return
124+
125+
def _decrement_busy_count(self) -> None:
126+
return
127+
122128
def on_flush(
123129
self,
124130
fn: Callable[[], None] | Callable[[], Awaitable[None]],

shiny/reactive/_reactives.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def on_invalidate_cb() -> None:
547547
def _continue() -> None:
548548
ctx.add_pending_flush(self._priority)
549549
if self._session:
550-
self._session._send_message_sync({"busy": "busy"})
550+
self._session._increment_busy_count()
551551

552552
if self._suspended:
553553
self._on_resume = _continue
@@ -558,7 +558,7 @@ async def on_flush_cb() -> None:
558558
if not self._destroyed:
559559
await self._run()
560560
if self._session:
561-
self._session._send_message_sync({"busy": "idle"})
561+
self._session._decrement_busy_count()
562562

563563
ctx.on_invalidate(on_invalidate_cb)
564564
ctx.on_flush(on_flush_cb)

shiny/session/_session.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,12 @@ def set_message_handler(
471471
namespaced when used with a session proxy.
472472
"""
473473

474+
@abstractmethod
475+
def _increment_busy_count(self) -> None: ...
476+
477+
@abstractmethod
478+
def _decrement_busy_count(self) -> None: ...
479+
474480

475481
# ======================================================================================
476482
# AppSession
@@ -493,6 +499,7 @@ def __init__(
493499
self.id: str = id
494500
self._conn: Connection = conn
495501
self._debug: bool = debug
502+
self._busy_count: int = 0
496503
self._message_handlers: dict[
497504
str,
498505
tuple[Callable[..., Awaitable[Jsonifiable]], Session],
@@ -785,11 +792,11 @@ async def uploadEnd(job_id: str, input_id: str) -> None:
785792
async def _handle_request(
786793
self, request: Request, action: str, subpath: Optional[str]
787794
) -> ASGIApp:
788-
self._send_message_sync({"busy": "busy"})
795+
self._increment_busy_count()
789796
try:
790797
return await self._handle_request_impl(request, action, subpath)
791798
finally:
792-
self._send_message_sync({"busy": "idle"})
799+
self._decrement_busy_count()
793800

794801
async def _handle_request_impl(
795802
self, request: Request, action: str, subpath: Optional[str]
@@ -1011,6 +1018,16 @@ async def _flush(self) -> None:
10111018
with session_context(self):
10121019
await self._flushed_callbacks.invoke()
10131020

1021+
def _increment_busy_count(self) -> None:
1022+
self._busy_count += 1
1023+
if self._busy_count == 1:
1024+
self._send_message_sync({"busy": "busy"})
1025+
1026+
def _decrement_busy_count(self) -> None:
1027+
self._busy_count -= 1
1028+
if self._busy_count == 0:
1029+
self._send_message_sync({"busy": "idle"})
1030+
10141031
# ==========================================================================
10151032
# On session ended
10161033
# ==========================================================================
@@ -1191,6 +1208,12 @@ def _send_progress(self, type: str, message: object) -> None:
11911208
async def send_custom_message(self, type: str, message: dict[str, object]) -> None:
11921209
await self._parent.send_custom_message(type, message)
11931210

1211+
def _increment_busy_count(self) -> None:
1212+
self._parent._increment_busy_count()
1213+
1214+
def _decrement_busy_count(self) -> None:
1215+
self._parent._decrement_busy_count()
1216+
11941217
def set_message_handler(
11951218
self,
11961219
name: str,

shiny/www/shared/py-shiny/data-frame/data-frame.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/playwright/examples/example_apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_apps(path: str) -> typing.List[str]:
3333
return app_paths
3434

3535

36-
app_idle_wait = {"duration": 300, "timeout": 5 * 1000}
36+
app_idle_wait = {"duration": 300, "timeout": 30 * 1000}
3737
app_hard_wait: typing.Dict[str, int] = {
3838
"examples/brownian": 250,
3939
"examples/ui-func": 250,

tests/playwright/shiny/components/data_frame/edit/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ def summary_data():
8888
def _():
8989
print(
9090
"Filters:",
91-
summary_data.input_column_filter(), # pyright: ignore[reportUnknownArgumentType,reportAttributeAccessIssue]
91+
summary_data.input_column_filter(),
9292
)
9393

9494
@reactive.effect
9595
def _():
9696
print(
9797
"Sorting:",
98-
summary_data.input_column_sort(), # pyright: ignore[reportUnknownArgumentType,reportAttributeAccessIssue]
98+
summary_data.input_column_sort(),
9999
)
100100

101101
@reactive.effect

tests/playwright/shiny/components/data_frame/html_columns_df/df_organization/test_df_organization.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ def test_dataframe_organization_methods(page: Page, local_app: ShinyAppProc) ->
1212
input_cell_selection = OutputCode(page, "cell_selection")
1313
reset_df = InputActionButton(page, "reset_df")
1414

15+
def reset_data_frame():
16+
reset_df.click()
17+
input_view_rows.expect_value("(0, 1, 2)")
18+
input_view_selected_true.expect_value("[]")
19+
input_view_selected_false.expect_value("[ 0 50 100]")
20+
input_cell_selection.expect_value("()")
21+
1522
# assert value of unsorted table
16-
input_view_rows.expect_value("(0, 1, 2)")
17-
input_view_selected_true.expect_value("[]")
18-
input_view_selected_false.expect_value("[ 0 50 100]")
19-
input_cell_selection.expect_value("()")
23+
reset_data_frame()
2024

2125
# sort column by number descending
2226
data_frame.set_column_sort(col=0)
@@ -46,8 +50,7 @@ def test_dataframe_organization_methods(page: Page, local_app: ShinyAppProc) ->
4650
input_view_selected_false.expect_value("[100 50 0]")
4751
input_cell_selection.expect_value("()")
4852

49-
# reset dataframe
50-
reset_df.click()
53+
reset_data_frame()
5154

5255
# filter using numbers
5356
data_frame.set_column_filter(col=0, text=["6", "7"])
@@ -56,8 +59,7 @@ def test_dataframe_organization_methods(page: Page, local_app: ShinyAppProc) ->
5659
input_view_selected_false.expect_value("[ 50 100]")
5760
input_cell_selection.expect_value("()")
5861

59-
# reset dataframe
60-
reset_df.click()
62+
reset_data_frame()
6163

6264
# select multiple rows
6365
data_frame.select_rows([0, 2])
@@ -66,8 +68,7 @@ def test_dataframe_organization_methods(page: Page, local_app: ShinyAppProc) ->
6668
input_view_selected_false.expect_value("[ 0 50 100]")
6769
input_cell_selection.expect_value("(0, 2)")
6870

69-
# reset dataframe
70-
reset_df.click()
71+
reset_data_frame()
7172

7273
# select single row
7374
data_frame.select_rows([0])

tests/pytest/test_poll.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ def on_ended(self, fn: Callable[[], None]) -> Callable[[], None]:
3939
def _send_message_sync(self, message: Dict[str, object]) -> None:
4040
pass
4141

42+
def _increment_busy_count(self) -> None:
43+
pass
44+
45+
def _decrement_busy_count(self) -> None:
46+
pass
47+
4248
async def __aenter__(self):
4349
self._session_context.__enter__()
4450

0 commit comments

Comments
 (0)