MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / download_file

Function download_file

smallthinker/tools/server/tests/utils.py:537–553  ·  view source on GitHub ↗

Download a file from a URL to a local path. If the file already exists, it will not be downloaded again. output_file_path is the local path to save the downloaded file. If not provided, the file will be saved in the root directory. Returns the local path of the downloaded file.

(url: str, output_file_path: str | None = None)

Source from the content-addressed store, hash-verified

535
536
537def download_file(url: str, output_file_path: str | None = None) -> str:
538 """
539 Download a file from a URL to a local path. If the file already exists, it will not be downloaded again.
540
541 output_file_path is the local path to save the downloaded file. If not provided, the file will be saved in the root directory.
542
543 Returns the local path of the downloaded file.
544 """
545 file_name = url.split('/').pop()
546 output_file = f'./tmp/{file_name}' if output_file_path is None else output_file_path
547 if not os.path.exists(output_file):
548 print(f"Downloading {url} to {output_file}")
549 wget.download(url, out=output_file)
550 print(f"Done downloading to {output_file}")
551 else:
552 print(f"File already exists at {output_file}")
553 return output_file
554
555
556def is_slow_test_allowed():

Callers 3

create_serverFunction · 0.85
create_serverFunction · 0.85
test_with_big_modelFunction · 0.85

Calls 3

downloadMethod · 0.80
printFunction · 0.50
popMethod · 0.45

Tested by 3

create_serverFunction · 0.68
create_serverFunction · 0.68
test_with_big_modelFunction · 0.68