diff --git a/week8/day1.ipynb b/week8/day1.ipynb index d59e021..6b89a75 100644 --- a/week8/day1.ipynb +++ b/week8/day1.ipynb @@ -241,6 +241,14 @@ "\n", "You can also build REST endpoints easily, although we won't cover that as we'll be calling direct from Python.\n", "\n", + "## Important note about secrets\n", + "\n", + "In both the files `pricer_service.py` and `pricer_service2.py` you will find code like this near the top: \n", + "`secrets = [modal.Secret.from_name(\"hf-secret\")]` \n", + "You may need to change from `hf-secret` to `huggingface-secret` depending on how the Secret is configured in modal. \n", + "To check, visit this page and look in the first column: \n", + "https://modal.com/secrets/\n", + "\n", "## Important note for Windows people:\n", "\n", "On the next line, I call `modal deploy` from within Jupyter lab; I've heard that on some versions of Windows this gives a strange unicode error because modal prints emojis to the output which can't be displayed. If that happens to you, simply use an Anaconda Prompt window or a Powershell instead, with your environment activated, and type `modal deploy pricer_service` there. Follow the same approach the next time we do `!modal deploy` too.\n", diff --git a/week8/pricer_service.py b/week8/pricer_service.py index 088b962..3796e12 100644 --- a/week8/pricer_service.py +++ b/week8/pricer_service.py @@ -5,6 +5,9 @@ from modal import App, Image app = modal.App("pricer-service") image = Image.debian_slim().pip_install("torch", "transformers", "bitsandbytes", "accelerate", "peft") + +# This collects the secret from Modal. +# Depending on your Modal configuration, you may need to replace "hf-secret" with "huggingface-secret" secrets = [modal.Secret.from_name("hf-secret")] # Constants diff --git a/week8/pricer_service2.py b/week8/pricer_service2.py index babe318..e1b6b22 100644 --- a/week8/pricer_service2.py +++ b/week8/pricer_service2.py @@ -4,6 +4,9 @@ from modal import App, Volume, Image app = modal.App("pricer-service") image = Image.debian_slim().pip_install("huggingface", "torch", "transformers", "bitsandbytes", "accelerate", "peft") + +# This collects the secret from Modal. +# Depending on your Modal configuration, you may need to replace "hf-secret" with "huggingface-secret" secrets = [modal.Secret.from_name("hf-secret")] # Constants @@ -15,7 +18,10 @@ RUN_NAME = "2024-09-13_13.04.39" PROJECT_RUN_NAME = f"{PROJECT_NAME}-{RUN_NAME}" REVISION = "e8d637df551603dc86cd7a1598a8f44af4d7ae36" FINETUNED_MODEL = f"{HF_USER}/{PROJECT_RUN_NAME}" -CACHE_DIR = "/cache" +CACHE_DIR = "/cache" + +# Change this to 1 if you want Modal to be always running, otherwise it will go cold after 2 mins +MIN_CONTAINERS = 0 QUESTION = "How much does this cost to the nearest dollar?" PREFIX = "Price is $" @@ -27,6 +33,7 @@ hf_cache_volume = Volume.from_name("hf-hub-cache", create_if_missing=True) secrets=secrets, gpu=GPU, timeout=1800, + min_containers=MIN_CONTAINERS, volumes={CACHE_DIR: hf_cache_volume} ) class Pricer: @@ -74,8 +81,4 @@ class Pricer: contents = result.split("Price is $")[1] contents = contents.replace(',','') match = re.search(r"[-+]?\d*\.\d+|\d+", contents) - return float(match.group()) if match else 0 - - @modal.method() - def wake_up(self) -> str: - return "ok" \ No newline at end of file + return float(match.group()) if match else 0 \ No newline at end of file