Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix: replace datetime.UTC with timezone.utc for Python 3.9+ compatibility

Leo Borcherdinga3daae1c40f2
diff --git a/studio/backend/auth/authentication.py b/studio/backend/auth/authentication.py
index 6ea668db3e0..e725834630f 100644
--- a/studio/backend/auth/authentication.py
+++ b/studio/backend/auth/authentication.py
@@ -1,5 +1,5 @@
import secrets
-from datetime import UTC, datetime, timedelta
+from datetime import datetime, timedelta, timezone
from typing import Optional
from fastapi import Depends, HTTPException, status
@@ -34,7 +34,7 @@ def create_access_token(
Tokens are valid across restarts because SECRET_KEY is stored in SQLite.
"""
to_encode = {"sub": subject}
- expire = datetime.now(UTC) + (
+ expire = datetime.now(timezone.utc) + (
expires_delta or timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
)
to_encode.update({"exp": expire})
@@ -48,7 +48,7 @@ def create_refresh_token(subject: str) -> str:
Refresh tokens are opaque (not JWTs) and expire after REFRESH_TOKEN_EXPIRE_DAYS.
"""
token = secrets.token_urlsafe(48)
- expires_at = datetime.now(UTC) + timedelta(days=REFRESH_TOKEN_EXPIRE_DAYS)
+ expires_at = datetime.now(timezone.utc) + timedelta(days=REFRESH_TOKEN_EXPIRE_DAYS)
save_refresh_token(token, subject, expires_at.isoformat())
return token
diff --git a/studio/backend/auth/storage.py b/studio/backend/auth/storage.py
index faea6266e30..e5a486bca28 100644
--- a/studio/backend/auth/storage.py
+++ b/studio/backend/auth/storage.py
@@ -3,7 +3,7 @@ SQLite storage for authentication data (user credentials + JWT secret).
"""
import hashlib
import sqlite3
-from datetime import UTC, datetime
+from datetime import datetime, timezone
from pathlib import Path
from typing import Optional, Tuple
@@ -218,7 +218,7 @@ def verify_refresh_token(token: str) -> Optional[str]:
# Clean up any expired tokens while we're here
conn.execute(
"DELETE FROM refresh_tokens WHERE expires_at < ?",
- (datetime.now(UTC).isoformat(),),
+ (datetime.now(timezone.utc).isoformat(),),
)
conn.commit()
@@ -235,7 +235,7 @@ def verify_refresh_token(token: str) -> Optional[str]:
# Check expiry
expires_at = datetime.fromisoformat(row["expires_at"])
- if datetime.now(UTC) > expires_at:
+ if datetime.now(timezone.utc) > expires_at:
conn.execute("DELETE FROM refresh_tokens WHERE id = ?", (row["id"],))
conn.commit()
return None