Best Python code snippet using fMBT_python
views.py
Source:views.py
1from json import decoder2from django.shortcuts import render3from account_user.models import Fuser4from allauth.socialaccount.models import SocialToken5from allauth.socialaccount.models import SocialAccount6from .get_social_info import *7#íì´ì¬ í¨ììì¼ë¡ ë§ë¤ë©´ ë¨8def main(request):9 data = {}10 user_pk = request.session.get('user') #login í¨ììì ì¶ê°í´ì¤ request.session['user'] = fuser.id11 try:12 social_account = SocialAccount.objects.all()[0]13 print('ìì
ë¡ê·¸ì¸ ì´ë¦--> ',social_account.extra_data['name'])14 social_user_name = social_account.extra_data['name']15 except:16 social_account = None17 if social_account or user_pk :18 print('ã
ã
ìì
ë¡ ë¡ê·¸ì¸ ëë ìì´ëë¡ ë¡ê·¸ì¸íì´ ')19 else:20 print('ìì
ë¡ê·¸ì¸ë ìíê³ ì¬ì´í¸ ë¡ê·¸ì¸ë ìí¨')21 if user_pk: #ì¸ì
ì user_pk ì ë³´ê° ì¡´ì¬íë©´22 fuser = Fuser.objects.get(pk = user_pk)23 data['user'] = fuser24 elif social_account:25 request.session['social_user']= social_user_name #ì¹ì
ì ìì
ì ì ì ì´ë¦ë§ ì ì¥í기. -->(ë¤ë¥¸ í¨ììì get í기 ìí´ì.)26 #기존ì ì¬ì©ì27 data['user'] = social_user_name28 else:29 data['temp'] = 130 return render(request, "main.html",data)31def mypage(request):32 data={}33 print('ì¤í')34 data['user'] = None #ì²ìì base.htmlì ììí기 ë문ì35 #data['user'] ì ê°ì Noneì¼ë¡ ë³ê²½ìíë©´ ì²ì mainíì´ì§ì user ê°ì´ë ê²¹ì¹ë¤.36 user_pk = request.session.get('user')37 print( 'user_pk =', user_pk)38 social_name = request.session.get('social_user')39 try:40 fuser = Fuser.objects.get(pk=user_pk)41 data['user']=fuser42 except:43 data['social_user'] = social_name44 print(data)45 return render(request, "mypage.html", data)46 47def profile_modify(request):48 temp=049 data={}50 user_pk = request.session.get('user')51 if request.method == 'GET':52 fuser = Fuser.objects.get(pk=user_pk)53 data['user']=fuser54 return render(request, "profile_modify.html", data)55 elif request.method == 'POST':56 fuser = Fuser.objects.get(pk=user_pk)57 fuser.useremail =request.POST.get('useremail') 58 fuser.school = request.POST.get('school')59 fuser.major = request.POST.get('major')60 fuser.grade = request.POST.get('grade')61 fuser.phone = request.POST.get('phone')62 if not (fuser.useremail and fuser.school and fuser.major and fuser.grade and fuser.phone):63 data['error']="â 모ë 칸ì ì
ë ¥í´ì£¼ì¸ìâ " 64 return render (request,"profile_modify.html",data) 65 else:66 fuser.save()67 data['user']=fuser68 return render (request,"mypage.html",data)69 70 #ì´ í¨ìë welcomeì´ë¼ë ì´ë¦ ë¤ë¥¸ê³³ìì welcomeì¼ë¡ ë¶ë¬ì¬ ì ìë¤. ...
jit.py
Source:jit.py
...13 torch._C._jit_set_profiling_executor(False)14 torch._C._jit_set_profiling_mode(False)15 torch._C._jit_override_can_fuse_on_gpu(True)16 #torch._C._jit_set_texpr_fuser_enabled(True)17def set_jit_fuser(fuser):18 if fuser == "te":19 # default fuser should be == 'te'20 torch._C._jit_set_profiling_executor(True)21 torch._C._jit_set_profiling_mode(True)22 torch._C._jit_override_can_fuse_on_cpu(False)23 torch._C._jit_override_can_fuse_on_gpu(True)24 torch._C._jit_set_texpr_fuser_enabled(True)25 elif fuser == "old" or fuser == "legacy":26 torch._C._jit_set_profiling_executor(False)27 torch._C._jit_set_profiling_mode(False)28 torch._C._jit_override_can_fuse_on_gpu(True)29 torch._C._jit_set_texpr_fuser_enabled(False)30 elif fuser == "nvfuser" or fuser == "nvf":31 os.environ['PYTORCH_CUDA_FUSER_DISABLE_FALLBACK'] = '1'...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!