From c751d1fb9956f6c7fcff6ab746ae2b7d5e65041e Mon Sep 17 00:00:00 2001 From: Alex Atallah Date: Mon, 5 Feb 2024 20:36:25 -0500 Subject: [PATCH] Make model downloading synchronous again (#66) --- modal/runner/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modal/runner/__init__.py b/modal/runner/__init__.py index 953a65b..cc9220f 100644 --- a/modal/runner/__init__.py +++ b/modal/runner/__init__.py @@ -5,7 +5,7 @@ ) from runner.shared.clean import clean_models_volume from runner.shared.common import stub -from runner.shared.download import download_model +from runner.shared.download import download_model, downloader_image from shared.images import BASE_IMAGE from shared.logging import get_logger, get_observability_secrets from shared.volumes import models_path, models_volume @@ -31,18 +31,20 @@ def completion(): # named for backwards compatibility with the Modal URL @stub.function( - image=BASE_IMAGE, + image=downloader_image, timeout=3600, # 1 hour + volumes={models_path: models_volume}, secrets=[ + Secret.from_name("huggingface"), *get_observability_secrets(), ], ) -def download(): +def download(force: bool = False): logger = get_logger("download") logger.info("Downloading all models...") - results = list(download_model.map(DEFAULT_CONTAINER_TYPES.keys())) - if not results: - raise Exception("Failed to perform remote calls") + for model in DEFAULT_CONTAINER_TYPES: + # Can't be parallelized because of a modal volume corruption issue + download_model.local(model, force=force) logger.info("ALL DONE!")