This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Proof-of-concept for NAT traversal and low-latency communication over QUIC | |
between two Modal containers. | |
In theory this could be used to establish a low-latency p2p connection between a | |
service running outside Modal and a Modal GPU container, e.g. for real-time | |
inference on a video stream. Please let us know if you try it! | |
Usage: | |
> modal run modal_quic_hole_punch.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import secrets | |
import subprocess | |
import time | |
import modal | |
app = modal.App() | |
image = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from modal import Image, Secret, Stub, enter, exit, method | |
app_name = "modal-datadog-demo" | |
DD_ENV = Secret.from_dict( | |
{ | |
"DD_SITE": "datadoghq.com", | |
"DD_ENV": "prod", | |
"DD_SERVICE": app_name, | |
"DD_LOGS_ENABLED": "true", | |
"DD_TRACE_ENABLED": "true", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import tempfile | |
from typing import Optional | |
from pydantic import BaseModel | |
from modal import Image, Secret, Stub, build, enter, gpu, web_endpoint | |
whisper_image = ( | |
Image.micromamba() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import modal | |
from fastapi import Depends, HTTPException, status | |
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials | |
auth_scheme = HTTPBearer() | |
stub = modal.Stub( | |
"example-web-badges", | |
image=modal.Image.debian_slim().pip_install("pybadges", "pypistats"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quick snippet to connect to a Jupyter notebook server running inside a Modal container, | |
# especially useful for exploring the contents of Modal shared volumes. | |
# This uses https://github.com/ekzhang/bore to expose the server to the public internet. | |
# | |
# Steps | |
# ----- | |
# 1. (Recommended) Change `JUPYTER_TOKEN` to a different value; default is 1234. | |
# 2. `modal run jupyter-bore.py` | |
# 3. Find the `bore.pub` URL printed in the logs, and navigate to it using your browser. |