Skip to content

Instantly share code, notes, and snippets.

@aksh-at
aksh-at / modal_quic_hole_punch.py
Last active May 4, 2025 12:51
Modal QUIC NAT hole-punching
"""
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
@aksh-at
aksh-at / launch_jupyter.py
Last active June 6, 2024 17:08
Launching Jupyter on Modal programmatically
import os
import secrets
import subprocess
import time
import modal
app = modal.App()
image = (
@aksh-at
aksh-at / datadog.py
Created May 26, 2024 01:20
Modal Datadog setup
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",
@aksh-at
aksh-at / modal_fast_whisper.py
Created February 23, 2024 18:29
Insanely fast whisper on Modal
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()
@aksh-at
aksh-at / webhook_auth.py
Created February 25, 2023 00:27
Modal webhook with bearer token authentication
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"),
@aksh-at
aksh-at / jupyter-bore.py
Last active April 5, 2023 13:26
Jupyter on Modal through Bore
# 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.