Skip to content

Commit

Permalink
Upgrade Streamlit to 1.23.1 (#574)
Browse files Browse the repository at this point in the history
* Upgrade Streamlit to 1.23.1

* Fix the CI job for the concept of constraints introduced in the upstream Streamlit

* Fix the CI job to install the vendored protoc

* Fix to install protoc from the release page

* Fix proto path

* Remove commented-out lines

* Fix Makefile

* Fix the main.yml CI file

* Fix the import path in desktop/src/StreamlitApp.tsx

* Add comments
  • Loading branch information
whitphx authored Jun 27, 2023
1 parent 3e0e1be commit a8e90b4
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 43 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ concurrency:

env:
GITHUB_PAGES_SUBDIR_MOUNTABLE: lib/mountable
USE_CONSTRAINT_FILE: false # https://github.com/streamlit/streamlit/blob/1.23.1/.github/workflows/release.yml#L61-L62

jobs:
build:
Expand Down Expand Up @@ -71,9 +72,19 @@ jobs:
node-version-file: .nvmrc
cache: 'yarn'

## Set up apt packages. Ref: https://github.com/streamlit/streamlit/wiki/Contributing#ubuntu
- name: Install Streamlit build dependencies
run: sudo apt install protobuf-compiler
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"

- name: Set up
run: make init
Expand Down
84 changes: 68 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
USE_CONSTRAINT_FILE: false # https://github.com/streamlit/streamlit/blob/1.23.1/.github/workflows/release.yml#L61-L62

jobs:
changes: # See https://github.com/dorny/paths-filter#examples
runs-on: ubuntu-latest
Expand Down Expand Up @@ -118,10 +121,19 @@ jobs:
cd packages/kernel/py/stlite-server
poetry install
# Set up the /streamlit submodule
## Set up apt packages. Ref: https://github.com/streamlit/streamlit/wiki/Contributing#ubuntu
- name: Install Streamlit build dependencies
run: sudo apt install protobuf-compiler
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"
- name: Set up Streamlit and build proto
run: |
. .venv/bin/activate
Expand Down Expand Up @@ -313,9 +325,19 @@ jobs:
node-version-file: .nvmrc
cache: 'yarn'

## Set up apt packages. Ref: https://github.com/streamlit/streamlit/wiki/Contributing#ubuntu
- name: Install Streamlit build dependencies
run: sudo apt install protobuf-compiler
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"

- name: Set up
run: make init
Expand Down Expand Up @@ -434,9 +456,19 @@ jobs:
node-version-file: .nvmrc
cache: 'yarn'

## Set up apt packages. Ref: https://github.com/streamlit/streamlit/wiki/Contributing#ubuntu
- name: Install Streamlit build dependencies
run: sudo apt install protobuf-compiler
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"

- name: Set up
run: make init
Expand Down Expand Up @@ -555,9 +587,19 @@ jobs:
node-version-file: .nvmrc
cache: 'yarn'

## Set up apt packages. Ref: https://github.com/streamlit/streamlit/wiki/Contributing#ubuntu
- name: Install Streamlit build dependencies
run: sudo apt install protobuf-compiler
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"

- name: Set up
run: make init
Expand Down Expand Up @@ -721,9 +763,19 @@ jobs:
node-version-file: .nvmrc
cache: 'yarn'

## Set up apt packages. Ref: https://github.com/streamlit/streamlit/wiki/Contributing#ubuntu
- name: Install Streamlit build dependencies
run: sudo apt install protobuf-compiler
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"

- name: Set up
run: make init
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ sharing-editor := packages/sharing-editor/build/*
desktop := packages/desktop/build/*
kernel := packages/kernel/dist/*
stlite-server-wheel := packages/kernel/py/stlite-server/dist/stlite_server-0.1.0-py3-none-any.whl
streamlit_proto := streamlit/frontend/src/autogen
streamlit_wheel := packages/kernel/py/streamlit/lib/dist/streamlit-1.21.0-py2.py3-none-any.whl
streamlit_proto := streamlit/frontend/src/lib/proto.d.ts
streamlit_wheel := packages/kernel/py/streamlit/lib/dist/streamlit-1.23.1-py2.py3-none-any.whl

.PHONY: all
all: init mountable sharing sharing-editor
Expand Down Expand Up @@ -119,4 +119,4 @@ $(streamlit_wheel): $(VENV) $(streamlit_proto) streamlit/lib/streamlit/**/*.py s
cd streamlit && \
SNOWPARK_CONDA_BUILD=true $(MAKE) distribution
mkdir -p `dirname $(streamlit_wheel)`
cp streamlit/lib/dist/streamlit-1.21.0-py2.py3-none-any.whl $(streamlit_wheel)
cp streamlit/lib/dist/streamlit-1.23.1-py2.py3-none-any.whl $(streamlit_wheel)
4 changes: 2 additions & 2 deletions packages/common-react/src/toastify-components/theme.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
LocalStore,
localStorageAvailable,
} from "streamlit-browser/src/lib/storageUtils";
import { darkTheme } from "streamlit-browser/src/theme/themeConfigs";
} from "streamlit-browser/src/lib/util/storageUtils";
import { darkTheme } from "streamlit-browser/src/lib/theme/themeConfigs";

