Skip to content

Fix for "streamlit run" - when no file extension is provided#2115

Merged
tconkling merged 1 commit intostreamlit:developfrom
abhinand5:develop
Oct 7, 2020
Merged

Fix for "streamlit run" - when no file extension is provided#2115
tconkling merged 1 commit intostreamlit:developfrom
abhinand5:develop

Conversation

@abhinand5
Copy link
Copy Markdown
Contributor

Fixes #2107

What was the issue?

When the streamlit run command is executed with a filename that does not have an extension the error message shown on the CLI was incorrect as discussed in the Issue thread #2107

The fix

Problem was in the cli.py file where the run command is defined. In lines 206 to 210 where the extension is checked.

When only the filename is provided without extension, checking only the extension[1:] not in ACCEPTED_FILE_EXTENSIONS will result in an empty string because of the output from os.path.splitext returns empty string for the extension when none is provided. This behaviour is illustrated in the image below,

image

This results in this weird error message "Streamlit requires raw Python (.py) files, not ." which does not make sense and might confuse some absolute beginners.

The fix was to add another statement to check if there is an extension provided and display a proper error message when not.

@abhinand5 abhinand5 requested a review from a team October 7, 2020 18:31
@nthmost
Copy link
Copy Markdown
Contributor

nthmost commented Oct 7, 2020

I agree with @randyzwitch that this is an obvious win. Marking "approve" on the basis that it fixes a known community pain point; we still need 1 more Core approver to make it official.

@tconkling
Copy link
Copy Markdown
Contributor

Looks great - thanks @abhinand5!

@tconkling tconkling merged commit 354bb25 into streamlit:develop Oct 7, 2020
@abhinand5
Copy link
Copy Markdown
Contributor Author

Thanks 😃 @treuille @nthmost @randyzwitch

tconkling added a commit to tconkling/streamlit that referenced this pull request Oct 12, 2020
# By karrie (7) and others
# Via GitHub
* develop:
  Removing cache option from main menu if s4a (streamlit#2149)
  Fix empty deploy page (streamlit#2148)
  Don't wait for unit tests before starting Cypress (streamlit#2142)
  Fix formatting of st.file_uploader docstring (streamlit#2141)
  Fix broken link in 0.68 changelog (streamlit#2144)
  Fix useEffect warning (streamlit#2137)
  Add global GTM container (streamlit#2128)
  Allow Streamlit server to handle Range Requests (streamlit#1967)
  rename hosted to hostedAt (streamlit#2132)
  Update change log
  Update notices
  Up version to 0.68.0
  Rename hosted to hostedAt in tracking data (streamlit#2132)
  Inject tracking data (streamlit#2110)
  [Feature Branch] File uploader (streamlit#2130)
  links for docs (streamlit#2129)
  Upgrade ProtobufJS and fix build script (streamlit#2118)
  Refresh landing page (streamlit#2116)
  Improve docstrings + tutorials for Layout (streamlit#2117)
  Better 'streamlit run' error message when no extension provided (streamlit#2115)

# Conflicts:
#	frontend/src/components/elements/Video/Video.tsx
#	frontend/src/components/widgets/FileUploader/FileUploader.test.tsx
#	frontend/src/components/widgets/FileUploader/FileUploader.tsx
#	frontend/src/lib/utils.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When "streamlit run" file doesn't exit and has no extension, error printout is weird

3 participants