Skip to content

Commit 8500040

Browse files
whitphxlukasmasuch
andauthored
dev/upgrade streamlit 1.27.0 (#671)
* Copy .nvmrc from [email protected] * Update the streamlit submodule, fix some package resolutions for it, and fix @stlite/kernel for streamlit 1.27.0 * Update @stlite/common-react and mountable * Set webpack version in @stlite/mountable as same as [email protected] * Set the resolved webpack version to avoid an error "The 'compilation' argument must be an instance of Compilation", which is caused by multiple versions of webpack. Ref: https://qiita.com/Hanpen3019/items/e6ae5d29b334bc3d7af3 * Update @stlire/sharing * Update @stlite/desktop * Update Makefile * Remove blob-polyfill * Update Makefile * Update the streamlit submodule * Fix .github/workflows/main.yml * Add streamlit/frontend as a workspace * Add a make rule for the streamlit frontend lib * Update wheel versions * Update the streamlit submodule * Set the immutable's version as same as the locked version of the upstream Streamlit frontend to avoid type errors * Add stlite modifications (#672) * Add stlite modifications * Add back connection manager * Move methods * Some updates * Remove header * More cleanup * More changes * More cleanup * More modifications * Don't update pyiodide * More cleanup * Don't Update pyodide * Don't update pyiodide * More cleanup * More cleanup * Rename of option * Remove new line * Minor cleanup * Fix wrong option name * Minor renaming * Fix typo Co-authored-by: Yuichiro Tachibana (Tsuchiya) <[email protected]> * Update comment Co-authored-by: Yuichiro Tachibana (Tsuchiya) <[email protected]> * Remove paths * Change to put * Update URL * Add gatherUsageStats flag --------- Co-authored-by: Yuichiro Tachibana (Tsuchiya) <[email protected]> * Update the streamlit submodule * Add the PUT type to the HttpRequest interface * Fix the imports in ConnectionManager.ts * Fix upload_file_request_handler.py to refer to `kwargs` of the handler method * Fix stlite_server/upload_file_request_handler.py to catch up with the upstream implementation * Remove `form-data-encoder` from `@stlite/kernel` as it's moved to `@streamlit/lib` in whitphx/streamlit#7 * Fix the mountable option parser to distinguish the toast callback options from the kernel options * Remove ctx.disableToast() and ctx.enableToast() which were introduced in #636 because the `disableProgressToasts` and `disableErrorToasts` options play the same role * Update CHANGELOG.md * Apply Prettier to kernel * Fix stlite-server tests * Fix the CI workflows * Fix format and types in stlite-server * Update main.yml fixing the build jobs to initialize with venv * Add the streamlit lib package to the deps of the kernel make rule * Remove the TS dependency from the kernel module to the build artifact of `@streamlit/lib` * Fix main.yml * Fix .github/workflows/gh-pages.yml * Update the streamlit submodule * Fix the streamlit-proto make rule to call the python-init-dev-only rule * Fix the venv make rule to execute it every time * Update DEVELOPMENT.md * Fix desktop/bin/dump_artifacts.ts not to pin the altair version * Fix CI files * Fix tsconfig * Refresh package.json and yarn.lock * Fix stlite_server/server.py making it look more similar to the original server.py * Fix dump_artifacts.ts * Add a test for the file delete endpoint --------- Co-authored-by: Lukas Masuch <[email protected]>
1 parent 062593d commit 8500040

Some content is hidden

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

41 files changed

+6408
-8776
lines changed

.github/workflows/gh-pages.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ concurrency:
1313

1414
env:
1515
GITHUB_PAGES_SUBDIR_MOUNTABLE: lib/mountable
16-
USE_CONSTRAINT_FILE: false # https://github.com/streamlit/streamlit/blob/1.23.1/.github/workflows/release.yml#L61-L62
16+
USE_CONSTRAINTS_FILE: false # https://github.com/streamlit/streamlit/blob/1.27.0/.github/workflows/release.yml#L67-L68
1717

1818
jobs:
1919
build:
@@ -33,6 +33,8 @@ jobs:
3333

3434
steps:
3535
- uses: actions/checkout@v3
36+
with:
37+
submodules: true
3638

3739
## Set up Python and Poetry environment
3840
- name: Set up Python ${{ env.python-version }}
@@ -53,7 +55,7 @@ jobs:
5355
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
5456

5557
- name: Configure poetry
56-
run: poetry config virtualenvs.in-project true
58+
run: poetry config virtualenvs.in-project false
5759

5860
- name: Set up cache
5961
uses: actions/cache@v3
@@ -66,11 +68,15 @@ jobs:
6668
if: steps.cache.outputs.cache-hit == 'true'
6769
run: timeout 10s pip --version || rm -rf .venv
6870

71+
- name: Create virtualenv
72+
run: python -m venv .venv
73+
6974
## Set up Node environment
7075
- uses: actions/setup-node@v3
7176
with:
7277
node-version-file: .nvmrc
7378
cache: 'yarn'
79+
- run: yarn install --frozen-lockfile
7480

7581
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
7682
# Actions are running as of 2023.05.03 - doesn't have recent versions
@@ -96,7 +102,9 @@ jobs:
96102
run: echo "PUBLIC_URL=." >> $GITHUB_ENV
97103
- if: matrix.target == 'mountable'
98104
name: Build @stlite/mountable
99-
run: make mountable
105+
run: |
106+
. .venv/bin/activate
107+
make mountable
100108
101109
- if: matrix.target == 'mountable'
102110
name: Upload the built files as an artifact

.github/workflows/main.yml

+45-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env:
1515
# so we set the max memory size as 6.5 GiB like https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes
1616
NODE_OPTIONS: "--max-old-space-size=6656"
1717
RUN_ALL_TESTS: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
18-
USE_CONSTRAINT_FILE: false # https://github.com/streamlit/streamlit/blob/1.23.1/.github/workflows/release.yml#L61-L62
18+
USE_CONSTRAINTS_FILE: false # https://github.com/streamlit/streamlit/blob/1.27.0/.github/workflows/release.yml#L67-L68
1919

2020
jobs:
2121
changes: # See https://github.com/dorny/paths-filter#examples
@@ -128,6 +128,13 @@ jobs:
128128
cd packages/kernel/py/stlite-server
129129
poetry install
130130
131+
# Node packages are needed to build proto
132+
- uses: actions/setup-node@v3
133+
with:
134+
node-version-file: .nvmrc
135+
cache: 'yarn'
136+
- run: yarn install --frozen-lockfile
137+
131138
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
132139
# Actions are running as of 2023.05.03 - doesn't have recent versions
133140
# of protoc in its package repository.
@@ -144,8 +151,7 @@ jobs:
144151
- name: Set up Streamlit and build proto
145152
run: |
146153
. .venv/bin/activate
147-
cd streamlit
148-
make mini-init
154+
make streamlit-proto
149155
150156
- name: Run linter and code formatter to the test code module
151157
run: |
@@ -285,6 +291,8 @@ jobs:
285291

286292
steps:
287293
- uses: actions/checkout@v3
294+
with:
295+
submodules: true
288296

289297
## Set up Python and Poetry environment
290298
- name: Set up Python ${{ env.python-version }}
@@ -305,7 +313,7 @@ jobs:
305313
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
306314

307315
- name: Configure poetry
308-
run: poetry config virtualenvs.in-project true
316+
run: poetry config virtualenvs.in-project false
309317

310318
- name: Set up cache
311319
uses: actions/cache@v3
@@ -318,6 +326,9 @@ jobs:
318326
if: steps.cache.outputs.cache-hit == 'true'
319327
run: timeout 10s pip --version || rm -rf .venv
320328

329+
- name: Create virtualenv
330+
run: python -m venv .venv
331+
321332
## Set up Node environment
322333
- uses: actions/setup-node@v3
323334
with:
@@ -346,7 +357,9 @@ jobs:
346357
- name: Set PUBLIC_URL
347358
run: echo "PUBLIC_URL=." >> $GITHUB_ENV
348359
- name: Build @stlite/kernel
349-
run: make kernel
360+
run: |
361+
. .venv/bin/activate
362+
make kernel
350363
351364
- name: Package
352365
working-directory: packages/kernel
@@ -408,6 +421,8 @@ jobs:
408421

409422
steps:
410423
- uses: actions/checkout@v3
424+
with:
425+
submodules: true
411426

412427
## Set up Python and Poetry environment
413428
- name: Set up Python ${{ env.python-version }}
@@ -428,7 +443,7 @@ jobs:
428443
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
429444

430445
- name: Configure poetry
431-
run: poetry config virtualenvs.in-project true
446+
run: poetry config virtualenvs.in-project false
432447

433448
- name: Set up cache
434449
uses: actions/cache@v3
@@ -441,6 +456,9 @@ jobs:
441456
if: steps.cache.outputs.cache-hit == 'true'
442457
run: timeout 10s pip --version || rm -rf .venv
443458

459+
- name: Create virtualenv
460+
run: python -m venv .venv
461+
444462
## Set up Node environment
445463
- uses: actions/setup-node@v3
446464
with:
@@ -469,7 +487,9 @@ jobs:
469487
- name: Set PUBLIC_URL
470488
run: echo "PUBLIC_URL=." >> $GITHUB_ENV
471489
- name: Build @stlite/mountable
472-
run: make mountable
490+
run: |
491+
. .venv/bin/activate
492+
make mountable
473493
474494
- name: Package
475495
working-directory: packages/mountable
@@ -531,6 +551,8 @@ jobs:
531551

532552
steps:
533553
- uses: actions/checkout@v3
554+
with:
555+
submodules: true
534556

535557
## Set up Python and Poetry environment
536558
- name: Set up Python ${{ env.python-version }}
@@ -551,7 +573,7 @@ jobs:
551573
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
552574

553575
- name: Configure poetry
554-
run: poetry config virtualenvs.in-project true
576+
run: poetry config virtualenvs.in-project false
555577

556578
- name: Set up cache
557579
uses: actions/cache@v3
@@ -564,6 +586,9 @@ jobs:
564586
if: steps.cache.outputs.cache-hit == 'true'
565587
run: timeout 10s pip --version || rm -rf .venv
566588

589+
- name: Create virtualenv
590+
run: python -m venv .venv
591+
567592
## Set up Node environment
568593
- uses: actions/setup-node@v3
569594
with:
@@ -595,7 +620,9 @@ jobs:
595620
if: github.ref_name == github.event.repository.default_branch
596621
run: echo "REACT_APP_EDITOR_APP_ORIGIN=https://edit.share.stlite.net" >> $GITHUB_ENV
597622
- name: Build @stlite/sharing
598-
run: make sharing
623+
run: |
624+
. .venv/bin/activate
625+
make sharing
599626
600627
- name: Upload the built directory as an artifact
601628
uses: actions/upload-artifact@v3
@@ -692,6 +719,8 @@ jobs:
692719

693720
steps:
694721
- uses: actions/checkout@v3
722+
with:
723+
submodules: true
695724

696725
## Set up Python and Poetry environment
697726
- name: Set up Python ${{ env.python-version }}
@@ -712,7 +741,7 @@ jobs:
712741
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
713742

714743
- name: Configure poetry
715-
run: poetry config virtualenvs.in-project true
744+
run: poetry config virtualenvs.in-project false
716745

717746
- name: Set up cache
718747
uses: actions/cache@v3
@@ -725,6 +754,9 @@ jobs:
725754
if: steps.cache.outputs.cache-hit == 'true'
726755
run: timeout 10s pip --version || rm -rf .venv
727756

757+
- name: Create virtualenv
758+
run: python -m venv .venv
759+
728760
## Set up Node environment
729761
- uses: actions/setup-node@v3
730762
with:
@@ -750,7 +782,9 @@ jobs:
750782

751783
## Build and deploy @stlite/desktop
752784
- name: Build @stlite/desktop
753-
run: make desktop
785+
run: |
786+
. .venv/bin/activate
787+
make desktop
754788
755789
- name: Check if electron-builder works
756790
working-directory: packages/desktop

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lts/gallium
1+
lts/*

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### `@stlite/kernel`
11+
12+
#### Changed
13+
14+
- Update Streamlit to 1.27.0, [#671](https://github.com/whitphx/stlite/pull/671)
15+
16+
### `@stlite/mountable`
17+
18+
#### Added
19+
20+
- `disableProgressToasts` and `disableErrorToasts` options, [#671](https://github.com/whitphx/stlite/pull/671)
21+
22+
#### Changed
23+
24+
- Remove `ctx.disableToast()` and `ctx.enableToast()`, [#671](https://github.com/whitphx/stlite/pull/671)
25+
1026
## [0.42.5] - 2024-01-19
1127

1228
### `@stlite/kernel`

DEVELOPMENT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Use the Python version same as the one which the [currently used Pyodide](./pack
77
### Initialize the development environment
88

99
```
10-
USE_CONSTRAINT_FILE=false make init
10+
USE_CONSTRAINTS_FILE=false make init
1111
```
1212

1313
### Development of each package

Makefile

+21-13
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ sharing-editor := packages/sharing-editor/build/*
77
desktop := packages/desktop/build/*
88
kernel := packages/kernel/dist/*
99
stlite-server-wheel := packages/kernel/py/stlite-server/dist/stlite_server-0.1.0-py3-none-any.whl
10-
streamlit_proto := streamlit/frontend/src/lib/proto.d.ts
11-
streamlit_wheel := packages/kernel/py/streamlit/lib/dist/streamlit-1.24.0-cp311-none-any.whl
10+
streamlit_proto := streamlit/frontend/lib/src/proto.d.ts
11+
streamlit_wheel := packages/kernel/py/streamlit/lib/dist/streamlit-1.27.0-cp311-none-any.whl
12+
streamlit_frontend_lib_prod := streamlit/frontend/lib/dist/*
1213

1314
.PHONY: all
1415
all: init mountable sharing sharing-editor
@@ -21,8 +22,7 @@ VENV := ./.venv
2122
NODE_MODULES := ./node_modules
2223

2324
.PHONY: venv
24-
venv: $(VENV)
25-
$(VENV): requirements.dev.txt
25+
venv: requirements.dev.txt
2626
[ -d $(VENV) ] || python -m venv $(VENV)
2727
. $(VENV)/bin/activate && python -m pip install -U pip && python -m pip install -r requirements.dev.txt
2828
@echo "\nPython virtualenv has been set up. Run the command below to activate.\n\n. $(VENV)/bin/activate"
@@ -59,14 +59,14 @@ $(common-react): packages/common-react/src/*.ts yarn_install $(kernel)
5959

6060
.PHONY: mountable
6161
mountable: $(mountable)
62-
$(mountable): packages/mountable/src/*.ts packages/mountable/src/*.tsx yarn_install $(kernel) $(common-react)
62+
$(mountable): packages/mountable/src/*.ts packages/mountable/src/*.tsx yarn_install $(kernel) $(common-react) $(streamlit_frontend_lib_prod)
6363
cd packages/mountable; \
6464
yarn build
6565
@touch $@
6666

6767
.PHONY: sharing
6868
sharing: $(sharing)
69-
$(sharing): packages/sharing/src/*.ts packages/sharing/src/*.tsx yarn_install $(kernel) $(sharing-common) $(common-react)
69+
$(sharing): packages/sharing/src/*.ts packages/sharing/src/*.tsx yarn_install $(kernel) $(sharing-common) $(common-react) $(streamlit_frontend_lib_prod)
7070
cd packages/sharing; \
7171
yarn build
7272
@touch $@
@@ -87,7 +87,7 @@ $(sharing-editor): packages/sharing-editor/src/*.ts packages/sharing-editor/src/
8787

8888
.PHONY: desktop
8989
desktop: $(desktop)
90-
$(desktop): packages/desktop/src/*.ts packages/desktop/src/*.tsx packages/desktop/electron/*.ts yarn_install $(kernel) $(common) $(common-react)
90+
$(desktop): packages/desktop/src/*.ts packages/desktop/src/*.tsx packages/desktop/electron/*.ts yarn_install $(kernel) $(common) $(common-react) $(streamlit_frontend_lib_prod)
9191
cd packages/desktop; \
9292
yarn build
9393
@touch $@
@@ -100,21 +100,24 @@ $(kernel): packages/kernel/src/*.ts $(common) $(stlite-server-wheel) $(streamlit
100100
@touch $@
101101

102102
.PHONY: stlite-server-wheel
103-
$(stlite-server-wheel): $(VENV) packages/kernel/py/stlite-server/stlite_server/*.py
103+
stlite-server-wheel: $(stlite-server-wheel)
104+
$(stlite-server-wheel): venv packages/kernel/py/stlite-server/stlite_server/*.py
104105
. $(VENV)/bin/activate && \
105106
cd packages/kernel/py/stlite-server && \
106107
poetry build
107108
@touch $@
108109

109-
$(streamlit_proto): $(VENV) streamlit/proto/streamlit/proto/*.proto
110+
.PHONY: streamlit-proto
111+
streamlit-proto: $(streamlit_proto)
112+
$(streamlit_proto): venv streamlit/proto/streamlit/proto/*.proto
110113
. $(VENV)/bin/activate && \
111-
cd streamlit; \
112-
$(MAKE) mini-init
114+
$(MAKE) -C streamlit python-init-dev-only && \
115+
$(MAKE) -C streamlit protobuf
113116
@touch $@
114117

115118
.PHONY: streamlit-wheel
116119
streamlit-wheel: $(streamlit_wheel)
117-
$(streamlit_wheel): $(VENV) $(streamlit_proto) streamlit/lib/streamlit/**/*.py streamlit/lib/Pipfile streamlit/lib/setup.py streamlit/lib/bin/* streamlit/lib/MANIFEST.in
120+
$(streamlit_wheel): venv $(streamlit_proto) streamlit/lib/streamlit/**/*.py streamlit/lib/Pipfile streamlit/lib/setup.py streamlit/lib/bin/* streamlit/lib/MANIFEST.in
118121
. $(VENV)/bin/activate && \
119122
PYODIDE_VERSION=`python -c "import pyodide_build; print(pyodide_build.__version__)"` && \
120123
PYTHON_VERSION=`python -c "import sys; print('.'.join(map(str, sys.version_info[:3])))"` && \
@@ -124,6 +127,11 @@ $(streamlit_wheel): $(VENV) $(streamlit_proto) streamlit/lib/streamlit/**/*.py s
124127
exit 1; \
125128
fi && \
126129
cd streamlit && SNOWPARK_CONDA_BUILD=true $(MAKE) distribution && cd .. && \
127-
pyodide py-compile --keep streamlit/lib/dist/streamlit-1.24.0-py2.py3-none-any.whl && \
130+
pyodide py-compile --keep streamlit/lib/dist/streamlit-1.27.0-py2.py3-none-any.whl && \
128131
mkdir -p $(dir $(streamlit_wheel)) && \
129132
cp streamlit/lib/dist/$(notdir $(streamlit_wheel)) $(streamlit_wheel)
133+
134+
.PHONY: streamlit-frontend-lib
135+
streamlit-frontend-lib: $(streamlit_frontend_lib_prod)
136+
$(streamlit_frontend_lib_prod): yarn_install $(kernel) $(streamlit_proto) streamlit/frontend/lib/src/**/*.ts streamlit/frontend/lib/src/**/*.tsx streamlit/frontend/lib/package.json streamlit/frontend/lib/tsconfig.json
137+
$(MAKE) -C streamlit frontend-lib-prod

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"name": "stlite",
44
"workspaces": [
55
"packages/*",
6-
"streamlit/frontend"
6+
"streamlit/frontend",
7+
"streamlit/frontend/app",
8+
"streamlit/frontend/lib"
79
],
810
"scripts": {
911
"new-version": "lerna version --force-publish",
@@ -22,5 +24,10 @@
2224
"rimraf": "^3.0.2",
2325
"wait-on": "^6.0.1"
2426
},
27+
"resolutions": {
28+
"immutable": "4.2.3",
29+
"webpack": "5.76.0",
30+
"@types/react": "17.*"
31+
},
2532
"version": "0.2.0"
2633
}

packages/common-react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"check:prettier": "prettier --check ."
1515
},
1616
"dependencies": {
17-
"streamlit-browser": "^1.18.1"
17+
"@streamlit/lib": "1.27.0"
1818
},
1919
"devDependencies": {
2020
"@typescript-eslint/eslint-plugin": "^5.49.0",

0 commit comments

Comments
 (0)