Skip to content

Commit

Permalink
Update Django to 4.x (#6122)
Browse files Browse the repository at this point in the history
- Reduced rest_api testing time by ~25% in my environment: 430s vs 560s
- Enabled gzip compression
- Fixed webhook tests that not actually waiting for the required number
of delivered messages in response.
- Fixed `preview` tests
  • Loading branch information
azhavoro authored May 22, 2023
1 parent 0a092f9 commit cfe2ea3
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 94 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ without use_cache option (<https://github.com/opencv/cvat/pull/6074>)
- Cloud storage manifest file is optional (<https://github.com/opencv/cvat/pull/6074>)

### Changed
- TDB
- Updated Django to 4.2.x version (<https://github.com/opencv/cvat/pull/6122>)

### Deprecated
- The endpoint /cloudstorages/{id}/content was deprecated (<https://github.com/opencv/cvat/pull/6074>)
Expand Down
31 changes: 22 additions & 9 deletions cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1914,26 +1914,39 @@ def perform_destroy(self, instance):
list=extend_schema(
summary='Method returns a paginated list of users',
responses={
'200': PolymorphicProxySerializer(component_name='MetaUser',
'200': PolymorphicProxySerializer(
component_name='MetaUser',
serializers=[
UserSerializer, BasicUserSerializer,
], resource_type_field_name=None),
UserSerializer,
BasicUserSerializer,
],
resource_type_field_name=None,
many=True, # https://github.com/tfranzel/drf-spectacular/issues/910
),
}),
retrieve=extend_schema(
summary='Method provides information of a specific user',
responses={
'200': PolymorphicProxySerializer(component_name='MetaUser',
'200': PolymorphicProxySerializer(
component_name='MetaUser',
serializers=[
UserSerializer, BasicUserSerializer,
], resource_type_field_name=None),
UserSerializer,
BasicUserSerializer,
],
resource_type_field_name=None,
),
}),
partial_update=extend_schema(
summary='Method updates chosen fields of a user',
responses={
'200': PolymorphicProxySerializer(component_name='MetaUser',
'200': PolymorphicProxySerializer(
component_name='MetaUser',
serializers=[
UserSerializer(partial=True), BasicUserSerializer(partial=True),
], resource_type_field_name=None),
UserSerializer(partial=True),
BasicUserSerializer(partial=True),
],
resource_type_field_name=None,
),
}),
destroy=extend_schema(
summary='Method deletes a specific user from the server',
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/iam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.contrib import admin
from django.contrib.auth.models import Group, User
from django.contrib.auth.admin import GroupAdmin, UserAdmin
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

class CustomUserAdmin(UserAdmin):
fieldsets = (
Expand Down
7 changes: 5 additions & 2 deletions cvat/apps/iam/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ def unsign(self, signature, url):
class TokenAuthenticationEx(TokenAuthentication):
def authenticate(self, request):
auth = super().authenticate(request)
session = getattr(request, 'session')
if auth is not None and (session.session_key is None or (not session.modified and not session.load())):
# drf_spectacular uses mock requests without session field
session = getattr(request, 'session', None)
if (auth is not None and
session is not None and
(session.session_key is None or (not session.modified and not session.load()))):
login(request, auth[0], 'django.contrib.auth.backends.ModelBackend')
return auth

Expand Down
15 changes: 6 additions & 9 deletions cvat/requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

attrs==21.4.0
click==8.1.3
Django==3.2.18
django-appconf==1.0.4
Django~=4.2.1
django-auth-ldap==2.2.0
django-compressor==2.4
django-compressor==4.3.1
# dj-rest-auth[with_social] includes django-allauth but with version range: >=0.40.0,<0.53.0
# This does not suit us in the case when one of the previous allauth version was installed.
# Despite direct indication allauth in requirements we should keep 'with_social' for dj-rest-auth
Expand All @@ -20,24 +19,22 @@ numpy==1.22.0
python-ldap==3.4.3
pytz==2020.1
pyunpack==0.2.1
rcssmin==1.0.6
redis==4.5.4
rjsmin==1.1.0
requests==2.26.0
rq==1.5.2
rq-scheduler==0.10.0
sqlparse==0.4.2
django-sendfile2==0.7.0
dj-pagination==2.5.0
python-logstash-async==2.5.0
rules==2.2
rules>=3.3
GitPython==3.1.30
coreapi==2.3.3
django-filter==2.4.0
Markdown==3.2.2
djangorestframework==3.12.4
djangorestframework~=3.14.0
Pygments==2.7.4
drf-spectacular==0.22.1
drf-spectacular>=0.26.2
Shapely==1.7.1
pdf2image==1.14.0
opencv-python-headless==4.5.5.62
Expand All @@ -64,4 +61,4 @@ psutil==5.9.4
clickhouse-connect==0.5.10
django-crum==0.7.9
wheel>=0.38.0 # not directly required, pinned by Snyk to avoid a vulnerability
psycopg2-binary==2.9.5
psycopg2-binary==2.9.5
64 changes: 29 additions & 35 deletions cvat/requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:50365e5ee7471df51668fecdb1438bd0a1483d14
# SHA1:53feeaa402abed516aad4a640244c5fd1bff765a
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand Down Expand Up @@ -37,7 +37,7 @@ botocore==1.20.112
# s3transfer
cachetools==5.3.0
# via google-auth
certifi==2022.12.7
certifi==2023.5.7
# via
# clickhouse-connect
# msrest
Expand Down Expand Up @@ -80,7 +80,7 @@ dj-pagination==2.5.0
# via -r cvat/requirements/base.in
dj-rest-auth[with_social]==2.2.7
# via -r cvat/requirements/base.in
django==3.2.18
django==4.2.1
# via
# -r cvat/requirements/base.in
# dj-rest-auth
Expand All @@ -99,13 +99,11 @@ django-allauth==0.52.0
# via
# -r cvat/requirements/base.in
# dj-rest-auth
django-appconf==1.0.4
# via
# -r cvat/requirements/base.in
# django-compressor
django-appconf==1.0.5
# via django-compressor
django-auth-ldap==2.2.0
# via -r cvat/requirements/base.in
django-compressor==2.4
django-compressor==4.3.1
# via -r cvat/requirements/base.in
django-cors-headers==3.5.0
# via -r cvat/requirements/base.in
Expand All @@ -119,24 +117,24 @@ django-rq==2.3.2
# via -r cvat/requirements/base.in
django-sendfile2==0.7.0
# via -r cvat/requirements/base.in
djangorestframework==3.12.4
djangorestframework==3.14.0
# via
# -r cvat/requirements/base.in
# dj-rest-auth
# drf-spectacular
dnspython==2.2.0
# via -r cvat/requirements/base.in
drf-spectacular==0.22.1
drf-spectacular==0.26.2
# via -r cvat/requirements/base.in
easyprocess==0.3
# via
# -r cvat/requirements/base.in
# pyunpack
entrypoint2==1.1
# via pyunpack
flatbuffers==23.3.3
flatbuffers==23.5.9
# via tensorflow
fonttools==4.39.3
fonttools==4.39.4
# via matplotlib
furl==2.1.0
# via -r cvat/requirements/base.in
Expand All @@ -150,7 +148,7 @@ google-api-core==2.11.0
# via
# google-cloud-core
# google-cloud-storage
google-auth==2.17.3
google-auth==2.18.1
# via
# google-api-core
# google-auth-oauthlib
Expand All @@ -167,11 +165,11 @@ google-crc32c==1.5.0
# via google-resumable-media
google-pasta==0.2.0
# via tensorflow
google-resumable-media==2.4.1
google-resumable-media==2.5.0
# via google-cloud-storage
googleapis-common-protos==1.59.0
# via google-api-core
grpcio==1.54.0
grpcio==1.54.2
# via
# tensorboard
# tensorflow
Expand Down Expand Up @@ -204,7 +202,7 @@ kiwisolver==1.4.4
# via matplotlib
libclang==16.0.0
# via tensorflow
limits==3.4.0
limits==3.5.0
# via python-logstash-async
lxml==4.9.2
# via datumaro
Expand Down Expand Up @@ -236,7 +234,7 @@ opt-einsum==3.3.0
# via tensorflow
orderedmultidict==1.0.1
# via furl
orjson==3.8.10
orjson==3.8.12
# via datumaro
packaging==23.1
# via
Expand All @@ -245,7 +243,7 @@ packaging==23.1
# nibabel
# tensorboardx
# tensorflow
pandas==2.0.0
pandas==2.0.1
# via datumaro
patool==1.12
# via -r cvat/requirements/base.in
Expand All @@ -262,12 +260,12 @@ psutil==5.9.4
# via -r cvat/requirements/base.in
psycopg2-binary==2.9.5
# via -r cvat/requirements/base.in
pyasn1==0.4.8
pyasn1==0.5.0
# via
# pyasn1-modules
# python-ldap
# rsa
pyasn1-modules==0.2.8
pyasn1-modules==0.3.0
# via
# google-auth
# python-ldap
Expand All @@ -277,7 +275,7 @@ pycparser==2.21
# via cffi
pygments==2.7.4
# via -r cvat/requirements/base.in
pyjwt[crypto]==2.6.0
pyjwt[crypto]==2.7.0
# via django-allauth
pylogbeat==2.0.0
# via python-logstash-async
Expand All @@ -303,18 +301,16 @@ pytz==2020.1
# via
# -r cvat/requirements/base.in
# clickhouse-connect
# django
# djangorestframework
# pandas
pyunpack==0.2.1
# via -r cvat/requirements/base.in
pyyaml==6.0
# via
# datumaro
# drf-spectacular
rcssmin==1.0.6
# via
# -r cvat/requirements/base.in
# django-compressor
rcssmin==1.1.1
# via django-compressor
redis==4.5.4
# via
# -r cvat/requirements/base.in
Expand All @@ -338,10 +334,8 @@ requests-oauthlib==1.3.1
# django-allauth
# google-auth-oauthlib
# msrest
rjsmin==1.1.0
# via
# -r cvat/requirements/base.in
# django-compressor
rjsmin==1.2.1
# via django-compressor
rq==1.5.2
# via
# -r cvat/requirements/base.in
Expand All @@ -351,11 +345,11 @@ rq-scheduler==0.10.0
# via -r cvat/requirements/base.in
rsa==4.9
# via google-auth
ruamel-yaml==0.17.21
ruamel-yaml==0.17.26
# via datumaro
ruamel-yaml-clib==0.2.7
# via ruamel-yaml
rules==2.2
rules==3.3
# via -r cvat/requirements/base.in
s3transfer==0.4.2
# via boto3
Expand All @@ -367,7 +361,6 @@ six==1.16.0
# via
# astunparse
# azure-core
# django-compressor
# furl
# google-auth
# google-pasta
Expand Down Expand Up @@ -395,7 +388,7 @@ tensorflow-estimator==2.11.0
# via tensorflow
tensorflow-io-gcs-filesystem==0.32.0
# via tensorflow
termcolor==2.2.0
termcolor==2.3.0
# via tensorflow
typing-extensions==4.5.0
# via
Expand All @@ -414,8 +407,9 @@ urllib3==1.26.15
# -r cvat/requirements/base.in
# botocore
# clickhouse-connect
# google-auth
# requests
werkzeug==2.2.3
werkzeug==2.3.4
# via tensorboard
wheel==0.40.0
# via
Expand Down
6 changes: 3 additions & 3 deletions cvat/requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lazy-object-proxy==1.9.0
# via astroid
mccabe==0.7.0
# via pylint
platformdirs==3.2.0
platformdirs==3.5.1
# via pylint
pycodestyle==2.10.0
# via autopep8
Expand All @@ -49,9 +49,9 @@ tomli==2.0.1
# via
# autopep8
# pylint
tomlkit==0.11.7
tomlkit==0.11.8
# via pylint
tornado==6.3
tornado==6.3.2
# via snakeviz

# The following packages are considered to be unsafe in a requirements file:
Loading

0 comments on commit cfe2ea3

Please sign in to comment.