-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip empty pages directory when deploying streamlit #1499
Conversation
1befdef
to
56ad4fc
Compare
if not bool(os.listdir(file)): | ||
cli_console.warning(f"Skipping empty directory: {file}") | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should add it in StageManager.put
? WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it belongs here- it's streamlit logic, not stage put logic- it's the Streamlit manager that should decide what files and dirs to put, and Stage manager should know how to handle them to put'em on stage.
@@ -57,6 +58,10 @@ def _put_streamlit_files( | |||
stage_manager = StageManager() | |||
for file in artifacts: | |||
if file.is_dir(): | |||
if not bool(os.listdir(file)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not bool(os.listdir(file)): | |
if not any(file.iterdir()): |
To avoid additional os
import
tests/streamlit/test_commands.py
Outdated
mock_get_account.return_value = "my_account" | ||
|
||
with project_directory("streamlit_empty_pages") as directory: | ||
os.makedirs(directory / "pages", exist_ok=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.makedirs(directory / "pages", exist_ok=True) | |
(directory / "pages").mkdir(parents=True, exist_ok=True) |
if not bool(os.listdir(file)): | ||
cli_console.warning(f"Skipping empty directory: {file}") | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it belongs here- it's streamlit logic, not stage put logic- it's the Streamlit manager that should decide what files and dirs to put, and Stage manager should know how to handle them to put'em on stage.
@@ -57,6 +58,10 @@ def _put_streamlit_files( | |||
stage_manager = StageManager() | |||
for file in artifacts: | |||
if file.is_dir(): | |||
if not bool(os.listdir(file)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need bool() here. Empty list evaluates as false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to any(file.iterdir())
.
56ad4fc
to
46ff5f5
Compare
46ff5f5
to
6d07d43
Compare
Pre-review checklist
Changes description
Added check in Streamlit to skip put on stage when directory is empty.