This utility allows you to download large files from a bundle. It supports file suffixes like ".yml", ".yaml", and ".json". If you don't specify a `large_file_name`, it will automatically search for large files among the supported suffixes. Typical usage examples: .. code-block:: b
(bundle_path: str | None = None, large_file_name: str | None = None)
| 1976 | |
| 1977 | |
| 1978 | def download_large_files(bundle_path: str | None = None, large_file_name: str | None = None) -> None: |
| 1979 | """ |
| 1980 | This utility allows you to download large files from a bundle. It supports file suffixes like ".yml", ".yaml", and ".json". |
| 1981 | If you don't specify a `large_file_name`, it will automatically search for large files among the supported suffixes. |
| 1982 | |
| 1983 | Typical usage examples: |
| 1984 | .. code-block:: bash |
| 1985 | |
| 1986 | # Execute this module as a CLI entry to download large files from a bundle path: |
| 1987 | python -m monai.bundle download_large_files --bundle_path <bundle_path> |
| 1988 | |
| 1989 | # Execute this module as a CLI entry to download large files from the bundle path with a specified `large_file_name`: |
| 1990 | python -m monai.bundle download_large_files --bundle_path <bundle_path> --large_file_name large_files.yaml |
| 1991 | |
| 1992 | Args: |
| 1993 | bundle_path: (Optional) The path to the bundle where the files are located. Default is `os.getcwd()`. |
| 1994 | large_file_name: (Optional) The name of the large file to be downloaded. |
| 1995 | |
| 1996 | """ |
| 1997 | bundle_path = os.getcwd() if bundle_path is None else bundle_path |
| 1998 | if large_file_name is None: |
| 1999 | large_file_path = list(Path(bundle_path).glob("large_files*")) |
| 2000 | large_file_path = list(filter(lambda x: x.suffix in [".yml", ".yaml", ".json"], large_file_path)) |
| 2001 | if len(large_file_path) == 0: |
| 2002 | raise FileNotFoundError(f"Cannot find the large_files.yml/yaml/json under {bundle_path}.") |
| 2003 | |
| 2004 | parser = ConfigParser() |
| 2005 | parser.read_config(large_file_path) |
| 2006 | large_files_list = parser.get()["large_files"] |
| 2007 | for lf_data in large_files_list: |
| 2008 | lf_data["fuzzy"] = True |
| 2009 | if "hash_val" in lf_data and lf_data.get("hash_val", "") == "": |
| 2010 | lf_data.pop("hash_val") |
| 2011 | if "hash_type" in lf_data and lf_data.get("hash_type", "") == "": |
| 2012 | lf_data.pop("hash_type") |
| 2013 | lf_data["filepath"] = os.path.join(bundle_path, lf_data["path"]) |
| 2014 | lf_data.pop("path") |
| 2015 | download_url(**lf_data) |
nothing calls this directly
no test coverage detected
searching dependent graphs…