Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor text fixes following removal of mounts #1021

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 06_gpu_and_ml/dreambooth/diffusers_lora_finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,15 @@ class AppConfig(SharedConfig):
guidance_scale: float = 6


image_with_assets = image.add_local_dir(
web_image = image.add_local_dir(
# Add local web assets to the image
Path(__file__).parent / "assets",
remote_path="/assets",
)


@app.function(
image=image_with_assets,
image=web_image,
concurrency_limit=1,
allow_concurrent_inputs=1000,
)
Expand Down
10 changes: 7 additions & 3 deletions 06_gpu_and_ml/hyperparameter-sweep/hp_sweep_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@
"torch==2.1.2",
"tensorboard==2.17.1",
"numpy<2",
).add_local_dir(Path(__file__).parent / "src", remote_path="/root/src")
)

# We also have some local dependencies that we'll need to import into the remote environment.
# We mount them onto the remote container.
# We add them into the remote container.

torch_image = torch_image.add_local_dir(
Path(__file__).parent / "src", remote_path="/root/src"
)

# We'll serve a simple web endpoint
# We'll serve a simple web endpoint:
web_image = base_image.pip_install(
"fastapi[standard]==0.115.4", "starlette==0.41.2"
)
Expand Down
9 changes: 3 additions & 6 deletions 06_gpu_and_ml/obj_detection_webcam/webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@
from transformers import DetrForObjectDetection, DetrImageProcessor


@app.cls(
cpu=4,
image=image,
)
@app.cls(image=image)
class ObjectDetection:
@modal.build()
def download_model(self):
Expand Down Expand Up @@ -168,8 +165,8 @@ def detect(self, img_data_in):


@app.function(
image=modal.Image.debian_slim()
.pip_install("fastapi[standard]")
image=modal.Image.debian_slim(python_version="3.12")
.pip_install("fastapi[standard]==0.115.4")
.add_local_dir(static_path, remote_path="/assets")
)
@modal.asgi_app(label="example-webcam-object-detection")
Expand Down
20 changes: 10 additions & 10 deletions 09_job_queues/doc_ocr_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# ## Basic setup

# Let's get the imports out of the way and define a [`App`](https://modal.com/docs/reference/modal.App).
# Let's get the imports out of the way and define an [`App`](https://modal.com/docs/reference/modal.App).

from pathlib import Path

Expand Down Expand Up @@ -75,26 +75,26 @@ async def poll_results(call_id: str):
return result


# Specify a container image containing the version of fastapi we want to use to serve
# our web app
fast_api_image = modal.Image.debian_slim(python_version="3.12").pip_install(
# Now that we've defined our endpoints, we're ready to host them on Modal.
# First, we specify our dependencies -- here, a basic Debian Linux
# environment with FastAPI installed.

image = modal.Image.debian_slim(python_version="3.12").pip_install(
"fastapi[standard]==0.115.4"
)

# Finally, we add the static files for our front-end. We've made [a simple React
# Then, we add the static files for our front-end. We've made [a simple React
# app](https://github.com/modal-labs/modal-examples/tree/main/09_job_queues/doc_ocr_frontend)
# that hits the two endpoints defined above. To package these files with our app, we use
# add_local_dir with the local directory of the assets, and specify that we want them
# `add_local_dir` with the local directory of the assets, and specify that we want them
# in the `/assets` directory inside our container (the `remote_path`). Then, we instruct FastAPI to [serve
# this static file directory](https://fastapi.tiangolo.com/tutorial/static-files/) at our root path.

local_assets_path = Path(__file__).parent / "doc_ocr_frontend"
ocr_app_image = fast_api_image.add_local_dir(
local_assets_path, remote_path="/assets"
)
image = image.add_local_dir(local_assets_path, remote_path="/assets")


@app.function(image=ocr_app_image)
@app.function(image=image)
@modal.asgi_app()
def wrapper():
web_app.mount(
Expand Down
2 changes: 1 addition & 1 deletion 10_integrations/streamlit/serve_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# ## Define container dependencies

# The `app.py` script imports three third-party packages, so we include these in the example's
# image definition and then add the app.py file itself to the image.
# image definition and then add the `app.py` file itself to the image.

streamlit_script_local_path = Path(__file__).parent / "app.py"
streamlit_script_remote_path = "/root/app.py"
Expand Down