-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodal_app.py
44 lines (35 loc) · 1.16 KB
/
modal_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from modal import Image, Secret, Stub, wsgi_app
image = (
Image.debian_slim(python_version="3.11")
.apt_install("ffmpeg")
.pip_install_from_requirements("requirements.txt")
.copy_local_dir('staticfiles', '/root/staticfiles')
.copy_local_dir('todoApp', '/root/todoApp')
.copy_local_dir('todos', '/root/todos')
.copy_local_file('manage.py', '/root/manage.py')
.run_commands(
"python /root/manage.py migrate",
secrets=[Secret.from_name("surukoto-secret")],
)
)
with image.imports():
import whisper
whisper.load_model("medium.en")
stub = Stub(name="surukoto", image=image)
@stub.function(
secret=Secret.from_name("surukoto-secret"),
gpu="T4",
concurrency_limit=1,
container_idle_timeout=300,
)
@wsgi_app()
def run():
from todoApp.wsgi import application
from todos.models import Todo
from django.db import transaction
with transaction.atomic():
Todo.objects.create(title="Visit grandma")
Todo.objects.create(title="Call mom")
Todo.objects.create(title="Walk the dog")
return application