🚸 Show Top-3 files larger than threshold on deploy command#190
🚸 Show Top-3 files larger than threshold on deploy command#190YuriiMotov wants to merge 9 commits intomainfrom
deploy command#190Conversation
| toolkit.print(f" [dim]...and {len(large_files) - 3} more[/dim]") | ||
|
|
||
| large_files_docs_url = ( | ||
| "https://fastapicloud.com/docs/deployment#control-what-is-uploaded" |
There was a problem hiding this comment.
This page doesn't exist yet. We will need to create it first and update the link here.
There was a problem hiding this comment.
Pull request overview
Adds a deploy-time warning to help users identify unexpectedly large files in the app directory before upload, showing the top 3 largest files above a configurable threshold.
Changes:
- Introduces
_get_large_files()and a shared_rignore_walk()wrapper to scan the deploy directory using existing ignore rules. - Adds
--large-file-thresholdoption todeployand prints a warning listing the top-3 largest files above the threshold (plus a “...and N more” indicator). - Adds unit tests for
_get_large_files()and CLI-level tests validating the warning output.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/fastapi_cloud_cli/commands/deploy.py |
Adds large-file detection, new CLI option, and warning output during deploy. |
tests/test_deploy_utils.py |
Adds unit tests for _get_large_files() behavior and ignore handling. |
tests/test_cli_deploy.py |
Adds integration-style tests for deploy output: warning, top-3 behavior, and custom threshold. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fsize_mb = fsize // (1024 * 1024) | ||
| toolkit.print(f" • {fname} [yellow]({fsize_mb} MB)[/yellow]") |
There was a problem hiding this comment.
_format_size rounds the value, so 10 MB + 1 byte will be printed as 10.00 MB. It will also be confusing.
I think it's fine as it is
| large_files = _get_large_files(app_path, threshold_mb=large_file_threshold) | ||
| if large_files: | ||
| toolkit.print( | ||
| f"⚠️ Some uploaded files are larger than {large_file_threshold} MB ⚖️ :", | ||
| tag="warning", |
There was a problem hiding this comment.
I think this additional directory traversal will not add big overhead.
Alternative is to embed this into archive function, but, IMO, the code will be less clear
deploy commanddeploy command
Show Top-3 largest files (larger than configurable threshold) when there are large files in project directory.
The page in docs could describe the intention of this warning and the way to configure custom threshold.
We may also want to ignore this warning for specified files only (ignore not by size threshold, but by file name), so that it would allow having large file (for example, LLM-model), but still warn on other large files