From 248ee999b9cb97ae9f8d1bfb20ff67cc6a70ef2a Mon Sep 17 00:00:00 2001 From: Charles Frye Date: Wed, 4 Dec 2024 05:18:52 +0000 Subject: [PATCH] switch default environment for examples in CI to 'examples' --- .github/workflows/run-examples.yml | 2 +- 04_secrets/db_to_sheet.py | 1 + 06_gpu_and_ml/dreambooth/diffusers_lora_finetune.py | 1 + 06_gpu_and_ml/embeddings/text_embeddings_inference.py | 1 + 06_gpu_and_ml/langchains/potus_speech_qanda.py | 3 ++- 06_gpu_and_ml/llm-serving/download_llama.py | 2 ++ 06_gpu_and_ml/llm-serving/vllm_inference.py | 1 + 06_gpu_and_ml/llm-structured/instructor_generate.py | 1 + 06_gpu_and_ml/yolo/finetune_yolo.py | 1 + 10_integrations/algolia_indexer.py | 1 + 10_integrations/cloud_bucket_mount_loras.py | 1 + 10_integrations/dbt/dbt_duckdb.py | 1 + 10_integrations/s3_bucket_mount.py | 1 + 10_integrations/webscraper.py | 4 ++++ 12_datasets/laion400.py | 6 +++++- 13_sandboxes/codelangchain/agent.py | 2 +- 13_sandboxes/codelangchain/langserve.py | 1 + 17 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-examples.yml b/.github/workflows/run-examples.yml index bf27d0adb..9bab570ba 100644 --- a/.github/workflows/run-examples.yml +++ b/.github/workflows/run-examples.yml @@ -23,7 +23,7 @@ env: TERMINFO: /etc/terminfo MODAL_TOKEN_ID: ${{ secrets.MODAL_MODAL_LABS_TOKEN_ID }} MODAL_TOKEN_SECRET: ${{ secrets.MODAL_MODAL_LABS_TOKEN_SECRET }} - MODAL_ENVIRONMENT: main + MODAL_ENVIRONMENT: examples jobs: # Output all changed files in a JSON format compatible with GitHub Actions job matrices diff --git a/04_secrets/db_to_sheet.py b/04_secrets/db_to_sheet.py index f895ce788..d1dff63fe 100644 --- a/04_secrets/db_to_sheet.py +++ b/04_secrets/db_to_sheet.py @@ -1,5 +1,6 @@ # --- # deploy: true +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Write to Google Sheets from Postgres diff --git a/06_gpu_and_ml/dreambooth/diffusers_lora_finetune.py b/06_gpu_and_ml/dreambooth/diffusers_lora_finetune.py index aa3f7b8bb..b589c0977 100644 --- a/06_gpu_and_ml/dreambooth/diffusers_lora_finetune.py +++ b/06_gpu_and_ml/dreambooth/diffusers_lora_finetune.py @@ -1,5 +1,6 @@ # --- # deploy: true +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Create a character LoRA for Flux with Hugging Face and Gradio diff --git a/06_gpu_and_ml/embeddings/text_embeddings_inference.py b/06_gpu_and_ml/embeddings/text_embeddings_inference.py index de21bb76d..02bb1ca2d 100644 --- a/06_gpu_and_ml/embeddings/text_embeddings_inference.py +++ b/06_gpu_and_ml/embeddings/text_embeddings_inference.py @@ -1,5 +1,6 @@ # --- # cmd: ["modal", "run", "06_gpu_and_ml/embeddings/text_embeddings_inference.py::embed_dataset"] +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Run TextEmbeddingsInference (TEI) on Modal diff --git a/06_gpu_and_ml/langchains/potus_speech_qanda.py b/06_gpu_and_ml/langchains/potus_speech_qanda.py index d028c3969..38d6eed95 100644 --- a/06_gpu_and_ml/langchains/potus_speech_qanda.py +++ b/06_gpu_and_ml/langchains/potus_speech_qanda.py @@ -1,6 +1,7 @@ # --- -# deploy: true # args: ["--query", "How many oil barrels were released from reserves?"] +# deploy: true +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Retrieval-augmented generation (RAG) for question-answering with LangChain diff --git a/06_gpu_and_ml/llm-serving/download_llama.py b/06_gpu_and_ml/llm-serving/download_llama.py index 06e145056..c7da2cc4d 100644 --- a/06_gpu_and_ml/llm-serving/download_llama.py +++ b/06_gpu_and_ml/llm-serving/download_llama.py @@ -1,6 +1,8 @@ # --- # args: ["--force-download"] +# env: {"MODAL_ENVIRONMENT": "main"} # --- + import modal MODELS_DIR = "/llamas" diff --git a/06_gpu_and_ml/llm-serving/vllm_inference.py b/06_gpu_and_ml/llm-serving/vllm_inference.py index b4672c269..54ed82b8f 100644 --- a/06_gpu_and_ml/llm-serving/vllm_inference.py +++ b/06_gpu_and_ml/llm-serving/vllm_inference.py @@ -1,6 +1,7 @@ # --- # cmd: ["modal", "serve", "06_gpu_and_ml/llm-serving/vllm_inference.py"] # pytest: false +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Run OpenAI-compatible LLM inference with LLaMA 3.1-8B and vLLM diff --git a/06_gpu_and_ml/llm-structured/instructor_generate.py b/06_gpu_and_ml/llm-structured/instructor_generate.py index ca2a4b31c..3d5d3ef74 100644 --- a/06_gpu_and_ml/llm-structured/instructor_generate.py +++ b/06_gpu_and_ml/llm-structured/instructor_generate.py @@ -1,5 +1,6 @@ # --- # output-directory: "/tmp/instructor_generate" +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Structured Data Extraction using `instructor` diff --git a/06_gpu_and_ml/yolo/finetune_yolo.py b/06_gpu_and_ml/yolo/finetune_yolo.py index 8c6ee2d2c..95e28ebe2 100644 --- a/06_gpu_and_ml/yolo/finetune_yolo.py +++ b/06_gpu_and_ml/yolo/finetune_yolo.py @@ -1,5 +1,6 @@ # --- # args: ["--no-quick-check"] +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Fine-tune open source YOLO models for object detection diff --git a/10_integrations/algolia_indexer.py b/10_integrations/algolia_indexer.py index c46ceaf5a..ba5c8b74e 100644 --- a/10_integrations/algolia_indexer.py +++ b/10_integrations/algolia_indexer.py @@ -1,5 +1,6 @@ # --- # deploy: true +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Algolia docsearch crawler # diff --git a/10_integrations/cloud_bucket_mount_loras.py b/10_integrations/cloud_bucket_mount_loras.py index 333d03254..f156fceaf 100644 --- a/10_integrations/cloud_bucket_mount_loras.py +++ b/10_integrations/cloud_bucket_mount_loras.py @@ -1,6 +1,7 @@ # --- # output-directory: "/tmp/stable-diffusion-xl" # deploy: true +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # LoRAs Galore: Create a LoRA Playground with Modal, Gradio, and S3 diff --git a/10_integrations/dbt/dbt_duckdb.py b/10_integrations/dbt/dbt_duckdb.py index 5292c33b3..ea9537e8e 100644 --- a/10_integrations/dbt/dbt_duckdb.py +++ b/10_integrations/dbt/dbt_duckdb.py @@ -1,5 +1,6 @@ # --- # deploy: true +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Build your own data warehouse with DuckDB, DBT, and Modal diff --git a/10_integrations/s3_bucket_mount.py b/10_integrations/s3_bucket_mount.py index e49316531..cd28ad28c 100644 --- a/10_integrations/s3_bucket_mount.py +++ b/10_integrations/s3_bucket_mount.py @@ -1,5 +1,6 @@ # --- # output-directory: "/tmp/s3_bucket_mount" +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Analyze NYC yellow taxi data with DuckDB on Parquet files from S3 diff --git a/10_integrations/webscraper.py b/10_integrations/webscraper.py index 27d64b7b4..241aaecbb 100644 --- a/10_integrations/webscraper.py +++ b/10_integrations/webscraper.py @@ -1,3 +1,7 @@ +# --- +# env: {"MODAL_ENVIRONMENT": "main"} +# --- + # # Web Scraping on Modal # This example shows how you can scrape links from a website and post them to a Slack channel using Modal. diff --git a/12_datasets/laion400.py b/12_datasets/laion400.py index 3b7fa1240..71a9ea71f 100644 --- a/12_datasets/laion400.py +++ b/12_datasets/laion400.py @@ -33,17 +33,21 @@ bucket_creds = modal.Secret.from_name( "aws-s3-modal-examples-datasets", environment_name="main" ) + bucket_name = "modal-examples-datasets" + volume = modal.CloudBucketMount( bucket_name, secret=bucket_creds, ) + image = ( modal.Image.debian_slim() .apt_install("wget") .pip_install("img2dataset~=1.45.0") ) -app = modal.App("example-laoin400-dataset-import", image=image) + +app = modal.App("example-laion400-dataset-import", image=image) def start_monitoring_disk_space(interval: int = 30) -> None: diff --git a/13_sandboxes/codelangchain/agent.py b/13_sandboxes/codelangchain/agent.py index 554ef4c00..997014564 100644 --- a/13_sandboxes/codelangchain/agent.py +++ b/13_sandboxes/codelangchain/agent.py @@ -1,7 +1,7 @@ # --- # cmd: ["modal", "run", "13_sandboxes.codelangchain.agent", "--question", "Use gpt2 and transformers to generate text"] # pytest: false -# env: {"MODAL_AUTOMOUNT": "True"} +# env: {"MODAL_AUTOMOUNT": "True", "MODAL_ENVIRONMENT": "main"} # --- # # Build a coding agent with Modal Sandboxes and LangGraph diff --git a/13_sandboxes/codelangchain/langserve.py b/13_sandboxes/codelangchain/langserve.py index cc7dbd2c2..88690f8dc 100644 --- a/13_sandboxes/codelangchain/langserve.py +++ b/13_sandboxes/codelangchain/langserve.py @@ -1,6 +1,7 @@ # --- # pytest: false # cmd: ["modal", "serve", "13_sandboxes.codelangchain.langserve"] +# env: {"MODAL_ENVIRONMENT": "main"} # --- # # Deploy LangChain and LangGraph applications with LangServe