From 5e557abffa0dbdad0ea56a29063f6fe2c4e6a3ed Mon Sep 17 00:00:00 2001 From: Thiago Teixeira Date: Thu, 14 Jan 2021 11:04:38 -0800 Subject: [PATCH] Revert "Deploy button front (#2552)" (#2599) * Revert "Deploy button front (#2552)" This reverts commit 0f66b6eea6083413e486ebdd414af3ba9e05ba4c. * Fix merge (erm... revert) conflict. * Revert "Deploy button py (#2535)" This reverts commit 0bbc7aa681a15458708de31ab7569f2b16f244f9. Co-authored-by: karrie --- .gitignore | 1 - e2e/specs/st_main_menu.spec.js | 2 +- .../st_main_menu.spec.ts/main_menu.snap.png | Bin 0 -> 12802 bytes frontend/src/App.tsx | 67 ++------ .../core/MainMenu/MainMenu.test.tsx | 152 +---------------- .../src/components/core/MainMenu/MainMenu.tsx | 157 ++---------------- .../__snapshots__/MainMenu.test.tsx.snap | 1 - .../DeployErrorDialogs/DetachedHead.test.tsx | 9 - .../DeployErrorDialogs/DetachedHead.tsx | 16 -- .../ModuleIsNotAdded.test.tsx | 9 - .../DeployErrorDialogs/ModuleIsNotAdded.tsx | 18 -- .../NoRepositoryDetected.test.tsx | 9 - .../NoRepositoryDetected.tsx | 38 ----- .../DeployErrorDialogs/RepoIsAhead.test.tsx | 9 - .../DeployErrorDialogs/RepoIsAhead.tsx | 18 -- .../UncommittedChanges.test.tsx | 9 - .../DeployErrorDialogs/UncommittedChanges.tsx | 18 -- .../UntrackedFiles.test.tsx | 9 - .../DeployErrorDialogs/UntrackedFiles.tsx | 22 --- .../__snapshots__/DetachedHead.test.tsx.snap | 15 -- .../ModuleIsNotAdded.test.tsx.snap | 19 --- .../NoRepositoryDetected.test.tsx.snap | 42 ----- .../__snapshots__/RepoIsAhead.test.tsx.snap | 12 -- .../UncommittedChanges.test.tsx.snap | 19 --- .../UntrackedFiles.test.tsx.snap | 19 --- .../DeployErrorDialogs/index.ts | 6 - .../DeployErrorDialogs/types.ts | 6 - .../core/StreamlitDialog/StreamlitDialog.tsx | 50 ------ .../core/StreamlitDialog/styled-components.ts | 6 - frontend/src/urls.ts | 2 +- lib/streamlit/git_util.py | 35 +--- lib/streamlit/report_session.py | 53 +++--- lib/streamlit/server/server.py | 2 - lib/tests/streamlit/report_session_test.py | 8 + proto/streamlit/proto/BackMsg.proto | 2 - proto/streamlit/proto/ForwardMsg.proto | 6 +- proto/streamlit/proto/GitInfo.proto | 34 ---- proto/streamlit/proto/NewReport.proto | 13 +- 38 files changed, 76 insertions(+), 837 deletions(-) create mode 100644 frontend/cypress/snapshots/linux/2x/st_main_menu.spec.ts/main_menu.snap.png delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/DetachedHead.test.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/DetachedHead.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/ModuleIsNotAdded.test.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/ModuleIsNotAdded.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/NoRepositoryDetected.test.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/NoRepositoryDetected.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/RepoIsAhead.test.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/RepoIsAhead.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UncommittedChanges.test.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UncommittedChanges.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UntrackedFiles.test.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UntrackedFiles.tsx delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/DetachedHead.test.tsx.snap delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/ModuleIsNotAdded.test.tsx.snap delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/NoRepositoryDetected.test.tsx.snap delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/RepoIsAhead.test.tsx.snap delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/UncommittedChanges.test.tsx.snap delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/UntrackedFiles.test.tsx.snap delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/index.ts delete mode 100644 frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/types.ts delete mode 100644 proto/streamlit/proto/GitInfo.proto diff --git a/.gitignore b/.gitignore index 2bbed4bd2152..051c53dc1719 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,6 @@ cffi_bin # Pyenv Stuff .python-version -venv # Autogenerated Protobufs lib/streamlit/proto/*_pb2.py diff --git a/e2e/specs/st_main_menu.spec.js b/e2e/specs/st_main_menu.spec.js index d5f1cc7a8b50..b190bcb7f275 100644 --- a/e2e/specs/st_main_menu.spec.js +++ b/e2e/specs/st_main_menu.spec.js @@ -33,7 +33,7 @@ describe("main menu", () => { cy.get('[data-testid="main-menu-popover"]').invoke( "attr", "style", - "transform: translate3d(20px, 20px, 0px);" + "transform: translate3d(20px, 20px, 0px)" ); cy.get('[data-testid="main-menu-list"]').matchImageSnapshot("main_menu"); diff --git a/frontend/cypress/snapshots/linux/2x/st_main_menu.spec.ts/main_menu.snap.png b/frontend/cypress/snapshots/linux/2x/st_main_menu.spec.ts/main_menu.snap.png new file mode 100644 index 0000000000000000000000000000000000000000..640577f17500889c1d1ce97421d1bc4cd8edbcd6 GIT binary patch literal 12802 zcmb_@1zZ*Dy7vGA(kiWl3Ifs~AfiY}OAAPMNh2W*5~8#qQqm#}WUR+J{fzle_@2$8IegerXRLlBJcvpDdRVbkd% zd^=+yrXYqO#gPO@M%eKG%O*0a3JBuC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=IKPq52J;_-I%6)7dL^_UWMrv6%`dUZUWA) zWk2!3>E|cVTR{SXmw{Qou50-B*q~(Bz+>?m?6z!$?Vl<>(&wPU*^>Cl9Ag~78K}6M zAVW35_#sSDZ0olGM^A@dxd&Dg5GIjELvF*3*^l%1#4sP#n5&)__2x|&*a(II2W8~t zKR+Y7gre&#G3$&bL2i5V_vwwmIx zbRD#fOeozjrPFAU>irA`6lsJ#$UtX?=F(_zdhiepo?&WXZ`Iy66y)>ESFWTh8ibX@ zSmy$uHW^u2G3ej!6QDQ1d~FyE4s?tQ-MZDTU-S3L4jAr$&g){8hl7jzZ8%>C9K!Mu zp%R1ZNoOoUgG7%qI6L!!LkC~rh#+aQO5ZLXo>MP)+ila$gfU)WdnqF`b6G7_r`Q;~ z{$Pm>P@0ntK%~Rzdhbghg$8Qm@l$@Sc9`==g+pTq4#tJ49}EP>Ki)rx5A~gH(w4NQ zG^%r5y@;Mzfq9AK-2#IKMOq=}G+^~ts}0WV-E7z=IzC?aMSHqn5N3eb^Z-~b&|G-C z`>?o`E)$Sq3^)l#dyc<$ce8=yCLW^ei)_Bez+6*syCHWUXs0rHLtlWm7}{kHEG}`# zcWFK-^YGIs(3PE@o>l{0Z~YL4MA8A9Cpw2`eRgsN-)-gkgA= z4;tjbq-*-$nRI>u?WQHWR8-b+P{3&*!&iifTgJ0s0#Xo$cSokb8KU&6J$E^2peI0} zVPy87t$$;JG6K#F?&eLqNwm&>ic7e}%^UKfWCwov;hM9grn9M$vzd^|V>9@M@N)BV zbMU|yzZy5U5D%{qw;&t*z|CzOh41-qPO!B%ePr(b?@!oWiV literal 0 HcmV?d00001 diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 8f935e9db563..524bbb2a12f5 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -50,14 +50,13 @@ import { ForwardMsgMetadata, Initialize, NewReport, + IDeployParams, PageConfig, PageInfo, SessionEvent, WidgetStates, SessionState, Config, - IGitInfo, - GitInfo, } from "autogen/proto" import { without, concat } from "lodash" @@ -104,7 +103,7 @@ interface State { initialSidebarState: PageConfig.SidebarState allowRunOnSave: boolean reportFinishedHandlers: (() => void)[] - gitInfo?: IGitInfo | null + deployParams?: IDeployParams | null } const ELEMENT_LIST_BUFFER_TIMEOUT_MS = 10 @@ -162,7 +161,7 @@ export class App extends PureComponent { initialSidebarState: PageConfig.SidebarState.AUTO, allowRunOnSave: true, reportFinishedHandlers: [], - gitInfo: null, + deployParams: null, } this.sessionEventDispatcher = new SessionEventDispatcher() @@ -239,21 +238,6 @@ export class App extends PureComponent { this.openDialog(newDialog) } - showDeployError = ( - title: string, - errorNode: ReactNode, - onContinue?: () => void - ): void => { - this.openDialog({ - type: DialogType.DEPLOY_ERROR, - title, - msg: errorNode, - onContinue, - onClose: () => {}, - onTryAgain: this.sendLoadGitInfoBackMsg, - }) - } - /** * Checks if the code version from the backend is different than the frontend */ @@ -298,12 +282,6 @@ export class App extends PureComponent { } } - handleGitInfoChanged = (gitInfo: IGitInfo): void => { - this.setState({ - gitInfo, - }) - } - /** * Callback when we get a message from the server. */ @@ -335,8 +313,6 @@ export class App extends PureComponent { this.handlePageConfigChanged(pageConfig), pageInfoChanged: (pageInfo: PageInfo) => this.handlePageInfoChanged(pageInfo), - gitInfoChanged: (gitInfo: GitInfo) => - this.handleGitInfoChanged(gitInfo), reportFinished: (status: ForwardMsg.ReportFinishedStatus) => this.handleReportFinished(status), uploadReportProgress: (progress: number) => @@ -521,7 +497,12 @@ export class App extends PureComponent { } const { reportHash } = this.state - const { reportId, name: reportName, scriptPath } = newReportProto + const { + reportId, + name: reportName, + scriptPath, + deployParams, + } = newReportProto const newReportHash = hashString( SessionInfo.current.installationId + scriptPath @@ -539,9 +520,10 @@ export class App extends PureComponent { if (reportHash === newReportHash) { this.setState({ reportId, + deployParams, }) } else { - this.clearAppState(newReportHash, reportId, reportName) + this.clearAppState(newReportHash, reportId, reportName, deployParams) } } @@ -621,13 +603,15 @@ export class App extends PureComponent { clearAppState( reportHash: string, reportId: string, - reportName: string + reportName: string, + deployParams?: IDeployParams | null ): void { this.setState( { reportId, reportName, reportHash, + deployParams, elements: ReportRoot.empty(), }, () => { @@ -787,19 +771,6 @@ export class App extends PureComponent { this.widgetMgr.sendUpdateWidgetsMessage() } - sendLoadGitInfoBackMsg = (): void => { - if (!this.isServerConnected()) { - logError("Cannot load git information when disconnected from server.") - return - } - - this.sendBackMsg( - new BackMsg({ - loadGitInfo: true, - }) - ) - } - sendRerunBackMsg = (widgetStates?: WidgetStates | undefined): void => { const { queryParams } = this.props.s4aCommunication.currentState @@ -949,6 +920,7 @@ export class App extends PureComponent { const { allowRunOnSave, connectionState, + deployParams, dialog, elements, initialSidebarState, @@ -958,7 +930,6 @@ export class App extends PureComponent { reportRunState, sharingEnabled, userSettings, - gitInfo, } = this.state const outerDivClass = classNames("stApp", { "streamlit-embedded": isEmbeddedInIFrame(), @@ -1019,13 +990,7 @@ export class App extends PureComponent { screenCastState={this.props.screenCast.currentState} s4aMenuItems={this.props.s4aCommunication.currentState.items} sendS4AMessage={this.props.s4aCommunication.sendMessage} - gitInfo={gitInfo} - showDeployError={this.showDeployError} - closeDialog={this.closeDialog} - isDeployErrorModalOpen={ - this.state.dialog?.type === DialogType.DEPLOY_ERROR - } - loadGitInfo={this.sendLoadGitInfoBackMsg} + deployParams={deployParams} /> diff --git a/frontend/src/components/core/MainMenu/MainMenu.test.tsx b/frontend/src/components/core/MainMenu/MainMenu.test.tsx index 42b85a1de630..dcd066d66598 100644 --- a/frontend/src/components/core/MainMenu/MainMenu.test.tsx +++ b/frontend/src/components/core/MainMenu/MainMenu.test.tsx @@ -18,23 +18,9 @@ import React from "react" import { shallow } from "lib/test_util" import { IMenuItem } from "hocs/withS4ACommunication/types" -import { Args as SessionInfoArgs, SessionInfo } from "lib/SessionInfo" - -import { GitInfo, IGitInfo } from "autogen/proto" -import { IDeployErrorDialog } from "components/core/StreamlitDialog/DeployErrorDialogs/types" -import { - DetachedHead, - ModuleIsNotAdded, - NoRepositoryDetected, - RepoIsAhead, - UncommittedChanges, - UntrackedFiles, -} from "components/core/StreamlitDialog/DeployErrorDialogs" import MainMenu, { Props } from "./MainMenu" -const { GitStates } = GitInfo - const getProps = (extend?: Partial): Props => ({ aboutCallback: jest.fn(), clearCacheCallback: jest.fn(), @@ -47,29 +33,10 @@ const getProps = (extend?: Partial): Props => ({ settingsCallback: jest.fn(), shareCallback: jest.fn(), sharingEnabled: false, - isDeployErrorModalOpen: false, - showDeployError: jest.fn(), - loadGitInfo: jest.fn(), - closeDialog: jest.fn(), ...extend, }) describe("App", () => { - beforeAll(() => { - SessionInfo.current = new SessionInfo({ - sessionId: "sessionId", - streamlitVersion: "sv", - pythonVersion: "pv", - installationId: "iid", - installationIdV1: "iid1", - installationIdV2: "iid2", - authorEmail: "ae", - maxCachedMessageAge: 2, - commandLine: "command line", - userMapboxToken: "mpt", - } as SessionInfoArgs) - }) - it("renders without crashing", () => { const props = getProps() const wrapper = shallow() @@ -160,7 +127,7 @@ describe("App", () => { }) it("should render deploy app menu item", () => { - const props = getProps({ gitInfo: {} }) + const props = getProps({ deployParams: {} }) const wrapper = shallow() const popoverContent = wrapper.find("StatefulPopover").prop("content") // @ts-ignore @@ -185,121 +152,4 @@ describe("App", () => { "About", ]) }) - - describe("Onclick deploy button", () => { - function testDeployErrorModal( - gitInfo: Partial, - dialogComponent: (module: string) => IDeployErrorDialog - ): void { - const props = getProps({ - gitInfo, - }) - const wrapper = shallow() - const popoverContent = wrapper.find("StatefulPopover").prop("content") - // @ts-ignore - const menuWrapper = shallow(popoverContent(() => {})).dive() - - const items: any = menuWrapper.prop("items") - - const deployOption = items.find( - // @ts-ignore - ({ label }) => label === "Deploy this app" - ) - - deployOption.onClick() - - // @ts-ignore - const dialog = dialogComponent(props.gitInfo.module) - - expect(props.showDeployError.mock.calls[0][0]).toStrictEqual( - dialog.title - ) - expect(props.showDeployError.mock.calls[0][1]).toStrictEqual(dialog.body) - } - - it("no repo or remote", () => { - testDeployErrorModal( - { - state: GitStates.DEFAULT, - }, - NoRepositoryDetected - ) - }) - - it("empty repo", () => { - testDeployErrorModal( - { - repository: "", - branch: "", - module: "", - state: GitStates.DEFAULT, - }, - NoRepositoryDetected - ) - }) - - it("repo is detached", () => { - testDeployErrorModal( - { - repository: "repo", - branch: "branch", - module: "module", - state: GitStates.HEAD_DETACHED, - }, - DetachedHead - ) - }) - - it("script was not added to the repo", () => { - testDeployErrorModal( - { - repository: "repo", - branch: "branch", - module: "module.py", - isHeadDetached: false, - untrackedFiles: ["module.py"], - }, - ModuleIsNotAdded - ) - }) - - it("uncommitted changes", () => { - testDeployErrorModal( - { - repository: "repo", - branch: "branch", - module: "module.py", - isHeadDetached: false, - uncommittedFiles: ["module.py"], - untrackedFiles: [], - }, - UncommittedChanges - ) - }) - - it("changes not pushed to Github", () => { - const deployParams: IGitInfo = { - repository: "repo", - branch: "branch", - module: "module.py", - uncommittedFiles: [], - untrackedFiles: [], - state: GitStates.AHEAD_OF_REMOTE, - } - testDeployErrorModal(deployParams, RepoIsAhead) - }) - - it("untracked files", () => { - testDeployErrorModal( - { - repository: "repo", - branch: "branch", - module: "module.py", - isHeadDetached: false, - untrackedFiles: ["another-file.py"], - }, - UntrackedFiles - ) - }) - }) }) diff --git a/frontend/src/components/core/MainMenu/MainMenu.tsx b/frontend/src/components/core/MainMenu/MainMenu.tsx index d0e66fcec872..4b8a36fc68bc 100644 --- a/frontend/src/components/core/MainMenu/MainMenu.tsx +++ b/frontend/src/components/core/MainMenu/MainMenu.tsx @@ -15,36 +15,19 @@ * limitations under the License. */ -import React, { - forwardRef, - memo, - MouseEvent, - ReactElement, - ReactNode, - useCallback, - useEffect, -} from "react" +import React, { ReactElement, memo, forwardRef, MouseEvent } from "react" +import { StatefulPopover, PLACEMENT } from "baseui/popover" import { StatefulMenu } from "baseui/menu" -import { SessionInfo } from "lib/SessionInfo" -import { Menu } from "@emotion-icons/open-iconic" import Button, { Kind } from "components/shared/Button" -import { PLACEMENT, StatefulPopover } from "baseui/popover" -import { - DetachedHead, - ModuleIsNotAdded, - NoRepositoryDetected, - RepoIsAhead, - UncommittedChanges, - UntrackedFiles, -} from "components/core/StreamlitDialog/DeployErrorDialogs" +import { Menu } from "@emotion-icons/open-iconic" import Icon from "components/shared/Icon" import { - IGuestToHostMessage, IMenuItem, + IGuestToHostMessage, } from "hocs/withS4ACommunication/types" -import { GitInfo, IGitInfo } from "autogen/proto" +import { IDeployParams } from "autogen/proto" import { BUG_URL, COMMUNITY_URL, @@ -54,15 +37,13 @@ import { TEAMS_URL, } from "urls" import { - StyledMenuDivider, StyledMenuItem, + StyledMenuDivider, StyledMenuItemLabel, StyledMenuItemShortcut, StyledRecordingIndicator, } from "./styled-components" -const { GitStates } = GitInfo - const SCREENCAST_LABEL: { [s: string]: string } = { COUNTDOWN: "Cancel screencast", RECORDING: "Stop recording", @@ -78,9 +59,6 @@ export interface Props { /** Rerun the report. */ quickRerunCallback: () => void - /** Reload git information message */ - loadGitInfo: () => void - /** Clear the cache. */ clearCacheCallback: () => void @@ -102,32 +80,24 @@ export interface Props { sendS4AMessage: (message: IGuestToHostMessage) => void - gitInfo?: IGitInfo | null - - showDeployError: ( - title: string, - errorNode: ReactNode, - onContinue?: () => void - ) => void - - closeDialog: () => void - - isDeployErrorModalOpen: boolean + deployParams?: IDeployParams | null } const getOpenInWindowCallback = (url: string) => (): void => { window.open(url, "_blank") } -const getDeployAppUrl = (gitInfo?: IGitInfo | null): (() => void) => { +const getDeployAppUrl = ( + deployParams: IDeployParams | null | undefined +): (() => void) => { // If the app was run inside a GitHub repo, autofill for a one-click deploy. // E.g.: https://share.streamlit.io/deploy?repository=melon&branch=develop&mainModule=streamlit_app.py - if (gitInfo) { + if (deployParams) { const deployUrl = new URL(DEPLOY_URL) - deployUrl.searchParams.set("repository", gitInfo.repository || "") - deployUrl.searchParams.set("branch", gitInfo.branch || "") - deployUrl.searchParams.set("mainModule", gitInfo.module || "") + deployUrl.searchParams.set("repository", deployParams.repository || "") + deployUrl.searchParams.set("branch", deployParams.branch || "") + deployUrl.searchParams.set("mainModule", deployParams.module || "") return getOpenInWindowCallback(deployUrl.toString()) } @@ -215,94 +185,6 @@ const MenuListItem = forwardRef( function MainMenu(props: Props): ReactElement { const isServerDisconnected = !props.isServerConnected - const onClickDeployApp = useCallback((): void => { - const { - showDeployError, - closeDialog, - isDeployErrorModalOpen, - gitInfo, - } = props - - if (!gitInfo) { - const dialog = NoRepositoryDetected() - - showDeployError(dialog.title, dialog.body) - - return - } - - const { - repository, - branch, - module, - untrackedFiles, - uncommittedFiles, - state: gitState, - } = gitInfo - - if ( - (!repository || !branch || !module) && - gitState === GitStates.DEFAULT - ) { - const dialog = NoRepositoryDetected() - - showDeployError(dialog.title, dialog.body) - - return - } - - if (gitState === GitStates.HEAD_DETACHED) { - const dialog = DetachedHead() - - showDeployError(dialog.title, dialog.body) - - return - } - - if (module && untrackedFiles?.includes(module)) { - const dialog = ModuleIsNotAdded(module) - - showDeployError(dialog.title, dialog.body) - - return - } - - if (module && uncommittedFiles?.length) { - const dialog = UncommittedChanges(module) - - showDeployError(dialog.title, dialog.body) - - return - } - - if (gitState === GitStates.AHEAD_OF_REMOTE) { - const dialog = RepoIsAhead() - - showDeployError(dialog.title, dialog.body, getDeployAppUrl(gitInfo)) - - return - } - - if (untrackedFiles?.length) { - const dialog = UntrackedFiles() - - showDeployError(dialog.title, dialog.body, getDeployAppUrl(gitInfo)) - - return - } - - // We should close the modal when we try again and everything goes fine - if (isDeployErrorModalOpen) closeDialog() - - getDeployAppUrl(gitInfo)() - }, [props]) - - useEffect(() => { - if (!props.gitInfo || !props.isDeployErrorModalOpen) return - - onClickDeployApp() - }, [props.gitInfo, props.isDeployErrorModalOpen, onClickDeployApp]) - const coreMenuOptions = { DIVIDER: { isDivider: true }, rerun: { @@ -324,7 +206,7 @@ function MainMenu(props: Props): ReactElement { stopRecordingIndicator: Boolean(SCREENCAST_LABEL[props.screenCastState]), }, deployApp: { - onClick: onClickDeployApp, + onClick: getDeployAppUrl(props.deployParams), label: "Deploy this app", }, saveSnapshot: { @@ -369,11 +251,7 @@ function MainMenu(props: Props): ReactElement { const shouldShowS4AMenu = !!S4AMenuOptions.length - const showDeploy = - isLocalhost() && - !shouldShowS4AMenu && - SessionInfo.isSet() && - !SessionInfo.isHello + const showDeploy = isLocalhost() && !shouldShowS4AMenu const showSnapshot = !shouldShowS4AMenu && props.sharingEnabled const showClearCache = !shouldShowS4AMenu const preferredMenuOrder: any[] = [ @@ -418,9 +296,6 @@ function MainMenu(props: Props): ReactElement { return ( { - props.loadGitInfo() - }} placement={PLACEMENT.bottomRight} content={({ close }) => ( { - it("Should render without crashing", () => { - const dialog = DetachedHead() - - expect(dialog).toMatchSnapshot() - }) -}) diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/DetachedHead.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/DetachedHead.tsx deleted file mode 100644 index 9175d30b1068..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/DetachedHead.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from "react" -import { IDeployErrorDialog } from "./types" - -function DetachedHead(): IDeployErrorDialog { - return { - title: "Unable to deploy app", - body: ( - <> -

This Git tree is in a detached HEAD state.

-

Please commit the latest changes and push to Github to continue.

- - ), - } -} - -export default DetachedHead diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/ModuleIsNotAdded.test.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/ModuleIsNotAdded.test.tsx deleted file mode 100644 index c449ad3c5ef9..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/ModuleIsNotAdded.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import ModuleIsNotAdded from "./ModuleIsNotAdded" - -describe("DeployErrorDialog - ModuleIsNotAdded", () => { - it("Should render without crashing", () => { - const dialog = ModuleIsNotAdded("module") - - expect(dialog).toMatchSnapshot() - }) -}) diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/ModuleIsNotAdded.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/ModuleIsNotAdded.tsx deleted file mode 100644 index fe9499e71c37..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/ModuleIsNotAdded.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from "react" -import { IDeployErrorDialog } from "./types" - -function ModuleIsNotAdded(module: string): IDeployErrorDialog { - return { - title: "Unable to deploy app", - body: ( - <> -

- The file {module} has not been added to the repo. -

-

Please add it and push to Github to continue.

- - ), - } -} - -export default ModuleIsNotAdded diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/NoRepositoryDetected.test.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/NoRepositoryDetected.test.tsx deleted file mode 100644 index db97a1bbc240..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/NoRepositoryDetected.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import NoRepositoryDetected from "./NoRepositoryDetected" - -describe("DeployErrorDialog - NoRepositoryDetected", () => { - it("Should render without crashing", () => { - const dialog = NoRepositoryDetected() - - expect(dialog).toMatchSnapshot() - }) -}) diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/NoRepositoryDetected.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/NoRepositoryDetected.tsx deleted file mode 100644 index bffb4b1029dc..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/NoRepositoryDetected.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from "react" -import { ONLINE_DOCS_URL, TEAMS_URL } from "urls" -import { IDeployErrorDialog } from "./types" - -function NoRepositoryDetected(): IDeployErrorDialog { - return { - title: "Unable to deploy app", - body: ( - <> -

Could not find a remote repository hosted on Github.

-

How Streamlit sharing works:

- - - ), - } -} - -export default NoRepositoryDetected diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/RepoIsAhead.test.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/RepoIsAhead.test.tsx deleted file mode 100644 index a11d9b81e356..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/RepoIsAhead.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import RepoIsAhead from "./RepoIsAhead" - -describe("DeployErrorDialog - RepoIsAhead", () => { - it("Should render without crashing", () => { - const dialog = RepoIsAhead() - - expect(dialog).toMatchSnapshot() - }) -}) diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/RepoIsAhead.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/RepoIsAhead.tsx deleted file mode 100644 index 58561302fab7..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/RepoIsAhead.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from "react" -import { IDeployErrorDialog } from "./types" - -function RepoIsAhead(): IDeployErrorDialog { - return { - title: "Unable to deploy app", - body: ( - <> -

- This Git repo has uncommitted changes. You may want to commit them - before continuing. -

- - ), - } -} - -export default RepoIsAhead diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UncommittedChanges.test.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UncommittedChanges.test.tsx deleted file mode 100644 index 2b3cbda1fada..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UncommittedChanges.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import UncommittedChanges from "./UncommittedChanges" - -describe("DeployErrorDialog - RepoIsAhead", () => { - it("Should render without crashing", () => { - const dialog = UncommittedChanges("module") - - expect(dialog).toMatchSnapshot() - }) -}) diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UncommittedChanges.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UncommittedChanges.tsx deleted file mode 100644 index e2ad500ac628..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UncommittedChanges.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from "react" -import { IDeployErrorDialog } from "./types" - -function UncommittedChanges(module: string): IDeployErrorDialog { - return { - title: "Unable to deploy app", - body: ( - <> -

- The file {module} has uncommitted changes. -

-

Please commit the latest changes and push to Github to continue.

- - ), - } -} - -export default UncommittedChanges diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UntrackedFiles.test.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UntrackedFiles.test.tsx deleted file mode 100644 index 51678bab6d48..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UntrackedFiles.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import UntrackedFiles from "./UntrackedFiles" - -describe("DeployErrorDialog - UntrackedFiles", () => { - it("Should render without crashing", () => { - const dialog = UntrackedFiles() - - expect(dialog).toMatchSnapshot() - }) -}) diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UntrackedFiles.tsx b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UntrackedFiles.tsx deleted file mode 100644 index 7aa9f441b113..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/UntrackedFiles.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from "react" -import { IDeployErrorDialog } from "./types" - -function UntrackedFiles(): IDeployErrorDialog { - return { - title: "Unable to deploy app", - body: ( - <> -

- This Git repo has untracked files. You may want to commit them before - continuing. -

-

- Alternatively, you can either delete the files (if they're not - needed) or add them to your .gitignore. -

- - ), - } -} - -export default UntrackedFiles diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/DetachedHead.test.tsx.snap b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/DetachedHead.test.tsx.snap deleted file mode 100644 index 798e26c3d5b7..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/DetachedHead.test.tsx.snap +++ /dev/null @@ -1,15 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DeployErrorDialog - DetachedHead Should render without crashing 1`] = ` -Object { - "body": -

- This Git tree is in a detached HEAD state. -

-

- Please commit the latest changes and push to Github to continue. -

-
, - "title": "Unable to deploy app", -} -`; diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/ModuleIsNotAdded.test.tsx.snap b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/ModuleIsNotAdded.test.tsx.snap deleted file mode 100644 index bf4f7d46434d..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/ModuleIsNotAdded.test.tsx.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DeployErrorDialog - ModuleIsNotAdded Should render without crashing 1`] = ` -Object { - "body": -

- The file - - module - - has not been added to the repo. -

-

- Please add it and push to Github to continue. -

-
, - "title": "Unable to deploy app", -} -`; diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/NoRepositoryDetected.test.tsx.snap b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/NoRepositoryDetected.test.tsx.snap deleted file mode 100644 index dbc277610700..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/NoRepositoryDetected.test.tsx.snap +++ /dev/null @@ -1,42 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DeployErrorDialog - NoRepositoryDetected Should render without crashing 1`] = ` -Object { - "body": -

- Could not find a remote repository hosted on Github. -

-

- How Streamlit sharing works: -

- -
, - "title": "Unable to deploy app", -} -`; diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/RepoIsAhead.test.tsx.snap b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/RepoIsAhead.test.tsx.snap deleted file mode 100644 index 2a878e7a7931..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/RepoIsAhead.test.tsx.snap +++ /dev/null @@ -1,12 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DeployErrorDialog - RepoIsAhead Should render without crashing 1`] = ` -Object { - "body": -

- This Git repo has uncommitted changes. You may want to commit them before continuing. -

-
, - "title": "Unable to deploy app", -} -`; diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/UncommittedChanges.test.tsx.snap b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/UncommittedChanges.test.tsx.snap deleted file mode 100644 index b6bba88aa7c0..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/UncommittedChanges.test.tsx.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DeployErrorDialog - RepoIsAhead Should render without crashing 1`] = ` -Object { - "body": -

- The file - - module - - has uncommitted changes. -

-

- Please commit the latest changes and push to Github to continue. -

-
, - "title": "Unable to deploy app", -} -`; diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/UntrackedFiles.test.tsx.snap b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/UntrackedFiles.test.tsx.snap deleted file mode 100644 index a35b6a14274e..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/__snapshots__/UntrackedFiles.test.tsx.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DeployErrorDialog - UntrackedFiles Should render without crashing 1`] = ` -Object { - "body": -

- This Git repo has untracked files. You may want to commit them before continuing. -

-

- Alternatively, you can either delete the files (if they're not needed) or add them to your - - .gitignore - - . -

-
, - "title": "Unable to deploy app", -} -`; diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/index.ts b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/index.ts deleted file mode 100644 index 90b679635410..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { default as RepoIsAhead } from "./RepoIsAhead" -export { default as DetachedHead } from "./DetachedHead" -export { default as UntrackedFiles } from "./UntrackedFiles" -export { default as ModuleIsNotAdded } from "./ModuleIsNotAdded" -export { default as UncommittedChanges } from "./UncommittedChanges" -export { default as NoRepositoryDetected } from "./NoRepositoryDetected" diff --git a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/types.ts b/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/types.ts deleted file mode 100644 index 15afe3dc38d6..000000000000 --- a/frontend/src/components/core/StreamlitDialog/DeployErrorDialogs/types.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ReactNode } from "react" - -export interface IDeployErrorDialog { - title: string - body: ReactNode -} diff --git a/frontend/src/components/core/StreamlitDialog/StreamlitDialog.tsx b/frontend/src/components/core/StreamlitDialog/StreamlitDialog.tsx index 0dc07c5e45ed..275830d3c507 100644 --- a/frontend/src/components/core/StreamlitDialog/StreamlitDialog.tsx +++ b/frontend/src/components/core/StreamlitDialog/StreamlitDialog.tsx @@ -41,7 +41,6 @@ import { StyledRerunHeader, StyledCommandLine, StyledUploadUrl, - StyledDeployErrorContent, } from "./styled-components" type PlainEventHandler = () => void @@ -64,7 +63,6 @@ export type DialogProps = | UploadProgressProps | UploadedProps | WarningProps - | DeployErrorProps export enum DialogType { ABOUT = "about", @@ -76,7 +74,6 @@ export enum DialogType { UPLOAD_PROGRESS = "uploadProgress", UPLOADED = "uploaded", WARNING = "warning", - DEPLOY_ERROR = "deployError", } export function StreamlitDialog(dialogProps: DialogProps): ReactNode { @@ -99,8 +96,6 @@ export function StreamlitDialog(dialogProps: DialogProps): ReactNode { return uploadedDialog(dialogProps) case DialogType.WARNING: return warningDialog(dialogProps) - case DialogType.DEPLOY_ERROR: - return deployErrorDialog(dialogProps) case undefined: return noDialog(dialogProps) default: @@ -377,51 +372,6 @@ function warningDialog(props: WarningProps): ReactElement { ) } -interface DeployErrorProps { - type: DialogType.DEPLOY_ERROR - title: string - msg: ReactNode - onClose: PlainEventHandler - onContinue?: PlainEventHandler - onTryAgain: PlainEventHandler -} - -/** - * Modal used to show deployment errors - */ -function deployErrorDialog({ - title, - msg, - onClose, - onContinue, - onTryAgain, -}: DeployErrorProps): ReactElement { - const handlePrimaryButton = (): void => { - onClose() - - if (onContinue) { - onContinue() - } - } - - return ( - - {title} - - {msg} - - - - Try again - - - {onContinue ? "Continue anyway" : "Close"} - - - - ) -} - /** * Returns an empty dictionary, indicating that no object is to be displayed. */ diff --git a/frontend/src/components/core/StreamlitDialog/styled-components.ts b/frontend/src/components/core/StreamlitDialog/styled-components.ts index 0a2707715550..4e84e077a71e 100644 --- a/frontend/src/components/core/StreamlitDialog/styled-components.ts +++ b/frontend/src/components/core/StreamlitDialog/styled-components.ts @@ -27,9 +27,3 @@ export const StyledShortcutLabel = styled.span(({ theme }) => ({ textDecoration: "underline", }, })) - -export const StyledDeployErrorContent = styled.div(({ theme }) => ({ - "& > ul": { - paddingLeft: "1.4rem", - }, -})) diff --git a/frontend/src/urls.ts b/frontend/src/urls.ts index 44c7e4b2f97c..e56a4dd2b1f6 100644 --- a/frontend/src/urls.ts +++ b/frontend/src/urls.ts @@ -20,7 +20,7 @@ export const DEPLOY_URL = "https://share.streamlit.io/deploy" export const STREAMLIT_SHARE_URL = "https://streamlit.io/sharing" export const ONLINE_DOCS_URL = "https://docs.streamlit.io" export const COMMUNITY_URL = "https://discuss.streamlit.io" -export const TEAMS_URL = "https://streamlit.io/for-teams" +export const TEAMS_URL = "https://streamlit.io/forteams" export const BUG_URL = "https://github.com/streamlit/streamlit/issues/new/choose" diff --git a/lib/streamlit/git_util.py b/lib/streamlit/git_util.py index 04cfc26ef5d8..a712d590060a 100644 --- a/lib/streamlit/git_util.py +++ b/lib/streamlit/git_util.py @@ -23,10 +23,10 @@ def __init__(self, path): self.repo = git.Repo(path, search_parent_directories=True) self.git_version = self.repo.git.version_info - if self.git_version >= MIN_GIT_VERSION: git_root = self.repo.git.rev_parse("--show-toplevel") self.module = os.path.relpath(path, git_root) + except: # The git repo must be invalid for the following reasons: # * git binary or GitPython not installed @@ -47,46 +47,13 @@ def is_valid(self) -> bool: def tracking_branch(self): if not self.is_valid(): return None - - if self.is_head_detached: - return None - return self.repo.active_branch.tracking_branch() - @property - def untracked_files(self): - return self.repo.untracked_files - - @property - def is_head_detached(self): - return self.repo.head.is_detached - - @property - def uncommitted_files(self): - if not self.is_valid(): - return None - - return [item.a_path for item in self.repo.index.diff(None)] - - @property - def ahead_commits(self): - if not self.is_valid(): - return None - - try: - remote, branch_name = self.get_tracking_branch_remote() - remote_branch = "/".join([remote.name, branch_name]) - - return list(self.repo.iter_commits(f"{remote_branch}..{branch_name}")) - except: - return list() - def get_tracking_branch_remote(self): if not self.is_valid(): return None tracking_branch = self.tracking_branch - if tracking_branch is None: return None diff --git a/lib/streamlit/report_session.py b/lib/streamlit/report_session.py index 6c354187c2a3..977719087110 100644 --- a/lib/streamlit/report_session.py +++ b/lib/streamlit/report_session.py @@ -36,7 +36,6 @@ from streamlit.logger import get_logger from streamlit.proto.ForwardMsg_pb2 import ForwardMsg from streamlit.proto.ClientState_pb2 import ClientState -from streamlit.proto.GitInfo_pb2 import GitInfo from streamlit.server.server_util import serialize_forward_msg from streamlit.storage.file_storage import FileStorage from streamlit.watcher.local_sources_watcher import LocalSourcesWatcher @@ -60,7 +59,6 @@ class ReportSession(object): and widget state. A ReportSession is attached to each thread involved in running its Report. - """ def __init__(self, ioloop, script_path, command_line, uploaded_file_manager): @@ -347,14 +345,34 @@ def _enqueue_file_change_message(self): msg.session_event.report_changed_on_disk = True self.enqueue(msg) + def get_deploy_params(self): + try: + from streamlit.git_util import GitRepo + + self._repo = GitRepo(self._report.script_path) + return self._repo.get_repo_info() + except: + # Issues can arise based on the git structure + # (e.g. if branch is in DETACHED HEAD state, + # git is not installed, etc) + # In this case, catch any errors + return None + def _enqueue_new_report_message(self): self._report.generate_new_id() - msg = ForwardMsg() msg.new_report.report_id = self._report.report_id msg.new_report.name = self._report.name msg.new_report.script_path = self._report.script_path + # git deploy params + deploy_params = self.get_deploy_params() + if deploy_params is not None: + repo, branch, module = deploy_params + msg.new_report.deploy_params.repository = repo + msg.new_report.deploy_params.branch = branch + msg.new_report.deploy_params.module = module + # Immutable session data. We send this every time a new report is # started, to avoid having to track whether the client has already # received it. It does not change from run to run; it's up to the @@ -405,34 +423,6 @@ def _enqueue_report_finished_message(self, status): msg.report_finished = status self.enqueue(msg) - def handle_git_information_request(self): - msg = ForwardMsg() - - try: - from streamlit.git_util import GitRepo - - self._repo = GitRepo(self._report.script_path) - - repo, branch, module = self._repo.get_repo_info() - - msg.git_info_changed.repository = repo - msg.git_info_changed.branch = branch - msg.git_info_changed.module = module - - msg.git_info_changed.untracked_files[:] = self._repo.untracked_files - msg.git_info_changed.uncommitted_files[:] = self._repo.uncommitted_files - - if self._repo.is_head_detached: - msg.git_info_changed.state = GitInfo.GitStates.HEAD_DETACHED - elif len(self._repo.ahead_commits) > 0: - msg.git_info_changed.state = GitInfo.GitStates.AHEAD_OF_REMOTE - else: - msg.git_info_changed.state = GitInfo.GitStates.DEFAULT - - self.enqueue(msg) - except: - pass - def handle_rerun_script_request(self, client_state=None, is_preheat=False): """Tell the ScriptRunner to re-run its report. @@ -441,7 +431,6 @@ def handle_rerun_script_request(self, client_state=None, is_preheat=False): client_state : streamlit.proto.ClientState_pb2.ClientState | None The ClientState protobuf to run the script with, or None to use previous client state. - is_preheat: boolean True if this ReportSession should run the script immediately, and then ignore the next rerun request if it matches the already-ran diff --git a/lib/streamlit/server/server.py b/lib/streamlit/server/server.py index 624b513646e2..0c599a5d51a2 100644 --- a/lib/streamlit/server/server.py +++ b/lib/streamlit/server/server.py @@ -680,8 +680,6 @@ def on_message(self, payload): yield self._session.handle_save_request(self) elif msg_type == "rerun_script": self._session.handle_rerun_script_request(msg.rerun_script) - elif msg_type == "load_git_info": - self._session.handle_git_information_request() elif msg_type == "clear_cache": self._session.handle_clear_cache_request() elif msg_type == "set_run_on_save": diff --git a/lib/tests/streamlit/report_session_test.py b/lib/tests/streamlit/report_session_test.py index 02d5fcabac97..1973d4979901 100644 --- a/lib/tests/streamlit/report_session_test.py +++ b/lib/tests/streamlit/report_session_test.py @@ -70,6 +70,14 @@ def get_option(name): # Expect func to be called only once, inside enqueue(). func.assert_called_once() + @patch("streamlit.report_session.LocalSourcesWatcher") + @pytest.mark.usefixtures("del_path") + def test_get_deploy_params_with_no_git(self, _1): + """Make sure we try to handle execution control requests.""" + rs = ReportSession(None, report_session.__file__, "", UploadedFileManager()) + + self.assertIsNone(rs.get_deploy_params()) + @patch("streamlit.report_session.config") @patch("streamlit.report_session.Report") @patch("streamlit.report_session.LocalSourcesWatcher") diff --git a/proto/streamlit/proto/BackMsg.proto b/proto/streamlit/proto/BackMsg.proto index 14e95c642627..9d850ef8b560 100644 --- a/proto/streamlit/proto/BackMsg.proto +++ b/proto/streamlit/proto/BackMsg.proto @@ -53,8 +53,6 @@ message BackMsg { bool close_connection = 10; ClientState rerun_script = 11; - - bool load_git_info = 12; } reserved 1, 3, 4, 8, 9; diff --git a/proto/streamlit/proto/ForwardMsg.proto b/proto/streamlit/proto/ForwardMsg.proto index 178ee5ee35a7..76e0381a431a 100644 --- a/proto/streamlit/proto/ForwardMsg.proto +++ b/proto/streamlit/proto/ForwardMsg.proto @@ -22,7 +22,6 @@ import "streamlit/proto/PageConfig.proto"; import "streamlit/proto/PageInfo.proto"; import "streamlit/proto/SessionEvent.proto"; import "streamlit/proto/SessionState.proto"; -import "streamlit/proto/GitInfo.proto"; // A message sent from Proxy to the browser message ForwardMsg { @@ -50,7 +49,6 @@ message ForwardMsg { PageInfo page_info_changed = 12; PageConfig page_config_changed = 13; ReportFinishedStatus report_finished = 6; - GitInfo git_info_changed = 14; // Upload progress messages. @@ -77,7 +75,7 @@ message ForwardMsg { string ref_hash = 11; } - // Next: 15 + // Next: 14 } // ForwardMsgMetadata contains all data that does _not_ get hashed (or cached) @@ -104,4 +102,4 @@ message ElementDimensionSpec { // height in CSS points uint32 height = 2; -} \ No newline at end of file +} diff --git a/proto/streamlit/proto/GitInfo.proto b/proto/streamlit/proto/GitInfo.proto deleted file mode 100644 index 26ad3a09602e..000000000000 --- a/proto/streamlit/proto/GitInfo.proto +++ /dev/null @@ -1,34 +0,0 @@ -/** -* Copyright 2018-2020 Streamlit Inc. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -syntax = "proto3"; - -// Message used to update page metadata. -message GitInfo { - string repository = 1; - string branch = 2; - string module = 3; - repeated string untracked_files = 4; - repeated string uncommitted_files = 5; - - enum GitStates { - DEFAULT = 0; - HEAD_DETACHED = 1; - AHEAD_OF_REMOTE = 2; - } - - GitStates state = 6; -} \ No newline at end of file diff --git a/proto/streamlit/proto/NewReport.proto b/proto/streamlit/proto/NewReport.proto index 75eb0b43cd84..78033e1f0050 100644 --- a/proto/streamlit/proto/NewReport.proto +++ b/proto/streamlit/proto/NewReport.proto @@ -36,10 +36,7 @@ message NewReport { // "/foo/bar/foo.py" string script_path = 4; - // DEPRECATED. - // DeployParams deploy_params = 5; - - reserved 5; + DeployParams deploy_params = 5; } // Contains Streamlit configuration data, and the session state that existed @@ -101,3 +98,11 @@ message EnvironmentInfo { string streamlit_version = 1; string python_version = 2; } + +// Data about the git repository this app is deployed from (if any). +// Does not change over the app's lifetime. +message DeployParams { + string repository = 1; + string branch = 2; + string module = 3; +}