Skip to content

Commit

Permalink
Make model downloading synchronous again (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderatallah committed Feb 6, 2024
1 parent 513d934 commit c751d1f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modal/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!")


Expand Down

0 comments on commit c751d1f

Please sign in to comment.