Skip to content

Commit 57fae0b

Browse files
committed
Merge branch 'main' into pop_over
* main: feat(Session): Make Session on_flush() and on_flushed() accept async functions (#693) Make data frame selection return row numbers, not pandas index value (#677) chore(api)!: Rename `ui.navset_pill_card` -> `ui.navset_card_pill` and `ui.navset_tab_card` -> `ui.navset_card_tab` (#681) Consolidate all testing into `tests/` folder (#683) Fix pyright error (#678) Make model score app work on Connect/Shinyapps.io (#657) Suppress type check for read_csv Synchonize input_file examples More realistic file import example (#582) Make flaky dataframe test have larger timeout (#675) Wrap bare value box value in `p` tag (#668)
2 parents 81ea302 + 398738b commit 57fae0b

File tree

103 files changed

+682
-178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+682
-178
lines changed

CHANGELOG.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [UNRELEASED]
1010

11-
### Experimental breaking changes
12-
13-
* `shiny.experimental.ui.sidebar_toggle()` has been renamed to `shiny.experimental.ui.toggle_sidebar()` (#680).
14-
* `shiny.experimental.ui.tooltip_toggle()` has been renamed to `shiny.experimental.ui.toggle_tooltip()` (#680).
15-
* `shiny.experimental.ui.tooltip_update()` has been renamed to `shiny.experimental.ui.update_tooltip()` (#680).
16-
17-
1811
### New features
1912

2013
* Added `shiny.render.renderer_components` decorator to help create new output renderers (#621).
2114
* Added `shiny.experimental.ui.popover()`, `update_popover()`, and `toggle_popover()` for easy creation (and server-side updating) of [Bootstrap popovers](https://getbootstrap.com/docs/5.2/components/popovers/). Popovers are similar to tooltips, but are more persistent, and should primarily be used with button-like UI elements (e.g. `input_action_button()` or icons) (#680).
2215
* Added `shiny.experimental.ui.toggle_switch()` (#680).
2316
* Added CSS classes to UI input methods (#680) .
17+
* `Session` objects can now accept an asynchronous (or synchronous) function for `.on_flush(fn=)`, `.on_flushed(fn=)`, and `.on_ended(fn=)` (#686).
18+
19+
### API changes
20+
21+
* Renamed `shiny.ui.navset_pill_card` to `shiny.ui.navset_card_pill`. `shiny.ui.navset_pill_card` will throw a deprecated warning (#492).
22+
* Renamed `shiny.ui.navset_tab_card` to `shiny.ui.navset_card_tab`. `shiny.ui.navset_tab_card` will throw a deprecated warning (#492).
23+
24+
#### Experimental API changes
25+
26+
* Renamed `shiny.experimental.ui.navset_pill_card` to `shiny.experimental.ui.navset_card_pill` (#492).
27+
* Renamed `shiny.experimental.ui.navset_tab_card` to `shiny.experimental.ui.navset_card_tab` (#492).
28+
* Renamed `shiny.experimental.ui.sidebar_toggle()` to `shiny.experimental.ui.toggle_sidebar()` (#680).
29+
* Renamed `shiny.experimental.ui.tooltip_toggle()` to `shiny.experimental.ui.toggle_tooltip()` (#680).
30+
* Renamed `shiny.experimental.ui.tooltip_update()` to `shiny.experimental.ui.update_tooltip()` (#680).
31+
2432

2533
### Bug fixes
2634

35+
* Fixed #646: Wrap bare value box value in `<p />` tags. (#668)
36+
* Fixed #676: The `render.data_frame` selection feature was underdocumented and buggy (sometimes returning `None` as a row identifier if the pandas data frame's index had gaps in it). With this release, the selection is consistently a tuple of the 0-based row numbers of the selected rows--or `None` if no rows are selected. (#677)
37+
2738
### Other changes
2839

2940

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ check: ## check code quality with black and isort
7777
isort --check-only --diff .
7878

7979
test: ## run tests quickly with the default Python
80-
python3 tests/asyncio_prevent.py
81-
pytest tests
80+
python3 tests/pytest/asyncio_prevent.py
81+
pytest
8282

8383
# Default `FILE` to `e2e` if not specified
84-
FILE:=e2e
84+
FILE:=tests/e2e
8585

8686
e2e: ## end-to-end tests with playwright
8787
playwright install --with-deps

docs/_quartodoc.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ quartodoc:
7777
- ui.nav_spacer
7878
- ui.nav_menu
7979
- ui.navset_tab
80-
- ui.navset_tab_card
80+
- ui.navset_card_tab
8181
- ui.navset_pill
82-
- ui.navset_pill_card
82+
- ui.navset_card_pill
8383
- ui.navset_pill_list
8484
- ui.navset_hidden
8585
- title: UI panels
@@ -247,8 +247,8 @@ quartodoc:
247247
- experimental.ui.layout_sidebar
248248
- experimental.ui.page_navbar
249249
- experimental.ui.navset_bar
250-
- experimental.ui.navset_tab_card
251-
- experimental.ui.navset_pill_card
250+
- experimental.ui.navset_card_tab
251+
- experimental.ui.navset_card_pill
252252
- experimental.ui.toggle_sidebar
253253
- experimental.ui.toggle_switch
254254
- experimental.ui.panel_main

e2e/experimental/value_box/test_valuebox.py

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

examples/event/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
print the number of clicks in the console twice.
1212
"""
1313
),
14-
ui.navset_tab_card(
14+
ui.navset_card_tab(
1515
ui.nav(
1616
"Sync",
1717
ui.input_action_button("btn", "Click me"),

examples/model-score/scoredata.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,16 @@ async def update_db(position):
5555

5656
def begin():
5757
position = init_db()
58-
asyncio.create_task(update_db(position))
58+
59+
# After initializing the database, we need to start a non-blocking task to update it
60+
# every second or so. If an event loop is already running, we can use an asyncio
61+
# task. (This is the case when running via `shiny run` and shinylive.) Otherwise, we
62+
# need to launch a background thread and run an asyncio event loop there. (This is
63+
# the case when running via shinyapps.io or Posit Connect.)
64+
65+
if asyncio.get_event_loop().is_running():
66+
asyncio.create_task(update_db(position))
67+
else:
68+
from threading import Thread
69+
70+
Thread(target=lambda: asyncio.run(update_db(position)), daemon=True).start()

js/dataframe/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,8 @@ interface ShinyDataGridProps<TIndex> {
5858

5959
const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = (props) => {
6060
const { id, data, bgcolor } = props;
61-
const { columns, index, type_hints, data: rowData } = data;
61+
const { columns, type_hints, data: rowData } = data;
6262
const { width, height, filters: withFilters } = data.options;
63-
const keyToIndex: Record<string, unknown> = {};
64-
index.forEach((value) => {
65-
keyToIndex[value + ""] = value;
66-
});
6763

6864
const containerRef = useRef<HTMLDivElement>(null);
6965
const theadRef = useRef<HTMLTableSectionElement>(null);
@@ -192,7 +188,8 @@ const ShinyDataGrid: FC<ShinyDataGridProps<unknown>> = (props) => {
192188
rowSelection
193189
.keys()
194190
.toList()
195-
.map((key) => keyToIndex[key])
191+
.map((key) => parseInt(key))
192+
.sort()
196193
);
197194
}
198195
}

js/dataframe/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface DataGridOptions {
2020

2121
export interface PandasData<TIndex> {
2222
columns: ReadonlyArray<string>;
23-
index: ReadonlyArray<TIndex>;
23+
// index: ReadonlyArray<TIndex>;
2424
data: unknown[][];
2525
type_hints?: ReadonlyArray<TypeHint>;
2626
options: DataGridOptions;

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[pytest]
22
asyncio_mode=strict
3-
testpaths=tests
3+
testpaths=tests/pytest/
44
addopts = --strict-markers --durations=6 --durations-min=5.0 --browser webkit --browser firefox --browser chromium --numprocesses auto
55
markers =
66
examples: Suite of tests to validate that examples do not produce errors (deselect with '-m "not examples"')

shiny/api-examples/data_frame/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ def summary_data():
6363

6464
@reactive.Calc
6565
def filtered_df():
66+
# input.summary_data_selected_rows() is a tuple, so we must convert it to list,
67+
# as that's what Pandas requires for indexing.
6668
selected_idx = list(req(input.summary_data_selected_rows()))
67-
countries = summary_df["country"][selected_idx]
69+
countries = summary_df.iloc[selected_idx]["country"]
6870
# Filter data for selected countries
6971
return df[df["country"].isin(countries)]
7072

0 commit comments

Comments
 (0)