File tree 6 files changed +94
-5
lines changed
6 files changed +94
-5
lines changed Original file line number Diff line number Diff line change 11
11
# from .tasks import train_model
12
12
13
13
14
-
15
-
16
14
class UserSerializer (serializers .ModelSerializer ):
17
15
class Meta :
18
16
model = OsmUser
@@ -65,9 +63,11 @@ def to_representation(self, instance):
65
63
# get default
66
64
ret = super ().to_representation (instance )
67
65
# For GET requests, replace the user field with detailed UserSerializer data
68
- if self .context .get (' request' ) and self .context [' request' ].method == ' GET' :
69
- ret [' user' ] = UserSerializer (instance .user ).data
66
+ if self .context .get (" request" ) and self .context [" request" ].method == " GET" :
67
+ ret [" user" ] = UserSerializer (instance .user ).data
70
68
return ret
69
+
70
+
71
71
class ModelSerializer (serializers .ModelSerializer ):
72
72
user = UserSerializer (read_only = True )
73
73
accuracy = serializers .SerializerMethodField ()
@@ -453,6 +453,7 @@ class Meta:
453
453
"username" ,
454
454
"email" ,
455
455
"date_joined" ,
456
+ "last_login" ,
456
457
"img_url" ,
457
458
"notifications_delivery_methods" ,
458
459
"newsletter_subscription" ,
Original file line number Diff line number Diff line change 3
3
from core .serializers import UserStatsSerializer
4
4
from django .conf import settings
5
5
from django .http import JsonResponse
6
+ from django .utils import timezone
6
7
from drf_yasg import openapi
7
8
from drf_yasg .utils import swagger_auto_schema
8
9
from login .authentication import OsmAuthentication
@@ -59,7 +60,11 @@ class GetMyData(APIView):
59
60
permission_classes = [IsOsmAuthenticated ]
60
61
61
62
def get (self , request , format = None ):
62
- serialized_field = UserStatsSerializer (instance = request .user )
63
+
64
+ user = request .user
65
+ user .last_login = timezone .now ()
66
+ user .save (update_fields = ["last_login" ])
67
+ serialized_field = UserStatsSerializer (instance = user )
63
68
return Response (serialized_field .data , status = status .HTTP_201_CREATED )
64
69
65
70
@swagger_auto_schema (
Original file line number Diff line number Diff line change
1
+ ### Systemd templates
2
+
3
+
4
+ Services required to setup fAIr in VM ( Dev env ).
5
+
6
+ if frontend is hosted with nginx :
7
+
8
+ ``` bash
9
+ sudo systemctl restart gunicorn && sudo systemctl restart workers && sudo nginx -t && sudo systemctl restart nginx && sudo systemctl restart django-q
10
+ ```
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =Django Q Cluster
3
+ After =network.target
4
+
5
+ [Service]
6
+ User =root
7
+ Group =www-data
8
+ Environment =PROJ_LIB =/usr/local/envs/fair/share/proj
9
+ Environment =CONDA_PYTHON_EXE =/usr/local/bin/python
10
+ Environment =LD_LIBRARY_PATH =:/usr/local/lib/:/usr/local/envs/fair/lib/
11
+ Environment =LC_CTYPE =C.UTF-8
12
+ Environment =CONDA_DEFAULT_ENV =fair
13
+ Environment =GDAL_DATA =/usr/local/envs/fair/share/gdal
14
+ Environment =RAMP_HOME =/home/fAIr-utilities
15
+ WorkingDirectory =/home/kshitij/fAIr/backend
16
+ ExecStart =/usr/local/envs/fair/bin/python manage.py qcluster
17
+ Restart =always
18
+ RestartSec =5
19
+
20
+
21
+ [Install]
22
+ WantedBy =multi-user.target
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =gunicorn daemon
3
+ Requires =gunicorn.socket
4
+ After =network.target
5
+
6
+ [Service]
7
+ User =root
8
+ Group =www-data
9
+
10
+ # Environment variables
11
+ EnvironmentFile =/home/kshitij/fAIr/backend/.env
12
+
13
+ Environment =DEBUG =True
14
+ Environment =PROJ_LIB =/usr/local/envs/fair/share/proj
15
+ Environment =CONDA_PYTHON_EXE =/usr/local/bin/python
16
+ Environment =LD_LIBRARY_PATH =:/usr/local/lib/:/usr/local/envs/fair/lib/
17
+ Environment =LC_CTYPE =C.UTF-8
18
+ Environment =CONDA_DEFAULT_ENV =fair
19
+ Environment =GDAL_DATA =/usr/local/envs/fair/share/gdal
20
+
21
+
22
+ # Working directory
23
+ WorkingDirectory =/home/kshitij/fAIr/backend
24
+
25
+ # Gunicorn startup
26
+ ExecStart =/usr/local/envs/fair/bin/gunicorn \
27
+ --access-logfile - \
28
+ --workers 3 \
29
+ --bind unix:/run/gunicorn.sock \
30
+ aiproject.wsgi:application --timeout 180 --log-level debug
31
+
32
+ [Install]
33
+ WantedBy =multi-user.target
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =Celery Service
3
+ After =network.target
4
+
5
+ [Service]
6
+ Type =simple
7
+ User =root
8
+ Group =www-data
9
+ EnvironmentFile =/etc/default/workers
10
+ Environment =CONDA_PREFIX =/usr/local/envs/fair
11
+ Environment =PYTHON_HOME =/usr/local/envs/fair/bin/python
12
+ WorkingDirectory =/home/kshitij/fAIr/backend
13
+ ExecStart =/bin/sh -c '${CELERY_BIN} -A ${CELERY_APP} worker --pool=threads --concurrency=1 --hostname=worker@fair-dev -Q ramp_training,yolo_training'
14
+ Restart =on-failure
15
+ RestartSec =5
16
+
17
+ [Install]
18
+ WantedBy =multi-user.target
You can’t perform that action at this time.
0 commit comments