@@ -138,14 +138,15 @@ def archive(path: Path, tar_path: Path) -> Path:
138138 return tar_path
139139
140140
141- def _get_large_files (path : Path , threshold : int ) -> list [tuple [Path , int ]]:
141+ def _get_large_files (path : Path , threshold_mb : int ) -> list [tuple [Path , int ]]:
142+ threshold_bytes = threshold_mb * 1024 * 1024
142143 large_files = []
143144 files = _rignore_walk (path )
144145 for filename in files :
145146 if filename .is_dir ():
146147 continue
147148 file_size = filename .stat ().st_size
148- if file_size >= threshold :
149+ if file_size >= threshold_bytes :
149150 large_files .append ((filename .relative_to (path ), file_size ))
150151
151152 return large_files
@@ -696,6 +697,10 @@ def deploy(
696697 envvar = "FASTAPI_CLOUD_APP_ID" ,
697698 ),
698699 ] = None ,
700+ large_file_threshold : Annotated [
701+ int ,
702+ typer .Option (help = "File size threshold in MB for warning about large files" ),
703+ ] = 10 , # 10 MB
699704) -> Any :
700705 """
701706 Deploy a [bold]FastAPI[/bold] app to FastAPI Cloud. 🚀
@@ -821,14 +826,12 @@ def deploy(
821826 )
822827 raise typer .Exit (1 )
823828
824- large_file_threshold = 10 * 1024 * 1024 # 10 MB
825829 app_path = path or Path .cwd ()
826830
827- large_files = _get_large_files (app_path , threshold = large_file_threshold )
831+ large_files = _get_large_files (app_path , threshold_mb = large_file_threshold )
828832 if large_files :
829- threshold_mb = large_file_threshold // (1024 * 1024 )
830833 toolkit .print (
831- f"⚠️ Some uploaded files are larger than { threshold_mb } MB ⚖️ :" ,
834+ f"⚠️ Some uploaded files are larger than { large_file_threshold } MB ⚖️ :" ,
832835 tag = "warning" ,
833836 )
834837 top_3 = sorted (large_files , key = lambda x : x [1 ], reverse = True )[:3 ]
@@ -839,7 +842,9 @@ def deploy(
839842 if is_more :
840843 toolkit .print (f" [dim]...and { len (large_files ) - 3 } more[/dim]" )
841844
842- large_files_docs_url = "https://fastapicloud.com/docs/deployment#control-what-is-uploaded"
845+ large_files_docs_url = (
846+ "https://fastapicloud.com/docs/deployment#control-what-is-uploaded"
847+ )
843848 toolkit .print (
844849 f"Read more: [link={ large_files_docs_url } ]{ large_files_docs_url } [/link]" ,
845850 tag = "tip" ,
0 commit comments