Skip to content

Commit

Permalink
Update Streamlit to 1.41.0 (#1199)
Browse files Browse the repository at this point in the history
* Update Streamlit to 1.41.0

* Update kernel and sharing to use Vite (skipped ESLint)

* Update @stlite/mountable (skipped ESLint)

* Fix kernel build

* Update @stlite/desktop (skipped ESLint)

* Update @stlite/sharing-editor (skipped ESLint)

* Delete */react-app-env.d.ts

* Delete cache steps from the CI file

* Set up ESLint in sharing, mountable, and desktop

* Update package.json

* Fix tests

* Fix

* Fix

* Update streamlit submodule

* Fix

* Use @emotion/babel-plugin instead of @swc/plugin-emotion

* Fix devcontainer open port

* Set up ESLint in sharing-editor

* Enabme sourcemap for sharing-editor

* Update yarn.lock

* Format

* Fix

* [TMP] Disable sourcemap generation

* Revert "[TMP] Disable sourcemap generation"

This reverts commit f1633d1.

* Delete kernel.url

* Fix mountable to call setupCustomElement even after the DOM is initialized

* Update component gallery examples

* Delete unnecessary lines that are for Prerender.io, which Streamlit.io may use but we don't

* Improve the *.whl module type declarations

* Remove unnecessary configs in desktop/vite.config.ts
  • Loading branch information
whitphx authored Jan 8, 2025
1 parent ec84bbc commit fb5979a
Show file tree
Hide file tree
Showing 114 changed files with 14,109 additions and 20,630 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

"forwardPorts": [3000, 3030],
"forwardPorts": [3000, 5173],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "/bin/bash ./.devcontainer/postCreateCommand.sh",
Expand Down
8 changes: 4 additions & 4 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
make init

REACT_APP_EDITOR_APP_ORIGIN="https://${CODESPACE_NAME}-3030.app.github.dev"
REACT_APP_SHARING_APP_URL="https://${CODESPACE_NAME}-3000.app.github.dev/"
EDITOR_APP_ORIGIN="https://${CODESPACE_NAME}-3030.app.github.dev"
SHARING_APP_URL="https://${CODESPACE_NAME}-3000.app.github.dev/"

for file in ~/.zshrc ~/.bashrc; do
echo "" >> $file
echo "export REACT_APP_EDITOR_APP_ORIGIN=${REACT_APP_EDITOR_APP_ORIGIN}" >> $file
echo "export REACT_APP_SHARING_APP_URL=${REACT_APP_SHARING_APP_URL}" >> $file
echo "export EDITOR_APP_ORIGIN=${EDITOR_APP_ORIGIN}" >> $file
echo "export SHARING_APP_URL=${SHARING_APP_URL}" >> $file
done
37 changes: 6 additions & 31 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,6 @@ jobs:
python-version-file: ${{ env.python-version-file }}
node-version-file: ${{ env.node-version-file }}

- name: Cache node_modules/.cache including Webpack's cache
uses: actions/cache@v4
with:
path: packages/mountable/node_modules/.cache
key: mountable-node-modules-cache # Don't need to use runner.os or branch name in the key because the cache is not shared between different branches or runner OSes: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key

## Build and deploy @stlite/mountable
# PUBLIC_URL here is set as a relative path, which is possible to the trick introduced at https://github.com/whitphx/stlite/pull/143.
- name: Set PUBLIC_URL
Expand Down Expand Up @@ -422,20 +416,13 @@ jobs:
with:
python-version-file: ${{ env.python-version-file }}
node-version-file: ${{ env.node-version-file }}

- name: Cache node_modules/.cache including Webpack's cache
uses: actions/cache@v4
with:
path: packages/sharing/node_modules/.cache
key: sharing-node-modules-cache # Don't need to use runner.os or branch name in the key because the cache is not shared between different branches or runner OSes: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key

## Build and upload @stlite/sharing
- name: Set EDITOR_APP_ORIGIN (preview)
if: github.ref_name != github.event.repository.default_branch
run: echo "REACT_APP_EDITOR_APP_ORIGIN_REGEX=^https://[a-z0-9]+\.stlite-sharing-editor\.pages\.dev$" >> $GITHUB_ENV
run: echo "EDITOR_APP_ORIGIN_REGEX=^https://[a-z0-9]+\.stlite-sharing-editor\.pages\.dev$" >> $GITHUB_ENV
- name: Set EDITOR_APP_ORIGIN (main branch)
if: github.ref_name == github.event.repository.default_branch
run: echo "REACT_APP_EDITOR_APP_ORIGIN=https://edit.share.stlite.net" >> $GITHUB_ENV
run: echo "EDITOR_APP_ORIGIN=https://edit.share.stlite.net" >> $GITHUB_ENV
- name: Build @stlite/sharing
run: |
. .venv/bin/activate
Expand Down Expand Up @@ -501,31 +488,25 @@ jobs:
cache: 'yarn'
- run: yarn install --frozen-lockfile

- name: Cache node_modules/.cache including Webpack's cache
uses: actions/cache@v4
with:
path: packages/sharing-editor/node_modules/.cache
key: sharing-editor-node-modules-cache # Don't need to use runner.os or branch name in the key because the cache is not shared between different branches or runner OSes: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key

- name: Set SHARING_APP_URL (preview)
if: github.ref_name != github.event.repository.default_branch
run: echo "REACT_APP_SHARING_APP_URL=${{needs.deploy-sharing.outputs.url}}" >> $GITHUB_ENV
run: echo "SHARING_APP_URL=${{needs.deploy-sharing.outputs.url}}" >> $GITHUB_ENV
- name: Set SHARING_APP_URL (main branch)
if: github.ref_name == github.event.repository.default_branch
run: echo "REACT_APP_SHARING_APP_URL=https://share.stlite.net/" >> $GITHUB_ENV
run: echo "SHARING_APP_URL=https://share.stlite.net/" >> $GITHUB_ENV
- run: make sharing-editor

- name: Upload the built directory as an artifact
uses: actions/upload-artifact@v4
with:
path: packages/sharing-editor/build
path: packages/sharing-editor/dist
name: stlite-sharing-editor
- name: "Inform the package stats"
uses: ./.github/actions/inform-package-stats
with:
key: sharing-editor
name: "stlite sharing editor"
input-path: packages/sharing-editor/build
input-path: packages/sharing-editor/dist

deploy-sharing-editor:
if: ${{ ! failure() }} # This job should run even if the depending jobs are skipped, but not when those jobs failed: https://qiita.com/abetomo/items/d9ede7dbeeb24f723fc5#%E8%A8%AD%E5%AE%9A%E4%BE%8B4
Expand Down Expand Up @@ -571,12 +552,6 @@ jobs:
python-version-file: ${{ env.python-version-file }}
node-version-file: ${{ env.node-version-file }}

- name: Cache node_modules/.cache including Webpack's cache
uses: actions/cache@v4
with:
path: packages/desktop/node_modules/.cache
key: desktop-node-modules-cache # Don't need to use runner.os or branch name in the key because the cache is not shared between different branches or runner OSes: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key

## Build and deploy @stlite/desktop
- name: Build @stlite/desktop
run: |
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ desktop := $(BUILD_STATE_DIR)/desktop/.built
kernel := $(BUILD_STATE_DIR)/kernel/.built
stlite-lib-wheel := packages/kernel/py/stlite-lib/dist/stlite_lib-0.1.0-py3-none-any.whl
streamlit_proto := streamlit/frontend/lib/src/proto.d.ts
streamlit_wheel := packages/kernel/py/streamlit/lib/dist/streamlit-1.40.1-cp312-none-any.whl
streamlit_wheel := packages/kernel/py/streamlit/lib/dist/streamlit-1.41.0-cp312-none-any.whl
streamlit_frontend_lib_prod := streamlit/frontend/lib/dist/*

export USE_CONSTRAINTS_FILE := false # https://github.com/streamlit/streamlit/blob/1.27.0/.github/workflows/release.yml#L67-L68
Expand Down Expand Up @@ -101,7 +101,7 @@ $(common-react): $(shell find packages/common-react/src -type f \( -name "*.ts"

.PHONY: mountable
mountable: $(mountable)
$(mountable): $(shell find packages/mountable/src -type f \( -name "*.ts" -o -name "*.tsx" \) ) $(shell find packages/mountable/public -type f) $(node_modules) $(kernel) $(common) $(common-react)
$(mountable): $(shell find packages/mountable/src -type f \( -name "*.ts" -o -name "*.tsx" \) ) $(node_modules) $(kernel) $(common) $(common-react)
cd packages/mountable && yarn build
@mkdir -p $(dir $@)
@touch $@
Expand Down Expand Up @@ -178,7 +178,7 @@ $(streamlit_wheel): $(venv) $(streamlit_proto) $(shell find streamlit/lib/stream
SNOWPARK_CONDA_BUILD=true $(MAKE) -C streamlit distribution && \
mv $$TEMP_DIR/*.pyi ./streamlit/lib/streamlit/proto/ && \
rmdir $$TEMP_DIR && \
pyodide py-compile --keep streamlit/lib/dist/streamlit-1.40.1-py2.py3-none-any.whl && \
pyodide py-compile --keep streamlit/lib/dist/streamlit-1.41.0-py2.py3-none-any.whl && \
mkdir -p $(dir $(streamlit_wheel)) && \
cp streamlit/lib/dist/$(notdir $(streamlit_wheel)) $(streamlit_wheel)

Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"scripts": {
"new-version": "lerna version --force-publish",
"prepare": "husky install",
"postinstall": "patch-package --patch-dir streamlit/frontend/patches # The patch-package command requires to be run at the workspace root to patch the hoisted dependencies. So we run it here."
"//": "The patch-package command requires to be run at the workspace root to patch the hoisted dependencies. So we run it here.",
"postinstall": "patch-package --patch-dir streamlit/frontend/patches"
},
"devDependencies": {
"@lerna-lite/cli": "^3.4.0",
Expand All @@ -25,21 +26,19 @@
"eslint-plugin-react": "^7.32.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-config-prettier": "^8.6.0",
"eslint-config-react-app": "^7.0.1",
"eslint-webpack-plugin": "^3.1.1",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.1",
"rimraf": "^5.0.5",
"typescript": "^4.9.4",
"typescript": "^4.9.5",
"vitest": "^1.2.2",
"wait-on": "^7.2.0"
},
"resolutions": {
"immutable": "4.2.3",
"protobufjs": "7.2.5",
"webpack": "5.94.0",
"@types/react": "^18.2.0"
}
}
2 changes: 1 addition & 1 deletion packages/common-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"check:prettier": "prettier --check ."
},
"dependencies": {
"@streamlit/lib": "1.40.1"
"@streamlit/lib": "1.41.0"
},
"devDependencies": {
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/common-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// "paths": {} /* Specify a set of entries that re-map imports to additional lookup locations. */,
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
"types": ["vite/client"], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
Expand Down
21 changes: 21 additions & 0 deletions packages/desktop/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*eslint-env node*/
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
overrides: [],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["react", "@typescript-eslint"],
rules: {},
};
2 changes: 1 addition & 1 deletion packages/desktop/bin-src/dump_artifacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async function installPackages(
requirements.push(stliteLibWheel);
const streamlitWheel = await prepareLocalWheel(
pyodide,
path.join(wheelsDir, "streamlit-1.40.1-cp312-none-any.whl"),
path.join(wheelsDir, "streamlit-1.41.0-cp312-none-any.whl"),
);
requirements.push(streamlitWheel);

Expand Down
1 change: 1 addition & 0 deletions packages/desktop/bin-src/dump_artifacts/manifest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { coerceDesktopAppManifest } from "./manifest";

describe("coerceDesktopAppManifest", () => {
Expand Down
164 changes: 0 additions & 164 deletions packages/desktop/craco.config.js

This file was deleted.

5 changes: 3 additions & 2 deletions packages/desktop/electron/__tests__/file.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect } from "vitest";
import { walkRead } from "../file";
import * as path from "path";
import * as os from "os";
import * as path from "node:path";
import * as os from "node:os";

describe("walkRead", () => {
it("walks in the specified directory, reads the all child file contents, and returns the pairs of the relative path and the file content", async () => {
Expand Down
Loading

0 comments on commit fb5979a

Please sign in to comment.