Skip to content

Commit 3df2065

Browse files
committed
formatting fixes
1 parent 573b0a6 commit 3df2065

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

scripts/olmo2_modal_openai.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
# the weights from HuggingFace directly into a local directory when building the
3434
# container image.
3535

36+
3637
def download_model_to_image(model_dir, model_name, model_revision):
3738
from huggingface_hub import snapshot_download
3839
from transformers.utils import move_cache
@@ -46,6 +47,7 @@ def download_model_to_image(model_dir, model_name, model_revision):
4647
)
4748
move_cache()
4849

50+
4951
# ## Set up the container image
5052

5153
# Our first order of business is to define the environment our server will run in
@@ -76,7 +78,7 @@ def download_model_to_image(model_dir, model_name, model_revision):
7678
.env({"HF_HUB_ENABLE_HF_TRANSFER": "1"})
7779
.run_function(
7880
download_model_to_image,
79-
timeout=60 * MINUTES, # typically much faster but set high to be conservative
81+
timeout=60 * MINUTES, # typically much faster but set high to be conservative
8082
kwargs={
8183
"model_dir": MODEL_DIR,
8284
"model_name": MODEL_NAME,
@@ -100,14 +102,15 @@ def download_model_to_image(model_dir, model_name, model_revision):
100102
#
101103
app = modal.App(APP_NAME)
102104

105+
103106
@app.function(
104107
image=vllm_image,
105108
gpu=GPU_CONFIG,
106-
keep_warm=0, # Spin down entirely when idle
109+
keep_warm=0, # Spin down entirely when idle
107110
container_idle_timeout=5 * MINUTES,
108111
timeout=24 * HOURS,
109112
allow_concurrent_inputs=1000,
110-
secrets=[modal.Secret.from_name("example-secret-token")], # contains MODAL_TOKEN used below
113+
secrets=[modal.Secret.from_name("example-secret-token")], # contains MODAL_TOKEN used below
111114
)
112115
@modal.asgi_app()
113116
def serve():
@@ -144,7 +147,7 @@ def serve():
144147

145148
# This example uses a token defined in the Modal secret linked above,
146149
# as described here: https://modal.com/docs/guide/secrets
147-
async def is_authenticated(api_key = fastapi.Security(http_bearer)):
150+
async def is_authenticated(api_key=fastapi.Security(http_bearer)):
148151
if api_key.credentials != os.getenv("MODAL_TOKEN"):
149152
raise fastapi.HTTPException(
150153
status_code=fastapi.status.HTTP_401_UNAUTHORIZED,
@@ -167,17 +170,13 @@ async def is_authenticated(api_key = fastapi.Security(http_bearer)):
167170
enforce_eager=False, # capture the graph for faster inference, but slower cold starts (30s > 20s)
168171
)
169172

170-
engine = AsyncLLMEngine.from_engine_args(
171-
engine_args, usage_context=UsageContext.OPENAI_API_SERVER
172-
)
173+
engine = AsyncLLMEngine.from_engine_args(engine_args, usage_context=UsageContext.OPENAI_API_SERVER)
173174

174175
model_config = get_model_config(engine)
175176

176177
request_logger = RequestLogger(max_log_len=2048)
177178

178-
base_model_paths = [
179-
BaseModelPath(name=MODEL_NAME.split("/")[1], model_path=MODEL_NAME)
180-
]
179+
base_model_paths = [BaseModelPath(name=MODEL_NAME.split("/")[1], model_path=MODEL_NAME)]
181180

182181
api_server.chat = lambda s: OpenAIServingChat(
183182
engine,

0 commit comments

Comments
 (0)