mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-10-03 17:15:19 -07:00
Merge pull request #1146 from jamiepine/prep/pr-659
fix: replace deprecated datetime.utcnow() with datetime.now(UTC) throughout
This commit is contained in:
@@ -3,7 +3,7 @@ Audio channel management module.
|
||||
"""
|
||||
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
import uuid
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
@@ -81,7 +81,7 @@ async def create_channel(
|
||||
id=str(uuid.uuid4()),
|
||||
name=data.name,
|
||||
is_default=False,
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
db.add(channel)
|
||||
db.flush()
|
||||
|
||||
@@ -140,13 +140,13 @@ def _get_or_create_row(db: Session) -> DBCloudSettings:
|
||||
|
||||
|
||||
def _store_key(db: Session, *, api_key: str, device_name: str | None, account_user_id: str | None):
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
|
||||
row = _get_or_create_row(db)
|
||||
row.api_key = api_key
|
||||
row.device_name = device_name
|
||||
row.account_user_id = account_user_id
|
||||
row.connected_at = datetime.utcnow()
|
||||
row.connected_at = datetime.now(UTC)
|
||||
db.commit()
|
||||
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ async def import_generation_from_zip(file_bytes: bytes, db: Session) -> dict:
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
from .. import config
|
||||
|
||||
zip_buffer = io.BytesIO(file_bytes)
|
||||
@@ -432,7 +432,7 @@ async def import_generation_from_zip(file_bytes: bytes, db: Session) -> dict:
|
||||
duration=generation_data["duration"],
|
||||
seed=generation_data.get("seed"),
|
||||
instruct=generation_data.get("instruct"),
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
|
||||
db.add(db_generation)
|
||||
|
||||
@@ -3,7 +3,7 @@ Generation history management module.
|
||||
"""
|
||||
|
||||
from typing import List, Optional, Tuple
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
import uuid
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
@@ -124,7 +124,7 @@ async def create_generation(
|
||||
model_size=model_size,
|
||||
status=status,
|
||||
source=source,
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
|
||||
db.add(db_generation)
|
||||
|
||||
@@ -4,7 +4,7 @@ import json as _json
|
||||
import logging
|
||||
import shutil
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
|
||||
from sqlalchemy import func
|
||||
@@ -183,8 +183,8 @@ async def create_profile(
|
||||
design_prompt=data.design_prompt,
|
||||
default_engine=default_engine,
|
||||
personality=data.personality,
|
||||
created_at=datetime.utcnow(),
|
||||
updated_at=datetime.utcnow(),
|
||||
created_at=datetime.now(UTC),
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
|
||||
db.add(db_profile)
|
||||
@@ -244,7 +244,7 @@ async def add_profile_sample(
|
||||
|
||||
db.add(db_sample)
|
||||
|
||||
profile.updated_at = datetime.utcnow()
|
||||
profile.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(db_sample)
|
||||
@@ -403,7 +403,7 @@ async def update_profile(
|
||||
profile.personality = data.personality
|
||||
if data.default_engine is not None:
|
||||
profile.default_engine = data.default_engine or None # empty string → NULL
|
||||
profile.updated_at = datetime.utcnow()
|
||||
profile.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(profile)
|
||||
@@ -672,7 +672,7 @@ async def upload_avatar(
|
||||
process_avatar(image_path, str(output_path))
|
||||
|
||||
profile.avatar_path = config.to_storage_path(output_path)
|
||||
profile.updated_at = datetime.utcnow()
|
||||
profile.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(profile)
|
||||
@@ -703,7 +703,7 @@ async def delete_avatar(
|
||||
avatar_path.unlink()
|
||||
|
||||
profile.avatar_path = None
|
||||
profile.updated_at = datetime.utcnow()
|
||||
profile.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
|
||||
|
||||
+17
-17
@@ -3,7 +3,7 @@ Story management module.
|
||||
"""
|
||||
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
from datetime import UTC, datetime
|
||||
import uuid
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
@@ -96,8 +96,8 @@ async def create_story(
|
||||
id=str(uuid.uuid4()),
|
||||
name=data.name,
|
||||
description=data.description,
|
||||
created_at=datetime.utcnow(),
|
||||
updated_at=datetime.utcnow(),
|
||||
created_at=datetime.now(UTC),
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
|
||||
db.add(db_story)
|
||||
@@ -206,7 +206,7 @@ async def update_story(
|
||||
|
||||
story.name = data.name
|
||||
story.description = data.description
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(story)
|
||||
@@ -314,13 +314,13 @@ async def add_item_to_story(
|
||||
generation_id=data.generation_id,
|
||||
start_time_ms=start_time_ms,
|
||||
track=track,
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
|
||||
db.add(item)
|
||||
|
||||
# Update story updated_at
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(item)
|
||||
@@ -373,7 +373,7 @@ async def move_story_item(
|
||||
# Update story updated_at
|
||||
story = db.query(DBStory).filter_by(id=story_id).first()
|
||||
if story:
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(item)
|
||||
@@ -417,7 +417,7 @@ async def remove_item_from_story(
|
||||
# Update story updated_at
|
||||
story = db.query(DBStory).filter_by(id=story_id).first()
|
||||
if story:
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
return True
|
||||
@@ -470,7 +470,7 @@ async def trim_story_item(
|
||||
# Update story updated_at
|
||||
story = db.query(DBStory).filter_by(id=story_id).first()
|
||||
if story:
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(item)
|
||||
@@ -503,7 +503,7 @@ async def update_story_item_volume(
|
||||
|
||||
story = db.query(DBStory).filter_by(id=story_id).first()
|
||||
if story:
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(item)
|
||||
@@ -576,7 +576,7 @@ async def split_story_item(
|
||||
trim_start_ms=absolute_split_ms,
|
||||
trim_end_ms=current_trim_end,
|
||||
volume=getattr(item, "volume", 1.0),
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
|
||||
db.add(new_item)
|
||||
@@ -584,7 +584,7 @@ async def split_story_item(
|
||||
# Update story updated_at
|
||||
story = db.query(DBStory).filter_by(id=story_id).first()
|
||||
if story:
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(item)
|
||||
@@ -650,7 +650,7 @@ async def duplicate_story_item(
|
||||
trim_start_ms=current_trim_start,
|
||||
trim_end_ms=current_trim_end,
|
||||
volume=getattr(original_item, "volume", 1.0),
|
||||
created_at=datetime.utcnow(),
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
|
||||
db.add(new_item)
|
||||
@@ -658,7 +658,7 @@ async def duplicate_story_item(
|
||||
# Update story updated_at
|
||||
story = db.query(DBStory).filter_by(id=story_id).first()
|
||||
if story:
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(new_item)
|
||||
@@ -700,7 +700,7 @@ async def update_story_item_times(
|
||||
item_map[update.generation_id].start_time_ms = update.start_time_ms
|
||||
|
||||
# Update story updated_at
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
return True
|
||||
@@ -764,7 +764,7 @@ async def reorder_story_items(
|
||||
updated_items.append(_build_item_detail(item, generation, profile_name, db))
|
||||
|
||||
# Update story updated_at
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
return updated_items
|
||||
@@ -823,7 +823,7 @@ async def set_story_item_version(
|
||||
# Update story updated_at
|
||||
story = db.query(DBStory).filter_by(id=story_id).first()
|
||||
if story:
|
||||
story.updated_at = datetime.utcnow()
|
||||
story.updated_at = datetime.now(UTC)
|
||||
|
||||
db.commit()
|
||||
db.refresh(item)
|
||||
|
||||
Reference in New Issue
Block a user