Skip to content

Commit 7ad3a68

Browse files
committed
Merge branch 'main' into chat-append-incremental
2 parents e8d1e2c + d0354b9 commit 7ad3a68

File tree

36 files changed

+1248
-283
lines changed

36 files changed

+1248
-283
lines changed

.github/workflows/pytest.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,19 @@ jobs:
242242
name: "playright-examples-${{ runner.os }}-${{ matrix.python-version }}-results"
243243
path: test-results/
244244
retention-days: 5
245+
246+
test-narwhals-integration:
247+
runs-on: ubuntu-latest
248+
steps:
249+
- uses: actions/checkout@v4
250+
with:
251+
fetch-depth: 0
252+
- name: Setup py-shiny
253+
id: install
254+
uses: ./.github/py-shiny/setup
255+
- name: Run test commands
256+
env:
257+
UV_SYSTEM_PYTHON: 1
258+
run: |
259+
make narwhals-install-shiny
260+
make narwhals-test-integration

CHANGELOG.md

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

1818
### New features
1919

20-
* Added [narwhals](https://posit-dev.github.io/py-narwhals) support for `@render.data_frame`. This allows for any eager data frame supported by narwhals to be returned from a `@render.data_frame` output method. All internal methods and helper methods leverage the `narwhals` API to be data frame agnostic. (#1570)
20+
* New features for `@render.data_frame`:
21+
22+
* Added [narwhals](https://posit-dev.github.io/py-narwhals) support for `@render.data_frame`. This allows for any eager data frame supported by narwhals to be returned from a `@render.data_frame` output method. All internal methods and helper methods now leverage the `narwhals` API to be data frame agnostic. (#1570)
23+
24+
* Added `.data_patched()` reactive calculation that applies all `.cell_patches()` to `.data()`. (#1719)
25+
26+
* Added `.update_cell_value()` method to programmatically update the contents of a data frame cell. (#1719)
27+
28+
* Added `.update_data()` method to update the rendered data without resetting any user sort or filter. Note, all user edits will be forgotten. (#1719)
29+
30+
* Added [narwhals](https://posit-dev.github.io/py-narwhals) support for `@render.table`. This allows for any eager data frame supported by narwhals to be returned from a `@render.table` output method. (#1570)
31+
32+
* `chat_ui()` and `Chat.ui()` gain a `messages` parameter for providing starting messages. (#1736)
2133

2234
### Other changes
2335

@@ -41,8 +53,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4153

4254
* Added `.expect_class()` and `.expect_multiple()` for `Accordion` in `shiny.playwright.controllers` (#1710)
4355

44-
* Added [narwhals](https://posit-dev.github.io/py-narwhals) support for `@render.table`. This allows for any eager data frame supported by narwhals to be returned from a `@render.table` output method. (#1570)
45-
4656
### Bug fixes
4757

4858
* A few fixes for `ui.Chat()`, including:
@@ -52,7 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5262

5363
* `shiny create` now uses the template `id` rather than the directory name as the default directory. (#1666)
5464

55-
* `ui.Theme()` now works correctly on Windows when the theme requires Sass compilation. (thanks @yuuuxt, #1684)
65+
* `ui.Theme()` now works correctly on Windows when the theme requires Sass compilation. (Thanks, @yuuuxt!) (#1684)
5666

5767
* Fixed multiple input controllers (`InputSlider`, `InputDate`, `InputDateRange`, `InputCheckbox`, and `InputCheckboxGroup`) in `shiny.playwright.controller` to check the `width` property within the `style` attribute. (#1691, #1696, #1702)
5868

@@ -66,6 +76,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6676

6777
* Fixed bug in `@render.data_frame` where `bool` or `object` columns were not being rendered. (#1570)
6878

79+
* Fixed output controller `OutputDataFrame` in `shiny.playwright.controller` to correctly assert the number of rows in `.expect_nrow()` as the total number of virtual rows, not the number of currently displaying rows. (#1719)
80+
81+
* Fixed issue where `@render.download` did not respect the module namespacing. (Thanks, @nsiicm0) (#1732)
6982

7083
## [1.1.0] - 2024-09-03
7184

@@ -89,7 +102,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
89102
* A few fixes for `ui.Chat()`, including:
90103
* A fix for use inside Shiny modules. (#1582)
91104
* `.messages(format="google")` now returns the correct role. (#1622)
92-
* `ui.Chat(messages)` are no longer dropped when dynamically rendered. (#1593)
93105
* `transform_assistant_response` can now return `None` and correctly handles change of content on the last chunk. (#1641)
94106

95107
* An empty `ui.input_date()` value no longer crashes Shiny. (#1528)

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ SUB_FILE:=
150150
PYTEST_BROWSERS:= --browser webkit --browser firefox --browser chromium
151151
PYTEST_DEPLOYS_BROWSERS:= --browser chromium
152152

153+
153154
# Full test path to playwright tests
154155
TEST_FILE:=tests/playwright/$(SUB_FILE)
155156
# Default `make` values that shouldn't be directly used; (Use `TEST_FILE` instead!)
@@ -247,3 +248,12 @@ upgrade-html-deps: FORCE ## Upgrade Shiny's HTMLDependencies
247248
exit 1; \
248249
fi
249250
@scripts/htmlDependencies.R
251+
252+
narwhals-install-shiny: FORCE
253+
@echo "-------- Install py-shiny ----------"
254+
$(MAKE) ci-install-deps
255+
narwhals-test-integration: FORCE
256+
@echo "-------- Running py-shiny format, lint, typing, and unit tests ----------"
257+
$(MAKE) check
258+
@echo "-------- Running py-shiny playwright tests ----------"
259+
$(MAKE) playwright TEST_FILE="tests/playwright/shiny/components/data_frame" PYTEST_BROWSERS="--browser chromium"

docs/_quartodoc-core.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ quartodoc:
99
renderer:
1010
style: _renderer.py
1111
show_signature_annotations: false
12+
table_style: description-list
1213
sections:
1314
- title: Page containers
1415
desc: Create a user interface page container.
@@ -357,3 +358,4 @@ quartodoc:
357358
contents:
358359
- name: experimental.ui.card_image
359360
dynamic: false
361+

docs/_quartodoc-express.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ quartodoc:
99
renderer:
1010
style: _renderer.py
1111
show_signature_annotations: false
12+
table_style: description-list
1213
sections:
1314
- title: Input components
1415
desc: Gather user input.

docs/_renderer.py

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from griffe import (
1313
Alias,
1414
DocstringAttribute,
15-
DocstringParameter,
16-
DocstringSectionParameters,
1715
DocstringSectionText,
1816
Expr,
1917
ExprName,
@@ -22,8 +20,8 @@
2220
)
2321
from plum import dispatch
2422
from quartodoc import MdRenderer
25-
from quartodoc.pandoc.blocks import DefinitionList
2623
from quartodoc.renderers.base import convert_rst_link_to_md, sanitize
24+
from quartodoc.renderers.md_renderer import ParamRow
2725

2826
# from quartodoc.ast import preview
2927

@@ -101,12 +99,12 @@ def render_annotation(self, el: str):
10199
# TODO-future; Can be removed once we use quartodoc 0.3.5
102100
# Related: https://github.com/machow/quartodoc/pull/205
103101
@dispatch
104-
def render(self, el: DocstringAttribute):
105-
row = [
106-
sanitize(el.name),
107-
self.render_annotation(el.annotation),
108-
sanitize(el.description or "", allow_markdown=True),
109-
]
102+
def render(self, el: DocstringAttribute) -> ParamRow:
103+
row = ParamRow(
104+
el.name,
105+
el.description or "",
106+
annotation=self.render_annotation(el.annotation),
107+
)
110108
return row
111109

112110
@dispatch
@@ -170,28 +168,6 @@ def summarize(self, obj: Union[Object, Alias]) -> str:
170168

171169
return ""
172170

173-
# Consolidate the parameter type info into a single column
174-
@dispatch
175-
def render(self, el: DocstringParameter):
176-
param = f'<span class="parameter-name">{el.name}</span>'
177-
annotation = self.render_annotation(el.annotation)
178-
if annotation:
179-
param = f'{param}<span class="parameter-annotation-sep">:</span> <span class="parameter-annotation">{annotation}</span>'
180-
if el.default:
181-
param = f'{param} <span class="parameter-default-sep">=</span> <span class="parameter-default">{el.default}</span>'
182-
183-
# Wrap everything in a code block to allow for links
184-
param = "<code>" + param + "</code>"
185-
186-
return (param, el.description)
187-
188-
@dispatch
189-
def render(self, el: DocstringSectionParameters):
190-
rows = list(map(self.render, el.value))
191-
# rows is a list of tuples of (<parameter>, <description>)
192-
193-
return str(DefinitionList(rows))
194-
195171
@dispatch
196172
def signature(self, el: Function, source: Optional[Alias] = None):
197173
if el.name == "__call__":
@@ -279,7 +255,7 @@ def read_file(file: str | Path, root_dir: str | Path | None = None) -> FileConte
279255

280256

281257
def check_if_missing_expected_example(el, converted):
282-
if re.search(r"(^|\n)#{2,6} Examples\n", converted):
258+
if re.search(r"(^|\n)#{2,6} Examples", converted):
283259
# Manually added examples are fine
284260
return
285261

examples/penguins/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
def server(input: Inputs, output: Outputs, session: Session):
5656
@reactive.calc
5757
def filtered_df() -> pd.DataFrame:
58-
"""Returns a Pandas data frame that includes only the desired rows"""
58+
"""Returns a pandas data frame that includes only the desired rows"""
5959

6060
# This calculation "req"uires that at least one species is selected
6161
req(len(input.species()) > 0)

examples/static_plots/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
ui.input_slider("cov", "Co-variance", min=0, max=1, value=0.4),
3737
),
3838
),
39-
ui.nav_panel("Pandas", ui.output_plot("pandas")),
39+
ui.nav_panel("pandas", ui.output_plot("pandas")),
4040
ui.nav_panel("Holoviews", ui.output_plot("holoviews", height="600px")),
4141
ui.nav_panel("xarray", ui.output_plot("xarray")),
4242
ui.nav_panel("geopandas", ui.output_plot("geopandas")),

js/chat/chat.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,7 @@ class ChatContainer extends LightElement {
314314
private resizeObserver!: ResizeObserver;
315315

316316
render(): ReturnType<LitElement["render"]> {
317-
const input_id = this.id + "_user_input";
318-
return html`
319-
<shiny-chat-messages></shiny-chat-messages>
320-
<shiny-chat-input
321-
id=${input_id}
322-
placeholder=${this.placeholder}
323-
></shiny-chat-input>
324-
`;
317+
return html``;
325318
}
326319

327320
firstUpdated(): void {

js/data-frame/cell-edit-map.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export const useCellEditMap = () => {
4848
cellEditMap,
4949
// setCellEditMap,
5050
setCellEditMapAtLoc,
51+
resetCellEditMap: () => {
52+
setCellEditMap(new Map<string, CellEdit>());
53+
},
5154
} as const;
5255
};
5356

0 commit comments

Comments
 (0)