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

updates examples to use new queue and nfs methods, closes #659 #661

Merged
merged 1 commit into from
Mar 21, 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
5 changes: 4 additions & 1 deletion 06_gpu_and_ml/stable_diffusion/a1111_webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
from modal import Image, Queue, Stub, forward

stub = Stub("example-a1111-webui")
stub.urls = Queue.new() # TODO: FunctionCall.get() doesn't support generators.
stub.urls = Queue.from_name(
"a1111-webui-example", create_if_missing=True
) # TODO: FunctionCall.get() doesn't support generators.


def wait_for_port(port: int):
Expand Down Expand Up @@ -57,6 +59,7 @@ def wait_for_port(port: int):
.run_commands(
"cd /webui && . venv/bin/activate && "
+ "python -c 'from modules import shared_init, initialize; shared_init.initialize(); initialize.initialize()'",
gpu="a10g",
),
gpu="a10g",
cpu=2,
Expand Down
10 changes: 6 additions & 4 deletions 06_gpu_and_ml/stable_diffusion/stable_video_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import modal

stub = modal.Stub(name="example-stable-video-diffusion-streamlit")
stub.q = modal.Queue.new()
q = modal.Queue.from_name(
"stable-video-diffusion-streamlit", create_if_missing=True
)

session_timeout = 15 * 60

Expand Down Expand Up @@ -68,13 +70,13 @@ def run_streamlit(publish_url: bool = False):
with modal.forward(8501) as tunnel:
# Reload Streamlit config with information about Modal tunnel address.
if publish_url:
stub.q.put(tunnel.url)
q.put(tunnel.url)
load_config_options(
{"browser.serverAddress": tunnel.host, "browser.serverPort": 443}
)
run(
main_script_path="/sgm/scripts/demo/video_sampling.py",
command_line=None,
is_hello=False,
args=["--timeout", str(session_timeout)],
flag_options={},
)
Expand All @@ -86,5 +88,5 @@ def share():
from fastapi.responses import RedirectResponse

run_streamlit.spawn(publish_url=True)
url = stub.q.get()
url = q.get()
return RedirectResponse(url, status_code=303)
2 changes: 1 addition & 1 deletion 06_gpu_and_ml/tensorflow/tensorflow_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# We want to run the web server for TensorBoard at the same time as we are training the TensorFlow model.
# The easiest way to do this is to set up a shared filesystem between the training and the web server.

fs = NetworkFileSystem.new()
fs = NetworkFileSystem.from_name("tensorflow-tutorial", create_if_missing=True)
logdir = "/tensorboard"

# ## Training function
Expand Down
2 changes: 1 addition & 1 deletion 11_notebooks/jupyter_inside_modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
)
# This volume is not persisted, so the data will be deleted when this demo app is stopped.
volume = modal.NetworkFileSystem.new()
volume = modal.NetworkFileSystem.ephemeral()

CACHE_DIR = "/root/cache"
JUPYTER_TOKEN = "1234" # Change me to something non-guessable!
Expand Down
6 changes: 3 additions & 3 deletions misc/queue_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import modal.queue

stub = modal.Stub("example-queue-simple")
stub.q = modal.Queue.new()
q = modal.Queue.ephemeral()


@stub.function()
Expand Down Expand Up @@ -51,8 +51,8 @@ async def many_consumers(q: modal.Queue) -> None:

async def main():
with stub.run():
await run_async.remote.aio(stub.q)
await many_consumers.remote.aio(stub.q)
await run_async.remote.aio(q)
await many_consumers.remote.aio(q)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.pytest.ini_options]
filterwarnings = [
"ignore::DeprecationWarning",
"ignore::modal.exception.DeprecationError",
"error::DeprecationWarning",
"error::modal.exception.DeprecationError",
"ignore::DeprecationWarning:pytest.*:",
]
pythonpath = ["06_gpu_and_ml/spam-detect", "06_gpu_and_ml/text-to-pokemon"]
Expand Down
Loading