Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DIA-1803: Stop using deprecated utcnow #6897

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions label_studio/core/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import traceback as tb
import uuid
from collections import defaultdict
from datetime import datetime
from functools import wraps
from typing import Any, Callable, Generator, Iterable, Mapping, Optional

Expand All @@ -41,6 +40,7 @@
pre_save,
)
from django.db.utils import OperationalError
from django.utils import timezone
from django.utils.crypto import get_random_string
from django.utils.module_loading import import_string
from django_filters.rest_framework import DjangoFilterBackend
Expand Down Expand Up @@ -261,7 +261,7 @@ def datetime_to_timestamp(dt):


def timestamp_now():
return datetime_to_timestamp(datetime.utcnow())
return datetime_to_timestamp(timezone.now())


def find_first_one_to_one_related_field_by_prefix(instance, prefix):
Expand Down
5 changes: 3 additions & 2 deletions label_studio/io_storages/azure_blob/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import logging
import re
from datetime import datetime, timedelta
from datetime import timedelta
from typing import Union
from urllib.parse import urlparse

Expand All @@ -15,6 +15,7 @@
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from io_storages.base_models import (
ExportStorage,
Expand Down Expand Up @@ -144,7 +145,7 @@ def generate_http_url(self, url):
container = r.netloc
blob = r.path.lstrip('/')

expiry = datetime.utcnow() + timedelta(minutes=self.presign_ttl)
expiry = timezone.now() + timedelta(minutes=self.presign_ttl)

sas_token = generate_blob_sas(
account_name=self.get_account_name(),
Expand Down
Loading