function isSystemDarkTheme(): boolean {
// Detect the system color mode. Ref: https://stackoverflow.com/a/57795495/13103190
Expand Down
1 change: 0 additions & 1 deletion packages/common-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"src/theme": ["../../streamlit/frontend/src/theme"],
"src/theme/*": ["../../streamlit/frontend/src/theme/*"],
"src/lib/*": ["../../streamlit/frontend/src/lib/*"],
"src/autogen/*": ["../../streamlit/frontend/src/autogen/*"]
} /* 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`. */
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/bin/dump_artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async function inspectUsedBuiltinPackages(
await pyodide.loadPackage("micropip");
const micropip = pyodide.pyimport("micropip");

micropip.add_mock_package("streamlit", "1.21.0");
micropip.add_mock_package("streamlit", "1.23.1");

await micropip.install(options.requirements);
return Object.entries(pyodide.loadedPackages)
Expand Down Expand Up @@ -149,7 +149,7 @@ async function createSitePackagesSnapshot(
pyodide,
path.join(
stliteKernelPyDir,
"streamlit/lib/dist/streamlit-1.21.0-py2.py3-none-any.whl"
"streamlit/lib/dist/streamlit-1.23.1-py2.py3-none-any.whl"
)
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src/StreamlitApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";

import { StliteKernel, StliteKernelProvider } from "@stlite/kernel";

import ThemedApp from "streamlit-browser/src/ThemedApp";
import ThemedApp from "streamlit-browser/src/app/ThemedApp";
import { Client as Styletron } from "styletron-engine-atomic";
import { Provider as StyletronProvider } from "styletron-react";
const engine = new Styletron({ prefix: "st-" });
Expand Down
4 changes: 2 additions & 2 deletions packages/kernel/src/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { PromiseDelegate } from "@lumino/coreutils";

import type { IAllowedMessageOriginsResponse } from "streamlit-browser/src/hocs/withHostCommunication/types";
import type { IAllowedMessageOriginsResponse } from "streamlit-browser/src/lib/hocs/withHostCommunication/types";

import { makeAbsoluteWheelURL } from "./url";
import { CrossOriginWorkerMaker as Worker } from "./cross-origin-worker";
Expand All @@ -28,7 +28,7 @@ import type {
// https://github.com/pyodide/pyodide/pull/1859
// https://pyodide.org/en/stable/project/changelog.html#micropip
import STLITE_SERVER_WHEEL from "!!file-loader?name=pypi/[name].[ext]&context=.!../py/stlite-server/dist/stlite_server-0.1.0-py3-none-any.whl"; // TODO: Extract the import statement to an auto-generated file like `_pypi.ts` in JupyterLite: https://github.com/jupyterlite/jupyterlite/blob/f2ecc9cf7189cb19722bec2f0fc7ff5dfd233d47/packages/pyolite-kernel/src/_pypi.ts
import STREAMLIT_WHEEL from "!!file-loader?name=pypi/[name].[ext]&context=.!../py/streamlit/lib/dist/streamlit-1.21.0-py2.py3-none-any.whl";
import STREAMLIT_WHEEL from "!!file-loader?name=pypi/[name].[ext]&context=.!../py/streamlit/lib/dist/streamlit-1.23.1-py2.py3-none-any.whl";

// Ref: https://github.com/streamlit/streamlit/blob/1.12.2/frontend/src/lib/UriUtil.ts#L32-L33
const FINAL_SLASH_RE = /\/+$/;
Expand Down
2 changes: 1 addition & 1 deletion packages/kernel/src/react-helpers/image-list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from "react";
import { useStliteKernel } from "./StliteKernelProvider";
import { IImage, Image as ImageProto } from "src/autogen/proto";
import { IImage, Image as ImageProto } from "src/lib/proto";

/**
* Overrides an image array by loading data from the stlite kernel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Mimic https://github.com/streamlit/streamlit/blob/1.9.0/frontend/src/lib/ConnectionManager.ts
// and WebsocketConnection.

import { BackMsg, ForwardMsg } from "streamlit-browser/src/autogen/proto"
import type { IAllowedMessageOriginsResponse } from "streamlit-browser/src/hocs/withHostCommunication/types"
import type { BaseUriParts } from "streamlit-browser/src/lib/UriUtil"
import { BackMsg, ForwardMsg } from "streamlit-browser/src/lib/proto"
import type { IAllowedMessageOriginsResponse } from "streamlit-browser/src/lib/hocs/withHostCommunication/types"
import type { BaseUriParts } from "streamlit-browser/src/lib/util/UriUtil"
import type { ReactNode } from "react"

import type { StliteKernel } from "../../kernel"
import { ConnectionState } from "streamlit-browser/src/lib/ConnectionState"
import { ConnectionState } from "streamlit-browser/src/app/connection/ConnectionState"
import type { SessionInfo } from "streamlit-browser/src/lib/SessionInfo"
import { ensureError } from "streamlit-browser/src/lib/ErrorHandling"
import { ensureError } from "streamlit-browser/src/lib/util/ErrorHandling"
import { DUMMY_BASE_HOSTNAME, DUMMY_BASE_PORT } from "../../consts"

interface MessageQueue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import type { CancelToken } from "axios"
import type { SessionInfo } from "streamlit-browser/src/lib/SessionInfo"
import _ from "lodash"
import type { BaseUriParts } from "streamlit-browser/src/lib/UriUtil"
import type { BaseUriParts } from "streamlit-browser/src/lib/util/UriUtil"
import { FormDataEncoder, FormDataLike } from "form-data-encoder"
import { isValidFormId } from "streamlit-browser/src/lib/utils"
import { isValidFormId } from "streamlit-browser/src/lib/util/utils"
import type { StliteKernel } from "../../kernel"

/** Common widget protobuf fields that are used by the FileUploadClient. */
Expand Down
1 change: 0 additions & 1 deletion packages/kernel/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"paths": {
"src/lib/*": ["../../streamlit/frontend/src/lib/*"],
"src/autogen/*": ["../../streamlit/frontend/src/autogen/*"],
"src/theme": ["../../streamlit/frontend/src/theme"],
"src/theme/*": ["../../streamlit/frontend/src/theme/*"],
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
Expand Down
2 changes: 1 addition & 1 deletion packages/mountable/src/StreamlitApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";

import { StliteKernel, StliteKernelProvider } from "@stlite/kernel";

import ThemedApp from "streamlit-browser/src/ThemedApp";
import ThemedApp from "streamlit-browser/src/app/ThemedApp";
import { Client as Styletron } from "styletron-engine-atomic";
import { Provider as StyletronProvider } from "styletron-react";
const engine = new Styletron({ prefix: "st-" });
Expand Down
2 changes: 1 addition & 1 deletion packages/sharing/src/StreamlitApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";

import { StliteKernel, StliteKernelProvider } from "@stlite/kernel";

import ThemedApp from "streamlit-browser/src/ThemedApp";
import ThemedApp from "streamlit-browser/src/app/ThemedApp";
import { Client as Styletron } from "styletron-engine-atomic";
import { Provider as StyletronProvider } from "styletron-react";
const engine = new Styletron({ prefix: "st-" });
Expand Down
2 changes: 1 addition & 1 deletion packages/toy-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ConnectionManager,
ConnectionState,
} from "@stlite/kernel";
import { BackMsg } from "streamlit-browser/src/autogen/proto";
import { BackMsg } from "streamlit-browser/src/lib/proto";

function App() {
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion streamlit
Submodule streamlit updated 1024 files

0 comments on commit a8e90b4

Please sign in to comment.