streamlit's webserver not working when using BAZEL for installation bug

Open
#4,576 8 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start with the streamlit_main.py and BUILD.bazel reproduction, then locate the development-mode check described in the issue. Run "bazel build streamlit_main" and verify that the resulting application does not run in development mode without the workaround; the issue does not name the implementation file or a test.

Written by the indexing model from the issue text.

Description

area:deployment type:enhancement
Summary

Related to https://github.com/streamlit/streamlit/issues/3132 .

An internal check to see if streamlit is running in development mode or not. This checks if some strings are present in the script's file path. This check is not valid for other installation types, e.g. bazel.

The script path in a bazel build is for example:
/home/{user}/.cache/bazel/_bazel_{user}/b775940771a888524b9eed82a7f43708/execroot/{organization}/bazel-out/k8-fastbuild/bin/apps/daq/streamlit_main.runfiles/pip_deps_pypi__streamlit/streamlit/hello/hello.py

This could be solved by also checking for "pip_deps_pypi__streamlit" in the development_mode check, or by just having a better check in general.

Steps to reproduce

Code snippet:

streamlit_main.py

import sys
from streamlit import cli as stcli

if __name__ == '__main__':
    sys.argv = ["streamlit", "hello"]
    sys.exit(stcli.main())

BUILD.bazel

load("@rules_python//python:defs.bzl", "py_binary")

py_binary(
    name = "streamlit_main",
    srcs = [
        "streamlit_main.py",
    ],
    main = "streamlit_main.py",
    visibility = ["//visibility:public"],
    deps = [
        requirement('streamlit')
    ],
)

If applicable, please provide the steps we should take to reproduce the bug:

run "bazel build streamlit_main"

Expected behavior:

To not run in development mode;

Actual behavior:

Runs in development mode.

Is this a regression?

no

Debug info
  • Streamlit version: 1.8.1
  • Python version: 3.7
  • Using Conda? PipEnv? PyEnv? Pex? BAZEL
  • OS version: Ubuntu 20.04
  • Browser version:
Additional information

Workaround: explicitly set developmentMode to false:

import sys
from streamlit import cli as stcli

if __name__ == '__main__':
    sys.argv = ["streamlit", "hello", "--global.developmentMode", "0"]
    sys.exit(stcli.main())

Dominant language
Python
Stars
45.8k
Forks
4.4k
Avg merge
21h 22m
Merged PRs (30d)
316

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from streamlit/streamlit

All issues in streamlit/streamlit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.