Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(render.data_frame): Add more methods to render.data_frame() #1135

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e0d3666
Add clearRows method for dataframe
Feb 13, 2024
9d2224c
Add multiple selection.
Feb 14, 2024
0d44d4c
Tests
Feb 14, 2024
ba29703
Attach listeners to element
Feb 14, 2024
ad3afc9
Merge remote-tracking branch 'origin/main' into update_row_selection
Feb 15, 2024
3a959d6
Raise errors on python side for row_selection_mode
Feb 15, 2024
9823f92
Merge branch 'main' into update_row_selection
schloerke Feb 16, 2024
93a1bd0
Add testing app
Feb 16, 2024
05fa582
Merge branch 'update_row_selection' of https://github.com/rstudio/py-…
Feb 16, 2024
560ba53
Update _dataframe.py
schloerke Feb 16, 2024
62fd554
Update `render.data_frame.input_selected_rows()` return type and docs
schloerke Feb 16, 2024
034961b
Move test
schloerke Feb 20, 2024
f1f71c0
Add dataframe test for row selection
schloerke Feb 20, 2024
dae65cb
lints
schloerke Feb 20, 2024
d0a4307
Update Makefile
schloerke Feb 20, 2024
f398147
Add render.dataframe.{data, input_selected_rows, data_selected_rows}(…
schloerke Feb 20, 2024
e8058b4
Update Makefile
schloerke Feb 20, 2024
7ab3763
cleanup
schloerke Feb 20, 2024
04592db
Merge branch 'main' into update_row_selection
schloerke Feb 20, 2024
5644259
Build js
schloerke Feb 20, 2024
8f8b437
Add `palmerpenguins` for testing
schloerke Feb 20, 2024
c0c3c01
Merge branch 'main' into update_row_selection
schloerke Feb 20, 2024
2dfc272
Merge branch 'main' into update_row_selection
schloerke Feb 21, 2024
91f6cf8
Allow for `minify` to be set from process args
schloerke Feb 22, 2024
eba2680
Remove title from matplotlib typings
schloerke Feb 22, 2024
6de0f9c
Add extra exception for missing handlers
schloerke Feb 22, 2024
e09a48f
First pass at data_patched and on cell update
schloerke Feb 22, 2024
01c54f0
Round trip POC with editable data cells in table
schloerke Feb 22, 2024
ea20817
lints
schloerke Feb 22, 2024
6817dd0
Add `eslint-plugin-react-hooks`
schloerke Feb 26, 2024
f2c380b
Reorganize edit info to be parallel with data info
schloerke Feb 26, 2024
b39abf9
Use array when updating data. Add tab support. Prevent enter/tab defa…
schloerke Feb 26, 2024
e24eaf9
api!: Consolidate Outputs internal maps into a single map. Add `outpu…
schloerke Feb 26, 2024
d1c7055
Update _mock_session.py
schloerke Feb 26, 2024
3b4e864
compile
schloerke Feb 26, 2024
8bdfbce
Use reactive calcs to resolve derived properties of `value`. E.g. `da…
schloerke Feb 26, 2024
41fb078
Update apps
schloerke Feb 26, 2024
8d3e73a
Resolve feedback; wording
schloerke Feb 27, 2024
b7a0a82
Merge branch 'main' into update_row_selection
schloerke Feb 27, 2024
01cf0dd
lints
schloerke Feb 27, 2024
ddf9725
Remove some make help entries. Add js entries to build assets
schloerke Feb 27, 2024
9b196e0
Use `FORCE` instead of wild card `.PHONY`
schloerke Feb 27, 2024
9aacebd
lints
schloerke Feb 27, 2024
77b37cb
Fix test
schloerke Feb 27, 2024
6a4c13f
Only go into editing mode if editable is true
schloerke Feb 27, 2024
2e90631
Add future TODO
schloerke Feb 27, 2024
2ddaa58
Update app.py
schloerke Feb 27, 2024
fe985a7
Remove duplicate patches
schloerke Feb 27, 2024
14e07dd
api!: Update `session._send_error_message()` to be async and handle t…
schloerke Feb 29, 2024
0313c6a
Use `mode` instead of `row_selection_mode`
schloerke Feb 29, 2024
7ac9c7c
JS updates
schloerke Feb 29, 2024
70af535
compile
schloerke Feb 29, 2024
ea6173c
Give the written value until a response from the server comes back
schloerke Mar 1, 2024
f546e38
Save a success border on edit success. Fade out after 3s over 3s; Use…
schloerke Mar 1, 2024
f453654
Move Jsonifiable to `shiny.types`
schloerke Mar 1, 2024
83a7dae
Use `Jsonifiable` in message handlers
schloerke Mar 1, 2024
bceaf85
Use column indexes, not column ids
schloerke Mar 1, 2024
8b87e09
Move outputRPC to be defined within `Outputs` class; Create a session…
schloerke Mar 3, 2024
096c31b
Code feedback from joe/winston;
schloerke Mar 3, 2024
f3c6eef
compile js
schloerke Mar 3, 2024
0de93ad
Merge branch 'main' into update_row_selection
schloerke Mar 6, 2024
9f7642d
Post merge reverting the revert back to expected behavior
schloerke Mar 6, 2024
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
14 changes: 7 additions & 7 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ jobs:
- name: Run unit tests
if: steps.install.outcome == 'success' && (success() || failure())
run: |
make test
make check-tests

- name: Type check with pyright
- name: Type check
if: steps.install.outcome == 'success' && (success() || failure())
run: |
make pyright
make check-types

- name: Lint with flake8
- name: Lint code
if: steps.install.outcome == 'success' && (success() || failure())
run: |
make lint
make check-lint

- name: black and isort
- name: Verify code formatting
if: steps.install.outcome == 'success' && (success() || failure())
run: |
make check
make check-format

playwright-shiny:
runs-on: ${{ matrix.os }}
Expand Down
120 changes: 84 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
.PHONY: help clean% check% format% docs% lint test pyright playwright% install% testrail% coverage release
# https://www.gnu.org/software/make/manual/make.html#Phony-Targets
# Prerequisites of .PHONY are always interpreted as literal target names, never as patterns (even if they contain ‘%’ characters).
# # .PHONY: help clean% check% format% docs% lint test pyright playwright% install% testrail% coverage release js-*
# Using `FORCE` as prerequisite to _force_ the target to always run; https://www.gnu.org/software/make/manual/make.html#index-FORCE
FORCE: ;

.DEFAULT_GOAL := help

define BROWSER_PYSCRIPT
Expand All @@ -23,111 +28,154 @@ export PRINT_HELP_PYSCRIPT

BROWSER := python -c "$$BROWSER_PYSCRIPT"

help:
help: FORCE
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

clean-build: ## remove build artifacts
# Remove build artifacts
clean-build: FORCE
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +

clean-pyc: ## remove Python file artifacts
# Remove Python file artifacts
clean-pyc: FORCE
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean-test: ## remove test and coverage artifacts
# Remove test and coverage artifacts
clean-test: FORCE
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache
rm -rf typings/

typings/appdirs:
echo "Creating appdirs stubs"
pyright --createstub appdirs
typings/folium:
echo "Creating folium stubs"
pyright --createstub folium
typings/uvicorn:
echo "Creating uvicorn stubs"
pyright --createstub uvicorn
typings/seaborn:
echo "Creating seaborn stubs"
pyright --createstub seaborn

typings/matplotlib/__init__.pyi: ## grab type stubs from GitHub
typings/matplotlib/__init__.pyi:
echo "Creating matplotlib stubs"
mkdir -p typings
git clone --depth 1 https://github.com/microsoft/python-type-stubs typings/python-type-stubs
mv typings/python-type-stubs/stubs/matplotlib typings/
rm -rf typings/python-type-stubs

typings/seaborn:
pyright --createstub seaborn
pyright-typings: typings/appdirs typings/folium typings/uvicorn typings/seaborn typings/matplotlib/__init__.pyi

check: check-format check-lint check-types check-tests ## check code, style, types, and test (basic CI)
check-fix: format check-lint check-types check-tests ## check and format code, style, types, and test
check-format: check-black check-isort
check-lint:
@echo "-------- Checking style with flake8 --------"
check-lint: check-flake8
check-types: check-pyright
check-tests: check-pytest

check-flake8: FORCE
@echo "-------- Checking style with flake8 ---------"
flake8 --show-source .
check-black:
@echo "-------- Checking code with black --------"
check-black: FORCE
@echo "-------- Checking code with black -----------"
black --check .
check-isort:
@echo "-------- Sorting imports with isort --------"
check-isort: FORCE
@echo "-------- Sorting imports with isort ---------"
isort --check-only --diff .
check-types: typings/uvicorn typings/matplotlib/__init__.pyi typings/seaborn
check-pyright: pyright-typings
@echo "-------- Checking types with pyright --------"
pyright
check-tests:
@echo "-------- Running tests with pytest --------"
check-pytest: FORCE
@echo "-------- Running tests with pytest ----------"
python3 tests/pytest/asyncio_prevent.py
pytest

pyright: check-types ## check types with pyright
lint: check-lint ## check style with flake8
# Check types with pyright
pyright: check-types
# Check style with flake8
lint: check-lint
test: check-tests ## check tests quickly with the default Python

format: format-black format-isort ## format code with black and isort
format-black:
format-black: FORCE
@echo "-------- Formatting code with black --------"
black .
format-isort:
format-isort: FORCE
@echo "-------- Sorting imports with isort --------"
isort .

docs: ## docs: build docs with quartodoc
@echo "-------- Building docs with quartodoc --------"
docs: FORCE ## docs: build docs with quartodoc
@echo "-------- Building docs with quartodoc ------"
@cd docs && make quartodoc

docs-preview: ## docs: preview docs in browser
docs-preview: FORCE ## docs: preview docs in browser
@echo "-------- Previewing docs in browser --------"
@cd docs && make serve


install-npm: FORCE
$(if $(shell which npm), @echo -n, $(error Please install node.js and npm first. See https://nodejs.org/en/download/ for instructions.))
js/node_modules: install-npm
@echo "-------- Installing node_modules -----------"
@cd js && npm install
js-build: js/node_modules ## Build JS assets
@echo "-------- Building JS assets ----------------"
@cd js && npm run build
js-watch: js/node_modules
@echo "-------- Continuously building JS assets ---"
@cd js && npm run watch
js-watch-fast: js/node_modules ## Continuously build JS assets (development)
@echo "-------- Previewing docs in browser --------"
@cd js && npm run watch-fast
clean-js: FORCE
@echo "-------- Removing js/node_modules ----------"
rm -rf js/node_modules

# Default `SUB_FILE` to empty
SUB_FILE:=

install-playwright:
install-playwright: FORCE
playwright install --with-deps

install-trcli:
which trcli || pip install trcli
install-trcli: FORCE
$(if $(shell which trcli), @echo -n, $(shell pip install trcli))

install-rsconnect: ## install the main version of rsconnect till pypi version supports shiny express
# Installs the main version of rsconnect till pypi version supports shiny express
install-rsconnect: FORCE
pip install git+https://github.com/rstudio/rsconnect-python.git#egg=rsconnect-python

playwright-shiny: install-playwright ## end-to-end tests with playwright
# end-to-end tests with playwright; (SUB_FILE="" within tests/playwright/shiny/)
playwright-shiny: install-playwright
pytest tests/playwright/shiny/$(SUB_FILE)

playwright-deploys: install-playwright install-rsconnect ## end-to-end tests on examples with playwright
# end-to-end tests on deployed apps with playwright; (SUB_FILE="" within tests/playwright/deploys/)
playwright-deploys: install-playwright install-rsconnect
pytest tests/playwright/deploys/$(SUB_FILE)

playwright-examples: install-playwright ## end-to-end tests on examples with playwright
# end-to-end tests on all py-shiny examples with playwright; (SUB_FILE="" within tests/playwright/examples/)
playwright-examples: install-playwright
pytest tests/playwright/examples/$(SUB_FILE)

playwright-debug: install-playwright ## All end-to-end tests, chrome only, headed
playwright-debug: install-playwright ## All end-to-end tests, chrome only, headed; (SUB_FILE="" within tests/playwright/)
pytest -c tests/playwright/playwright-pytest.ini tests/playwright/$(SUB_FILE)

testrail-junit: install-playwright install-trcli ## end-to-end tests with playwright and generate junit report
# end-to-end tests with playwright and generate junit report
testrail-junit: install-playwright install-trcli
pytest tests/playwright/shiny/$(SUB_FILE) --junitxml=report.xml

coverage: ## check combined code coverage (must run e2e last)
coverage: FORCE ## check combined code coverage (must run e2e last)
pytest --cov-report term-missing --cov=shiny tests/pytest/ tests/playwright/shiny/$(SUB_FILE)
coverage html
$(BROWSER) htmlcov/index.html
Expand All @@ -148,9 +196,9 @@ install: dist
pip uninstall -y shiny
python3 -m pip install dist/shiny*.whl

install-deps: ## install dependencies
install-deps: FORCE ## install dependencies
pip install -e ".[dev,test]" --upgrade

# ## If caching is ever used, we could run:
# install-deps: ## install latest dependencies
# install-deps: FORCE ## install latest dependencies
# pip install --editable ".[dev,test]" --upgrade --upgrade-strategy eager
1 change: 1 addition & 0 deletions js/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist/*"],
overrides: [],
Expand Down
10 changes: 9 additions & 1 deletion js/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { BuildOptions, build } from "esbuild";
import { sassPlugin } from "esbuild-sass-plugin";
import * as fs from "node:fs/promises";

let minify = true;
process.argv.forEach((val, index) => {
if (val === "--minify=false") {
console.log("Disabling minification");
minify = false;
}
});

const outDir = "../shiny/www/shared/py-shiny";

async function bundle_helper(
Expand All @@ -11,7 +19,7 @@ async function bundle_helper(
const result = await build({
format: "esm",
bundle: true,
minify: true,
minify: minify,
sourcemap: true,
metafile: false,
outdir: outDir,
Expand Down
Loading
Loading