Spaces:
Runtime error
Runtime error
email_verification
#1
by
mayureshagashe2105
- opened
- TechdocsAPI/backend/__init__.py +39 -17
- TechdocsAPI/backend/core/ConfigEnv.py +1 -2
- TechdocsAPI/backend/core/ExceptionHandlers.py +0 -6
- TechdocsAPI/backend/core/Exceptions.py +1 -13
- TechdocsAPI/backend/services/auth/__init__.py +1 -2
- TechdocsAPI/backend/services/auth/ops.py +18 -19
- TechdocsAPI/backend/services/auth/utils/functools.py +0 -9
- TechdocsAPI/backend/utils/Gemini_Prompt.txt +0 -177
- TechdocsAPI/backend/utils/prompt.txt +7 -8
- TechdocsAPI/requirements.txt +2 -5
- scripts/test.py +11 -13
- temp.py +0 -21
- testing/logs_2024_01_07_16_08_04.log +0 -23
- testing/pack/DBQueries.py +61 -29
- testing/pack/functools.py +72 -39
- testing/test.py +29 -7
TechdocsAPI/backend/__init__.py
CHANGED
@@ -8,16 +8,16 @@ from fastapi.templating import Jinja2Templates
|
|
8 |
from backend.utils import DBConnection
|
9 |
from backend.core.ConfigEnv import config
|
10 |
|
11 |
-
from
|
12 |
from langchain.chains import LLMChain
|
13 |
-
from langchain.prompts import PromptTemplate
|
14 |
|
|
|
15 |
|
16 |
-
app = FastAPI(
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
)
|
21 |
|
22 |
from backend import router
|
23 |
|
@@ -26,26 +26,48 @@ try:
|
|
26 |
test_conn = DBConnection.get_client().get_server_info()
|
27 |
|
28 |
# send prompt wizardcoderLM-70b-instruct-GGUF model
|
29 |
-
with open("backend/utils/prompt.txt",
|
30 |
prompt = f.read()
|
31 |
|
32 |
-
prompt = PromptTemplate(template=prompt, input_variables=[
|
33 |
|
34 |
llm = Clarifai(
|
35 |
-
pat=config.CLARIFAI_PAT,
|
36 |
-
user_id=config.USER_ID,
|
37 |
-
app_id=config.APP_ID,
|
38 |
-
model_id=config.MODEL_ID,
|
39 |
model_version_id=config.MODEL_VERSION_ID,
|
40 |
)
|
41 |
|
42 |
-
llmchain =
|
|
|
|
|
|
|
43 |
app.state.llmchain = llmchain
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
app.state.templates = Jinja2Templates(directory="./backend/templates")
|
46 |
|
47 |
|
|
|
48 |
except mysql.connector.Error as err:
|
49 |
-
raise HTTPException(
|
50 |
-
|
51 |
-
|
|
|
8 |
from backend.utils import DBConnection
|
9 |
from backend.core.ConfigEnv import config
|
10 |
|
11 |
+
from langchain.llms import Clarifai
|
12 |
from langchain.chains import LLMChain
|
13 |
+
from langchain.prompts import PromptTemplate
|
14 |
|
15 |
+
from fastapi_mail import ConnectionConfig, FastMail
|
16 |
|
17 |
+
app = FastAPI(title="Techdocs",
|
18 |
+
version="V0.0.1",
|
19 |
+
description="API for automatic code documentation generation!"
|
20 |
+
)
|
|
|
21 |
|
22 |
from backend import router
|
23 |
|
|
|
26 |
test_conn = DBConnection.get_client().get_server_info()
|
27 |
|
28 |
# send prompt wizardcoderLM-70b-instruct-GGUF model
|
29 |
+
with open("backend/utils/prompt.txt",'r') as f:
|
30 |
prompt = f.read()
|
31 |
|
32 |
+
prompt = PromptTemplate(template=prompt, input_variables=['instruction'])
|
33 |
|
34 |
llm = Clarifai(
|
35 |
+
pat = config.CLARIFAI_PAT,
|
36 |
+
user_id = config.USER_ID,
|
37 |
+
app_id = config.APP_ID,
|
38 |
+
model_id = config.MODEL_ID,
|
39 |
model_version_id=config.MODEL_VERSION_ID,
|
40 |
)
|
41 |
|
42 |
+
llmchain = LLMChain(
|
43 |
+
prompt=prompt,
|
44 |
+
llm=llm
|
45 |
+
)
|
46 |
app.state.llmchain = llmchain
|
47 |
|
48 |
+
|
49 |
+
conf = ConnectionConfig(
|
50 |
+
MAIL_USERNAME=config.MAIL_USERNAME,
|
51 |
+
MAIL_PASSWORD=config.MAIL_PASSWORD,
|
52 |
+
MAIL_FROM=config.MAIL_FROM,
|
53 |
+
MAIL_PORT=587,
|
54 |
+
MAIL_SERVER="smtp.gmail.com",
|
55 |
+
MAIL_STARTTLS=True,
|
56 |
+
MAIL_SSL_TLS=False,
|
57 |
+
TEMPLATE_FOLDER="backend/templates",
|
58 |
+
USE_CREDENTIALS = True,
|
59 |
+
VALIDATE_CERTS = True
|
60 |
+
|
61 |
+
# MAIL_TLS=True,
|
62 |
+
# MAIL_SSL=False
|
63 |
+
)
|
64 |
+
|
65 |
+
app.state.mail_client = FastMail(conf)
|
66 |
app.state.templates = Jinja2Templates(directory="./backend/templates")
|
67 |
|
68 |
|
69 |
+
|
70 |
except mysql.connector.Error as err:
|
71 |
+
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(err))
|
72 |
+
|
73 |
+
|
TechdocsAPI/backend/core/ConfigEnv.py
CHANGED
@@ -14,14 +14,13 @@ class Settings(BaseSettings):
|
|
14 |
JWT_SECRET_KEY:str
|
15 |
JWT_REFRESH_SECRET_KEY:str
|
16 |
JWT_VERIFICATION_SECRET_KEY:str
|
17 |
-
#
|
18 |
APP_ID:str
|
19 |
USER_ID:str
|
20 |
MODEL_ID:str
|
21 |
CLARIFAI_PAT:str
|
22 |
MODEL_VERSION_ID:str
|
23 |
|
24 |
-
MAIL_SERVER_URL:str
|
25 |
MAIL_USERNAME:str
|
26 |
MAIL_PASSWORD:str
|
27 |
MAIL_FROM:str
|
|
|
14 |
JWT_SECRET_KEY:str
|
15 |
JWT_REFRESH_SECRET_KEY:str
|
16 |
JWT_VERIFICATION_SECRET_KEY:str
|
17 |
+
# OPENAI_KEY:str
|
18 |
APP_ID:str
|
19 |
USER_ID:str
|
20 |
MODEL_ID:str
|
21 |
CLARIFAI_PAT:str
|
22 |
MODEL_VERSION_ID:str
|
23 |
|
|
|
24 |
MAIL_USERNAME:str
|
25 |
MAIL_PASSWORD:str
|
26 |
MAIL_FROM:str
|
TechdocsAPI/backend/core/ExceptionHandlers.py
CHANGED
@@ -19,12 +19,6 @@ async def email_not_verified(request: Request, exec: EmailNotVerifiedException):
|
|
19 |
content=repr(exec)
|
20 |
)
|
21 |
|
22 |
-
@app.exception_handler(EmailNotSentException)
|
23 |
-
async def email_not_sent(request: Request, exec: EmailNotSentException):
|
24 |
-
return JSONResponse(status_code=status.HTTP_403_FORBIDDEN,
|
25 |
-
content=repr(exec)
|
26 |
-
)
|
27 |
-
|
28 |
@app.exception_handler(InvalidCredentialsException)
|
29 |
async def handle_login_failed(request: Request, exec: InvalidCredentialsException):
|
30 |
return JSONResponse(status_code=status.HTTP_403_FORBIDDEN,
|
|
|
19 |
content=repr(exec)
|
20 |
)
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
@app.exception_handler(InvalidCredentialsException)
|
23 |
async def handle_login_failed(request: Request, exec: InvalidCredentialsException):
|
24 |
return JSONResponse(status_code=status.HTTP_403_FORBIDDEN,
|
TechdocsAPI/backend/core/Exceptions.py
CHANGED
@@ -54,16 +54,4 @@ class EmailNotVerifiedException(Exception):
|
|
54 |
self.status = 'EmailNotVerifiedException'
|
55 |
|
56 |
def __repr__(self):
|
57 |
-
return "exception.EmailNotVerifiedException()"
|
58 |
-
|
59 |
-
|
60 |
-
class EmailNotSentException(Exception):
|
61 |
-
def __init__(self):
|
62 |
-
self.set_statuses()
|
63 |
-
super(EmailNotSentException, self).__init__()
|
64 |
-
|
65 |
-
def set_statuses(self):
|
66 |
-
self.status = 'EmailNotSentException'
|
67 |
-
|
68 |
-
def __repr__(self):
|
69 |
-
return "exception.EmailNotSentException()"
|
|
|
54 |
self.status = 'EmailNotVerifiedException'
|
55 |
|
56 |
def __repr__(self):
|
57 |
+
return "exception.EmailNotVerifiedException()"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TechdocsAPI/backend/services/auth/__init__.py
CHANGED
@@ -1,3 +1,2 @@
|
|
1 |
from .ops import *
|
2 |
-
from .utils.JWTBearer import *
|
3 |
-
from .utils.functools import *
|
|
|
1 |
from .ops import *
|
2 |
+
from .utils.JWTBearer import *
|
|
TechdocsAPI/backend/services/auth/ops.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
from .utils.auth_funcs import *
|
2 |
-
from .utils.functools import *
|
3 |
from .utils.JWTBearer import *
|
4 |
from backend.models import *
|
5 |
from backend.services.db.utils.DBQueries import DBQueries
|
@@ -12,8 +11,10 @@ from fastapi import HTTPException, BackgroundTasks
|
|
12 |
from pydantic import ValidationError
|
13 |
from jose import jwt
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
17 |
|
18 |
async def ops_signup(bgtasks: BackgroundTasks, response_result: GeneralResponse, data: UserAuth):
|
19 |
"""Wrapper method to handle signup process.
|
@@ -33,25 +34,22 @@ async def ops_signup(bgtasks: BackgroundTasks, response_result: GeneralResponse,
|
|
33 |
# user with the entered credentials already exists
|
34 |
raise ExistingUserException(response_result)
|
35 |
verifiction_token = Auth.create_access_token(f"{data.username} {data.email}", secret_name='VERIFICATION')
|
36 |
-
verification_link = f"
|
37 |
|
38 |
email_body_params = {
|
39 |
"username": data.username,
|
40 |
"verify_link": verification_link
|
41 |
}
|
42 |
|
43 |
-
|
44 |
-
"
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
status = post_request(url=config.MAIL_SERVER_URL, data=details, headers=None)
|
51 |
-
if status != 200:
|
52 |
-
raise EmailNotSentException()
|
53 |
-
|
54 |
|
|
|
|
|
55 |
|
56 |
DBQueries.insert_to_database('auth', (data.username, Auth.get_password_hash(data.password), "", 0),
|
57 |
['username', 'password', 'email', 'is_verified'])
|
@@ -112,7 +110,8 @@ def ops_regenerate_api_key(username:str) -> APIKey:
|
|
112 |
apikey = APIKey(api_key=apikey)
|
113 |
|
114 |
return apikey
|
115 |
-
|
|
|
116 |
|
117 |
def ops_inference(source_code:str,api_key:str,username:str):
|
118 |
response_result = GeneralResponse.get_instance(data={},
|
@@ -130,8 +129,7 @@ def ops_inference(source_code:str,api_key:str,username:str):
|
|
130 |
def generate_docstring(source_code_message: str):
|
131 |
|
132 |
|
133 |
-
llm_response = app.state.llmchain.
|
134 |
-
print(llm_response)
|
135 |
|
136 |
docstring = Inference(docstr=llm_response)
|
137 |
|
@@ -145,7 +143,6 @@ def ops_verify_email(request: Request, response_result: GeneralResponse, token:s
|
|
145 |
payload = jwt.decode(
|
146 |
token, config.JWT_VERIFICATION_SECRET_KEY, algorithms=[config.ALGORITHM]
|
147 |
)
|
148 |
-
|
149 |
token_data = TokenPayload(**payload)
|
150 |
if datetime.fromtimestamp(token_data.exp)< datetime.now():
|
151 |
return app.state.templates.TemplateResponse("verification_failure.html", context={"request": request})
|
@@ -158,6 +155,7 @@ def ops_verify_email(request: Request, response_result: GeneralResponse, token:s
|
|
158 |
print(registered_email[0][0])
|
159 |
if registered_email[0][0]:
|
160 |
return app.state.templates.TemplateResponse("verification_failure.html", context={"request": request})
|
|
|
161 |
|
162 |
DBQueries.update_data_in_database('auth','is_verified',f"username='{username}'", (True,))
|
163 |
DBQueries.update_data_in_database('auth','email',f"username='{username}'", email)
|
@@ -167,3 +165,4 @@ def ops_verify_email(request: Request, response_result: GeneralResponse, token:s
|
|
167 |
|
168 |
except (jwt.JWTError, ValidationError):
|
169 |
return app.state.templates.TemplateResponse("verification_failure.html", context={"request": request})
|
|
|
|
1 |
from .utils.auth_funcs import *
|
|
|
2 |
from .utils.JWTBearer import *
|
3 |
from backend.models import *
|
4 |
from backend.services.db.utils.DBQueries import DBQueries
|
|
|
11 |
from pydantic import ValidationError
|
12 |
from jose import jwt
|
13 |
|
14 |
+
from fastapi_mail import MessageSchema, MessageType
|
15 |
+
|
16 |
+
# import openai
|
17 |
+
# from transformers import RobertaTokenizer, T5ForConditionalGeneration
|
18 |
|
19 |
async def ops_signup(bgtasks: BackgroundTasks, response_result: GeneralResponse, data: UserAuth):
|
20 |
"""Wrapper method to handle signup process.
|
|
|
34 |
# user with the entered credentials already exists
|
35 |
raise ExistingUserException(response_result)
|
36 |
verifiction_token = Auth.create_access_token(f"{data.username} {data.email}", secret_name='VERIFICATION')
|
37 |
+
verification_link = f"http://localhost:8000/auth/verify/{verifiction_token}"
|
38 |
|
39 |
email_body_params = {
|
40 |
"username": data.username,
|
41 |
"verify_link": verification_link
|
42 |
}
|
43 |
|
44 |
+
message = MessageSchema(
|
45 |
+
subject="Welcome to Techdocs:[Account Verification]",
|
46 |
+
recipients=[data.email], # List of recipients, as many as you can pass
|
47 |
+
template_body=email_body_params,
|
48 |
+
subtype=MessageType.html
|
49 |
+
)
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
bgtasks.add_task(app.state.mail_client.send_message, message=message, template_name="email_verification.html")
|
52 |
+
# await app.state.mail_client.send_message(message=message, template_name="email_verification.html")
|
53 |
|
54 |
DBQueries.insert_to_database('auth', (data.username, Auth.get_password_hash(data.password), "", 0),
|
55 |
['username', 'password', 'email', 'is_verified'])
|
|
|
110 |
apikey = APIKey(api_key=apikey)
|
111 |
|
112 |
return apikey
|
113 |
+
|
114 |
+
|
115 |
|
116 |
def ops_inference(source_code:str,api_key:str,username:str):
|
117 |
response_result = GeneralResponse.get_instance(data={},
|
|
|
129 |
def generate_docstring(source_code_message: str):
|
130 |
|
131 |
|
132 |
+
llm_response = app.state.llmchain.run({"instruction": source_code_message})
|
|
|
133 |
|
134 |
docstring = Inference(docstr=llm_response)
|
135 |
|
|
|
143 |
payload = jwt.decode(
|
144 |
token, config.JWT_VERIFICATION_SECRET_KEY, algorithms=[config.ALGORITHM]
|
145 |
)
|
|
|
146 |
token_data = TokenPayload(**payload)
|
147 |
if datetime.fromtimestamp(token_data.exp)< datetime.now():
|
148 |
return app.state.templates.TemplateResponse("verification_failure.html", context={"request": request})
|
|
|
155 |
print(registered_email[0][0])
|
156 |
if registered_email[0][0]:
|
157 |
return app.state.templates.TemplateResponse("verification_failure.html", context={"request": request})
|
158 |
+
|
159 |
|
160 |
DBQueries.update_data_in_database('auth','is_verified',f"username='{username}'", (True,))
|
161 |
DBQueries.update_data_in_database('auth','email',f"username='{username}'", email)
|
|
|
165 |
|
166 |
except (jwt.JWTError, ValidationError):
|
167 |
return app.state.templates.TemplateResponse("verification_failure.html", context={"request": request})
|
168 |
+
|
TechdocsAPI/backend/services/auth/utils/functools.py
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
import requests
|
2 |
-
from typing import Any, Dict
|
3 |
-
import json
|
4 |
-
|
5 |
-
def post_request(url: str, data: Dict[str, Any], headers: Dict[str, str]=None):
|
6 |
-
json_data = json.dumps(data)
|
7 |
-
headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
|
8 |
-
response = requests.post(url, data=json_data, headers=headers)
|
9 |
-
return response.status_code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TechdocsAPI/backend/utils/Gemini_Prompt.txt
DELETED
@@ -1,177 +0,0 @@
|
|
1 |
-
<|im_start|>user
|
2 |
-
You are an expert Code Documentation writer. Your job is to document Python codebases. The Documentation should be in "Goolge Style Python Docstrings". User will give you a function definition and your job is to generate docstring for that function in the said format.
|
3 |
-
Now I will define a format which you will be following to generate the docstings. For each function definition, you will generate the following:
|
4 |
-
1. Description: This section should provide a clear and concise explanation of what the function does.
|
5 |
-
2. Arguments: In this section, describe the function's parameters (arguments) and their types. Include both mandatory and optional arguments. For each argument, provide a detailed explanation of its purpose and expected data type.
|
6 |
-
3. Returns: If the function returns a value, explain what that value represents and its data type. If the function doesn't return anything (i.e., it has a None return type), mention that explicitly.
|
7 |
-
4. Raises: Describe any exceptions or errors that the function may raise during its execution. Specify the conditions under which these exceptions might occur.
|
8 |
-
However, you must generate the final docstrings in a specific format which you should be able to figure out by looking at the following examples.
|
9 |
-
|
10 |
-
Code
|
11 |
-
def insert_to_database(cls, db_name:str, coll_name:str, data:dict)->Union[InsertOneResult, InsertManyResult]:
|
12 |
-
con = DBConnection.get_client()
|
13 |
-
mydb = con[db_name]
|
14 |
-
mycol = mydb[coll_name]
|
15 |
-
|
16 |
-
if isinstance(data, list):
|
17 |
-
return mycol.insert_many(data)
|
18 |
-
else:
|
19 |
-
return mycol.insert_one(data)
|
20 |
-
|
21 |
-
"""insert a single record or iterable of records to the database.
|
22 |
-
|
23 |
-
Args:
|
24 |
-
db_name (str): name of the database
|
25 |
-
coll_name (str): name of the collection
|
26 |
-
data (dict): data to be inserted
|
27 |
-
|
28 |
-
Returns:
|
29 |
-
An instance of class: pymongo.results.InsertOneResult or
|
30 |
-
pymongo.results.InsertManyResult
|
31 |
-
"""
|
32 |
-
|
33 |
-
Code
|
34 |
-
def signup(response_result: FrontendResponseModel, data: Union[UserAuth,BulkSignup]):
|
35 |
-
if isinstance(data, UserAuth):
|
36 |
-
# querying database to check if user already exist
|
37 |
-
user = DBQueries.filtered_db_search("Auth", data.role, [], AADHAR=data.AADHAR_NO)
|
38 |
-
if len(list(user)) != 0:
|
39 |
-
# user with the entered credentials already exists
|
40 |
-
raise ExistingUserException(response_result)
|
41 |
-
|
42 |
-
DBQueries.insert_to_database("Auth", data.role, userinfo) # saving user to database
|
43 |
-
response_result['status'] = f'success'
|
44 |
-
response_result['message'] = [f'User with this AADHAR NO created successfully']
|
45 |
-
|
46 |
-
else:
|
47 |
-
AADHAR_NOS = data.AADHAR_NOS
|
48 |
-
passwords = data.passwords
|
49 |
-
village_name = data.village_name
|
50 |
-
|
51 |
-
users = DBQueries.filtered_db_search("Auth", role_manager.user, ["_id","password","village_name"], search_idxs="AADHAR":"$in":AADHAR_NOS)
|
52 |
-
users = [user["AADHAR"] for user in users]
|
53 |
-
|
54 |
-
invalid_users = []
|
55 |
-
valid_users = []
|
56 |
-
users_created = []
|
57 |
-
|
58 |
-
for user in zip(AADHAR_NOS,passwords):
|
59 |
-
if user[0] in users:
|
60 |
-
invalid_users.append(user[0])
|
61 |
-
else:
|
62 |
-
userinfo["AADHAR"] = user[0]
|
63 |
-
userinfo["password"] = Auth.get_password_hash(user[1])
|
64 |
-
valid_users.append(userinfo)
|
65 |
-
users_created.append(user[0])
|
66 |
-
|
67 |
-
if len(valid_users)!=0:
|
68 |
-
DBQueries.insert_to_database("Auth", role_manager.user, valid_users) # saving user to database
|
69 |
-
response_result['status'] = f'success'
|
70 |
-
response_result['message'] = [f'Users created successfully']
|
71 |
-
else:
|
72 |
-
response_result['status'] = f'failure'
|
73 |
-
response_result['message'] = [f'No users created']
|
74 |
-
|
75 |
-
"""Wrapper method to handle signup process.
|
76 |
-
|
77 |
-
Args:
|
78 |
-
response_result: FrontendResponseModel. A TypedDict to return the
|
79 |
-
response captured from the API to the frontend.
|
80 |
-
data: UserAuth. New user's prospective credentials from the frontend
|
81 |
-
to create their account.
|
82 |
-
|
83 |
-
Raises:
|
84 |
-
ExistingUserException: If account with entered AADHAR Number already exists.
|
85 |
-
"""
|
86 |
-
|
87 |
-
Code
|
88 |
-
def fetch_individualdata(response_result: dict, db_name: str, AADHAR_No: str)->Cursor[_DocumentType]:
|
89 |
-
exclude_fields = field_manager.get_form_fields(FormData, exclude=["fam_info"])
|
90 |
-
exclude_fields += ["_id","timestamp","volunteer_id"]
|
91 |
-
indivdata = [docs for docs in DBQueries.filtered_db_search(db_name,collection_names["fam_data"],exclude_fields,search_idxs="fam_info.AADHAR_No":AADHAR_No)]
|
92 |
-
if len(indivdata) == 0:
|
93 |
-
raise InfoNotFoundException(response_result, "person with this id does not exist in the database")
|
94 |
-
|
95 |
-
fam_members = [doc for doc in indivdata[0]["fam_info"] if doc["AADHAR_No"] == AADHAR_No]
|
96 |
-
|
97 |
-
return fam_members[0]
|
98 |
-
|
99 |
-
"""Wrapper function to fetch individual data from the database.
|
100 |
-
Args:
|
101 |
-
response_result (dict): response result to be returned in case of error.
|
102 |
-
db_name (str): name of the database.
|
103 |
-
AADHAR_No (str): id of the respondent.
|
104 |
-
|
105 |
-
Returns:
|
106 |
-
Cursor[_DocumentType]: A cursor containing the data of the individual
|
107 |
-
fetched from the database.
|
108 |
-
"""
|
109 |
-
|
110 |
-
Code
|
111 |
-
def user_login(tokens: TokenSchema, form_data: UserAuth):
|
112 |
-
user = DBQueries.filtered_db_search("Auth", form_data.role, ['_id'], AADHAR=form_data.AADHAR_NO)
|
113 |
-
data = list(user)
|
114 |
-
if len(data) == 0:
|
115 |
-
# no such users in the database
|
116 |
-
raise LoginFailedException(tokens)
|
117 |
-
|
118 |
-
if not Auth.verify_password(form_data.password, data[0]['password']) or \
|
119 |
-
not Auth.verify_village_name(data[0]['village_name'], form_data.village_name):
|
120 |
-
# incorrect credentials
|
121 |
-
raise LoginFailedException(tokens)
|
122 |
-
|
123 |
-
# successful login
|
124 |
-
sub = form_data.AADHAR_NO + "_" + form_data.role + "_" + form_data.village_name
|
125 |
-
tokens['access_token'] = Auth.create_access_token(sub)
|
126 |
-
tokens['refresh_token'] = Auth.create_refresh_token(sub)
|
127 |
-
tokens['status'] = 'login successful'
|
128 |
-
tokens['role'] = form_data.role
|
129 |
-
|
130 |
-
"""Wrapper method to handle sign-ins and generating `access_tokens`.
|
131 |
-
|
132 |
-
Args:
|
133 |
-
tokens: TokenSchema. A TypedDict to return `access_token`,
|
134 |
-
`refresh_access_tokens`, `status`, and `role`
|
135 |
-
related information to grant genuine users their
|
136 |
-
respective level of authorization according to
|
137 |
-
the maintained hierarchy.
|
138 |
-
form_data: UserAuth. Sign-in credentials entered by the users at the
|
139 |
-
time of signing in.
|
140 |
-
|
141 |
-
Raises:
|
142 |
-
LoginFailedException: If no user with entered credentials exists.
|
143 |
-
"""
|
144 |
-
|
145 |
-
Code
|
146 |
-
def token_validation(token: str) -> bool:
|
147 |
-
try:
|
148 |
-
payload = jwt.decode(
|
149 |
-
token, settings.JWT_SECRET_KEY, algorithms=[settings.ALGORITHM]
|
150 |
-
)
|
151 |
-
token_data = TokenPayload(**payload)
|
152 |
-
|
153 |
-
if datetime.fromtimestamp(token_data.exp) < datetime.now():
|
154 |
-
return False
|
155 |
-
|
156 |
-
except(jwt.JWTError, ValidationError):
|
157 |
-
return False
|
158 |
-
|
159 |
-
return True
|
160 |
-
|
161 |
-
"""Decodes JWTs to check their validity by inspecting expiry and
|
162 |
-
authorization code.
|
163 |
-
|
164 |
-
Args:
|
165 |
-
token: str. Authenticated `access_token` of the user.
|
166 |
-
|
167 |
-
Returns:
|
168 |
-
bool value to indicate validity of the access tokens.
|
169 |
-
|
170 |
-
Raises:
|
171 |
-
jwt.JWTError: If decode fails.
|
172 |
-
ValidationError: If JWTs are not in RFC 7519 standard.
|
173 |
-
"""
|
174 |
-
|
175 |
-
Code
|
176 |
-
{instruction} <|im_end|>
|
177 |
-
<|im_start|>assistant
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TechdocsAPI/backend/utils/prompt.txt
CHANGED
@@ -1,17 +1,16 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
Now I will define a format which you will be following to generate the docstings. For each function definition, you will generate the following:
|
4 |
1. Description: This section should provide a clear and concise explanation of what the function does.
|
|
|
5 |
2. Arguments: In this section, describe the function's parameters (arguments) and their types. Include both mandatory and optional arguments. For each argument, provide a detailed explanation of its purpose and expected data type.
|
|
|
6 |
3. Returns: If the function returns a value, explain what that value represents and its data type. If the function doesn't return anything (i.e., it has a None return type), mention that explicitly.
|
|
|
7 |
4. Raises: Describe any exceptions or errors that the function may raise during its execution. Specify the conditions under which these exceptions might occur.
|
8 |
-
However, you must generate the final docstrings in a specific format which you should be able to figure out by looking at the following examples.
|
9 |
|
10 |
Please follow Google docstring style guidelines to generate a docstring for the query function given by the user.
|
11 |
|
12 |
-
Instructions: {instruction}
|
13 |
|
14 |
Your task is to generate a docstring for the above query.
|
15 |
-
|
16 |
-
|
17 |
-
<|im_start|>assistant
|
|
|
1 |
+
You are an AI Coding Assistant, and your role is to create comprehensive and highly informative docstrings for Python functions entered by the user. A well-structured docstring is essential for helping developers understand and use the function effectively. A standard Python docstring typically consists of the following sections:
|
2 |
+
|
|
|
3 |
1. Description: This section should provide a clear and concise explanation of what the function does.
|
4 |
+
|
5 |
2. Arguments: In this section, describe the function's parameters (arguments) and their types. Include both mandatory and optional arguments. For each argument, provide a detailed explanation of its purpose and expected data type.
|
6 |
+
|
7 |
3. Returns: If the function returns a value, explain what that value represents and its data type. If the function doesn't return anything (i.e., it has a None return type), mention that explicitly.
|
8 |
+
|
9 |
4. Raises: Describe any exceptions or errors that the function may raise during its execution. Specify the conditions under which these exceptions might occur.
|
|
|
10 |
|
11 |
Please follow Google docstring style guidelines to generate a docstring for the query function given by the user.
|
12 |
|
13 |
+
Instructions: {instruction}
|
14 |
|
15 |
Your task is to generate a docstring for the above query.
|
16 |
+
Response:
|
|
|
|
TechdocsAPI/requirements.txt
CHANGED
@@ -5,11 +5,8 @@ pydantic==1.10.12
|
|
5 |
python-jose[cryptography]
|
6 |
passlib[bcrypt]
|
7 |
mysql-connector-python
|
8 |
-
mysql
|
9 |
-
# langchain-google-genai
|
10 |
pydantic[email]
|
11 |
langchain
|
12 |
-
langchain-community
|
13 |
-
Pillow
|
14 |
-
jinja2
|
15 |
clarifai
|
|
|
|
|
|
5 |
python-jose[cryptography]
|
6 |
passlib[bcrypt]
|
7 |
mysql-connector-python
|
|
|
|
|
8 |
pydantic[email]
|
9 |
langchain
|
|
|
|
|
|
|
10 |
clarifai
|
11 |
+
Pillow
|
12 |
+
fastapi_mail==1.3.1
|
scripts/test.py
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
from dotenv import load_dotenv
|
2 |
-
|
3 |
load_dotenv()
|
4 |
import os
|
5 |
|
6 |
import mysql.connector
|
7 |
from mysql.connector import errorcode
|
8 |
|
9 |
-
config
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
}
|
15 |
|
16 |
-
print(
|
17 |
|
18 |
try:
|
19 |
cnx = mysql.connector.connect(**config)
|
@@ -30,12 +29,8 @@ else:
|
|
30 |
|
31 |
cursor.execute("DROP TABLE IF EXISTS api_key")
|
32 |
cursor.execute("DROP TABLE IF EXISTS auth")
|
33 |
-
cursor.execute(
|
34 |
-
|
35 |
-
)
|
36 |
-
cursor.execute(
|
37 |
-
"CREATE TABLE IF NOT EXISTS api_key(username VARCHAR(15),apikey TEXT, FOREIGN KEY (username) REFERENCES auth(username))"
|
38 |
-
)
|
39 |
cursor.execute("ALTER TABLE auth ADD is_verified BOOLEAN NOT NULL DEFAULT(false)")
|
40 |
|
41 |
# QUERY = ('INSERT INTO {coll_name} '
|
@@ -51,6 +46,9 @@ else:
|
|
51 |
# for i in cursor.fetchall():
|
52 |
# print(i)
|
53 |
|
|
|
|
|
|
|
54 |
cnx.commit()
|
55 |
cursor.close()
|
56 |
cnx.close()
|
|
|
1 |
from dotenv import load_dotenv
|
|
|
2 |
load_dotenv()
|
3 |
import os
|
4 |
|
5 |
import mysql.connector
|
6 |
from mysql.connector import errorcode
|
7 |
|
8 |
+
config={
|
9 |
+
'host':os.environ.get("HOSTNAME"),
|
10 |
+
'user':os.environ.get("UID"),
|
11 |
+
'password':os.environ.get("PASSWORD"),
|
12 |
+
'database':os.environ.get("DATABASE")
|
13 |
}
|
14 |
|
15 |
+
print(config)
|
16 |
|
17 |
try:
|
18 |
cnx = mysql.connector.connect(**config)
|
|
|
29 |
|
30 |
cursor.execute("DROP TABLE IF EXISTS api_key")
|
31 |
cursor.execute("DROP TABLE IF EXISTS auth")
|
32 |
+
cursor.execute("CREATE TABLE IF NOT EXISTS auth(username VARCHAR(15) PRIMARY KEY, password TEXT, email VARCHAR(50))")
|
33 |
+
cursor.execute("CREATE TABLE IF NOT EXISTS api_key(username VARCHAR(15),apikey TEXT, FOREIGN KEY (username) REFERENCES auth(username))")
|
|
|
|
|
|
|
|
|
34 |
cursor.execute("ALTER TABLE auth ADD is_verified BOOLEAN NOT NULL DEFAULT(false)")
|
35 |
|
36 |
# QUERY = ('INSERT INTO {coll_name} '
|
|
|
46 |
# for i in cursor.fetchall():
|
47 |
# print(i)
|
48 |
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
cnx.commit()
|
53 |
cursor.close()
|
54 |
cnx.close()
|
temp.py
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
import requests
|
2 |
-
import json
|
3 |
-
|
4 |
-
|
5 |
-
def post_request(url, data, headers=None):
|
6 |
-
data = json.dumps(data)
|
7 |
-
headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
|
8 |
-
response = requests.post(url, data=data, headers=headers)
|
9 |
-
return response.status_code, response.json()
|
10 |
-
|
11 |
-
email_body_params = {
|
12 |
-
"username": "mayo",
|
13 |
-
"verify_link": "new hai yeh bro agar ye aya toh maja aya"
|
14 |
-
}
|
15 |
-
details = {
|
16 |
-
"recipients": ["mayureshagashe2002@outlook.com", "alfatrion123@gmail.com"],
|
17 |
-
"subject": "Welcome to Techdocs:[Account Verification]",
|
18 |
-
"template_name": "email_verification.html",
|
19 |
-
"template_kwargs": email_body_params
|
20 |
-
}
|
21 |
-
print(post_request("https://api.techdocs.caffienecrewhacks.tech/api/send", details))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testing/logs_2024_01_07_16_08_04.log
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
2024-01-07 16:08:04,077:INFO:Logs generated at "testing\logs_2024_01_07_16_08_04.log". For detailed logs check the file.
|
2 |
-
2024-01-07 16:08:04,078:INFO:Docstrings generation started for "testing/*.py" files
|
3 |
-
2024-01-07 16:08:04,078:INFO:Working on "testing\*.py"
|
4 |
-
2024-01-07 16:08:04,093:INFO:Working on "testing\test.py"
|
5 |
-
2024-01-07 16:08:07,627:INFO:Docstring generated for def add
|
6 |
-
2024-01-07 16:08:07,629:INFO:==================================================
|
7 |
-
2024-01-07 16:08:07,631:INFO:Docstrings generation completed for "testing\.*py". Time Taken: 0:00:03.552157
|
8 |
-
2024-01-07 16:08:07,632:INFO:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
9 |
-
2024-01-07 16:08:07,632:INFO:Working on "testing\pack\*.py"
|
10 |
-
2024-01-07 16:08:07,635:INFO:Working on "testing\pack\DBQueries.py"
|
11 |
-
2024-01-07 16:08:13,942:INFO:Docstring generated for def insert_to_database
|
12 |
-
2024-01-07 16:08:18,222:INFO:Docstring generated for def fetch_data_from_database
|
13 |
-
2024-01-07 16:08:25,204:INFO:Docstring generated for def update_data_in_database
|
14 |
-
2024-01-07 16:08:25,206:INFO:==================================================
|
15 |
-
2024-01-07 16:08:25,207:INFO:Working on "testing\pack\functools.py"
|
16 |
-
2024-01-07 16:08:30,500:INFO:Docstring generated for def get_access_token
|
17 |
-
2024-01-07 16:08:34,476:INFO:Docstring generated for def request_inference
|
18 |
-
2024-01-07 16:08:40,210:INFO:Docstring generated for def update_file
|
19 |
-
2024-01-07 16:08:45,481:INFO:Docstring generated for def issue_api_key
|
20 |
-
2024-01-07 16:08:50,504:INFO:Docstring generated for def signup
|
21 |
-
2024-01-07 16:08:50,507:INFO:==================================================
|
22 |
-
2024-01-07 16:08:50,508:INFO:Docstrings generation completed for "testing\pack\.*py". Time Taken: 0:00:42.875458
|
23 |
-
2024-01-07 16:08:50,508:INFO:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testing/pack/DBQueries.py
CHANGED
@@ -9,17 +9,31 @@ class DBQueries:
|
|
9 |
|
10 |
@classmethod
|
11 |
def insert_to_database(cls, table_name: str, data: Union[Tuple, List[Tuple]], cols: List[str]=None):
|
12 |
-
"""
|
|
|
13 |
|
14 |
Args:
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
Raises:
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
con = DBConnection.get_client()
|
24 |
cursor = con.cursor()
|
25 |
QUERY = f"INSERT INTO {{table_name}} ({','.join(cols)}) VALUES ".format(table_name=table_name)
|
@@ -33,16 +47,38 @@ class DBQueries:
|
|
33 |
|
34 |
@classmethod
|
35 |
def fetch_data_from_database(cls, table_name: str, cols_to_fetch: Union[str, List[str]], where_clause: str=None):
|
36 |
-
"""
|
|
|
|
|
37 |
|
38 |
Args:
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
Returns:
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
con = DBConnection.get_client()
|
47 |
cursor = con.cursor()
|
48 |
if isinstance(cols_to_fetch, str):
|
@@ -56,25 +92,21 @@ class DBQueries:
|
|
56 |
|
57 |
@classmethod
|
58 |
def update_data_in_database(cls, table_name: str, cols_to_update: Union[str, List[str]], where_clause: str=None, new_values: Union[str, List[str]]=None):
|
59 |
-
"""
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
list of strings.
|
68 |
-
where_clause: str. Conditions to be met by the rows to be updated.
|
69 |
-
If no condition is to be imposed, pass it as None.
|
70 |
-
new_values: Union[str, List[str]]. New values to be set in the
|
71 |
-
columns. If a single column is to be updated, pass the
|
72 |
-
new value as a string. If multiple columns are to be
|
73 |
-
updated, pass the new values as a list of strings.
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
78 |
con = DBConnection.get_client()
|
79 |
cursor = con.cursor()
|
80 |
if isinstance(cols_to_update, str):
|
|
|
9 |
|
10 |
@classmethod
|
11 |
def insert_to_database(cls, table_name: str, data: Union[Tuple, List[Tuple]], cols: List[str]=None):
|
12 |
+
"""
|
13 |
+
This method is used to insert data into a specified table in the database.
|
14 |
|
15 |
Args:
|
16 |
+
table_name (str): The name of the table into which data will be inserted.
|
17 |
+
data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.
|
18 |
+
cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.
|
19 |
|
20 |
Raises:
|
21 |
+
None
|
22 |
+
|
23 |
+
Returns:
|
24 |
+
None
|
25 |
+
|
26 |
+
"""
|
27 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n\n '
|
28 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n\n '
|
29 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n\n '
|
30 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n\n '
|
31 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n\n '
|
32 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n\n '
|
33 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n\n '
|
34 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n\n '
|
35 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples, where each tuple represents a row of data.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n '
|
36 |
+
'\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. This can be a tuple or a list of tuples.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume that all columns are included. Defaults to None.\n\n Raises:\n None\n\n Returns:\n None\n '
|
37 |
con = DBConnection.get_client()
|
38 |
cursor = con.cursor()
|
39 |
QUERY = f"INSERT INTO {{table_name}} ({','.join(cols)}) VALUES ".format(table_name=table_name)
|
|
|
47 |
|
48 |
@classmethod
|
49 |
def fetch_data_from_database(cls, table_name: str, cols_to_fetch: Union[str, List[str]], where_clause: str=None):
|
50 |
+
"""
|
51 |
+
This method is a class method that fetches data from a specified table in the database based on the provided column names and,
|
52 |
+
optionally, a WHERE clause.
|
53 |
|
54 |
Args:
|
55 |
+
- table_name: A string representing the name of the table from which to fetch data.
|
56 |
+
- cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,
|
57 |
+
it will be treated as a comma-separated list of column names.
|
58 |
+
- where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.
|
59 |
|
60 |
Returns:
|
61 |
+
- cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,
|
62 |
+
and contains the values of the fetched columns in the order specified.
|
63 |
+
|
64 |
+
Raises:
|
65 |
+
- No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which
|
66 |
+
are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.
|
67 |
+
|
68 |
"""
|
69 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n\n '
|
70 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n\n '
|
71 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n\n '
|
72 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n\n '
|
73 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n\n '
|
74 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n\n '
|
75 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n\n '
|
76 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n\n '
|
77 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n '
|
78 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n '
|
79 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n '
|
80 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n '
|
81 |
+
'\n This method is a class method that fetches data from a specified table in the database based on the provided column names and,\n optionally, a WHERE clause.\n\n Args:\n - table_name: A string representing the name of the table from which to fetch data.\n - cols_to_fetch: A string or a list of strings representing the column(s) to fetch from the table. If a single string,\n it will be treated as a comma-separated list of column names.\n - where_clause: An optional string representing a WHERE clause to filter the fetched data. Defaults to None.\n\n Returns:\n - cursor.fetchall(): A list of tuples representing the fetched data. Each tuple corresponds to a row in the result set,\n and contains the values of the fetched columns in the order specified.\n\n Raises:\n - No exceptions are explicitly raised by this method. However, underlying database operations may raise exceptions, which\n are not handled or propagated by this method. It is the responsibility of the caller to handle any exceptions that may occur.\n '
|
82 |
con = DBConnection.get_client()
|
83 |
cursor = con.cursor()
|
84 |
if isinstance(cols_to_fetch, str):
|
|
|
92 |
|
93 |
@classmethod
|
94 |
def update_data_in_database(cls, table_name: str, cols_to_update: Union[str, List[str]], where_clause: str=None, new_values: Union[str, List[str]]=None):
|
95 |
+
"""
|
96 |
+
This method updates the data in a specified table in the database.
|
97 |
|
98 |
+
Args:
|
99 |
+
table_name (str): The name of the table in which the data needs to be updated.
|
100 |
+
cols_to_update (Union[str, List[str]]): The column(s) to be updated. If a single string, it should end with '=%s'. If a list, it should contain strings, each ending with '=%s'.
|
101 |
+
where_clause (str, optional): The WHERE clause of the SQL query. Defaults to None.
|
102 |
+
new_values (Union[str, List[str]], optional): The new values to be updated in the columns. If a single string, it should be a list of new values. If a list, it should contain the new values for each column. Defaults to None.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
Returns:
|
105 |
+
bool: Returns True if the data is successfully updated in the database.
|
106 |
+
|
107 |
+
Raises:
|
108 |
+
Exception: If the database connection fails or the query execution fails.
|
109 |
+
"""
|
110 |
con = DBConnection.get_client()
|
111 |
cursor = con.cursor()
|
112 |
if isinstance(cols_to_update, str):
|
testing/pack/functools.py
CHANGED
@@ -3,14 +3,21 @@ import requests
|
|
3 |
BASE_URL = 'https://caffeinecrew-techdocs.hf.space'
|
4 |
|
5 |
def get_access_token(data, return_refresh_token=False):
|
6 |
-
"""
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
Returns:
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
try:
|
15 |
url = BASE_URL + '/auth/login'
|
16 |
headers = {'accept': 'application/json'}
|
@@ -26,18 +33,25 @@ def get_access_token(data, return_refresh_token=False):
|
|
26 |
return None
|
27 |
|
28 |
def request_inference(config, code_block, max_retries=1):
|
29 |
-
"""
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
api key, and access token.
|
34 |
-
code_block: str. Code block for which inference is requested.
|
35 |
-
max_retries: int, optional. Number of retries to be made in case
|
36 |
-
of failure. Defaults to 1.
|
37 |
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
"""
|
|
|
|
|
41 |
if max_retries == 0:
|
42 |
return None
|
43 |
url = BASE_URL + '/api/inference'
|
@@ -53,30 +67,43 @@ def request_inference(config, code_block, max_retries=1):
|
|
53 |
return request_inference(config, code_block, max_retries=max_retries - 1)
|
54 |
|
55 |
def update_file(file_path, docstr_code):
|
56 |
-
"""
|
|
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
with open(file_path, 'w', errors='ignore') as file:
|
68 |
file.write(docstr_code)
|
69 |
|
70 |
def issue_api_key(config):
|
71 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
of the user.
|
76 |
|
77 |
Raises:
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
80 |
try:
|
81 |
headers = {'accept': 'application/json', 'Authorization': f"Bearer {config['access_token']}"}
|
82 |
response = requests.put(url=BASE_URL + '/auth/regenerate_api_key', headers=headers, data=json.dumps({'username': config['username']}))
|
@@ -87,17 +114,23 @@ def issue_api_key(config):
|
|
87 |
print(f'$ {e}')
|
88 |
|
89 |
def signup(config):
|
90 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
- 'username': The username of the new user.
|
95 |
-
- 'email': The email address of the new user.
|
96 |
-
- 'password': The password of the new user.
|
97 |
|
98 |
Raises:
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
101 |
try:
|
102 |
headers = {'accept': 'application/json'}
|
103 |
response = requests.post(url=BASE_URL + '/auth/signup', headers=headers, data=json.dumps(config))
|
|
|
3 |
BASE_URL = 'https://caffeinecrew-techdocs.hf.space'
|
4 |
|
5 |
def get_access_token(data, return_refresh_token=False):
|
6 |
+
"""
|
7 |
+
This function sends a POST request to the specified URL to get an access token.
|
8 |
+
|
9 |
+
Arguments:
|
10 |
+
data (dict): A dictionary containing the credentials required for authentication.
|
11 |
+
return_refresh_token (bool, optional): A flag to indicate if the refresh token should be returned. Defaults to False.
|
12 |
+
|
13 |
Returns:
|
14 |
+
str or tuple: If return_refresh_token is False, the function returns the access token as a string. If return_refresh_token is True, the function returns a tuple containing the access token and the refresh token.
|
15 |
+
|
16 |
+
Raises:
|
17 |
+
Exception: If an error occurs during the execution of the function, an Exception is raised.
|
18 |
+
"""
|
19 |
+
'\n This function sends a POST request to the specified URL to get an access token.\n \n Arguments:\n data (dict): A dictionary containing the credentials required for authentication.\n return_refresh_token (bool, optional): A flag to indicate if the refresh token should be returned. Defaults to False.\n \n Returns:\n str or tuple: If return_refresh_token is False, the function returns the access token as a string. If return_refresh_token is True, the function returns a tuple containing the access token and the refresh token.\n \n Raises:\n Exception: If an error occurs during the execution of the function, an Exception is raised.\n '
|
20 |
+
'\n This function sends a POST request to the specified URL to get an access token.\n \n Arguments:\n data (dict): A dictionary containing the credentials required for authentication.\n return_refresh_token (bool, optional): A flag to indicate if the refresh token should be returned. Defaults to False.\n \n Returns:\n str or tuple: If return_refresh_token is False, the function returns the access token as a string. If return_refresh_token is True, the function returns a tuple containing the access token and the refresh token.\n \n Raises:\n Exception: If an error occurs during the execution of the function, an Exception is raised.\n '
|
21 |
try:
|
22 |
url = BASE_URL + '/auth/login'
|
23 |
headers = {'accept': 'application/json'}
|
|
|
33 |
return None
|
34 |
|
35 |
def request_inference(config, code_block, max_retries=1):
|
36 |
+
"""
|
37 |
+
Usage: request_inference(config, code_block, max_retries=1)
|
38 |
|
39 |
+
Purpose:
|
40 |
+
This function sends a POST request to the API server to perform code inference.
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
Arguments:
|
43 |
+
- config (dict): A dictionary containing the necessary authentication details like 'access_token', 'api_key' and 'username'.
|
44 |
+
- code_block (str): The code block that needs to be inferenced.
|
45 |
+
- max_retries (int, optional): The maximum number of times the function should retry in case of an error. Defaults to 1.
|
46 |
+
|
47 |
+
Returns:
|
48 |
+
- str: The docstring of the inferenced code block.
|
49 |
+
|
50 |
+
Raises:
|
51 |
+
- Exception: If the maximum number of retries (specified by max_retries) is reached and the API server still returns an error.
|
52 |
"""
|
53 |
+
"\nUsage: request_inference(config, code_block, max_retries=1)\n\nPurpose:\nThis function sends a POST request to the API server to perform code inference.\n\nArguments:\n- config (dict): A dictionary containing the necessary authentication details like 'access_token', 'api_key' and 'username'.\n- code_block (str): The code block that needs to be inferenced.\n- max_retries (int, optional): The maximum number of times the function should retry in case of an error. Defaults to 1.\n\nReturns:\n- str: The docstring of the inferenced code block.\n\nRaises:\n- Exception: If the maximum number of retries (specified by max_retries) is reached and the API server still returns an error.\n"
|
54 |
+
"\nUsage: request_inference(config, code_block, max_retries=1)\n\nPurpose:\nThis function sends a POST request to the API server to perform code inference.\n\nArguments:\n- config (dict): A dictionary containing the necessary authentication details like 'access_token', 'api_key' and 'username'.\n- code_block (str): The code block that needs to be inferenced.\n- max_retries (int, optional): The maximum number of times the function should retry in case of an error. Defaults to 1.\n\nReturns:\n- str: The docstring of the inferenced code block.\n\nRaises:\n- Exception: If the maximum number of retries (specified by max_retries) is reached and the API server still returns an error.\n"
|
55 |
if max_retries == 0:
|
56 |
return None
|
57 |
url = BASE_URL + '/api/inference'
|
|
|
67 |
return request_inference(config, code_block, max_retries=max_retries - 1)
|
68 |
|
69 |
def update_file(file_path, docstr_code):
|
70 |
+
"""
|
71 |
+
This function updates the docstring of a Python file.
|
72 |
|
73 |
+
Arguments:
|
74 |
+
file_path (str): The path of the Python file to be updated.
|
75 |
+
docstr_code (str): The new docstring to be written to the file.
|
76 |
+
|
77 |
+
Returns:
|
78 |
+
None
|
79 |
|
80 |
+
Raises:
|
81 |
+
FileNotFoundError: If the specified file does not exist.
|
82 |
+
IOError: If there is an error while writing to the file.
|
83 |
+
"""
|
84 |
+
'\n This function performs some operation on the given arguments.\n\n Arguments:\n arg1 (int): The first argument. A positive integer.\n arg2 (float): The second argument. A positive floating point number.\n arg3 (str): The third argument. A string containing only alphabets.\n arg4 (bool): The fourth argument. A boolean value.\n\n Returns:\n None\n\n Raises:\n TypeError: If any argument is not of the expected type.\n ValueError: If arg1 is less than or equal to zero, or if arg2 is not a positive number, or if arg3 contains any non-alphabetic character, or if arg4 is not a boolean value.\n '
|
85 |
+
'\n This function updates the docstring of a Python file.\n\n Arguments:\n file_path (str): The path of the Python file to be updated.\n docstr_code (str): The new docstring to be written to the file.\n\n Returns:\n None\n\n Raises:\n FileNotFoundError: If the specified file does not exist.\n IOError: If there is an error while writing to the file.\n '
|
86 |
with open(file_path, 'w', errors='ignore') as file:
|
87 |
file.write(docstr_code)
|
88 |
|
89 |
def issue_api_key(config):
|
90 |
+
"""
|
91 |
+
This function generates a new API key for the given user.
|
92 |
+
|
93 |
+
Arguments:
|
94 |
+
config: dict, A dictionary containing the user's configuration details.
|
95 |
+
- access_token: str, The user's access token.
|
96 |
+
- username: str, The user's username.
|
97 |
|
98 |
+
Returns:
|
99 |
+
None, Prints the new API key to the console.
|
|
|
100 |
|
101 |
Raises:
|
102 |
+
Exception, If the API key generation fails. The error message will be printed to the console.
|
103 |
+
|
104 |
+
"""
|
105 |
+
"\n This function generates a new API key for the given user.\n\n Arguments:\n config: dict, A dictionary containing the user's configuration details.\n - access_token: str, The user's access token.\n - username: str, The user's username.\n\n Returns:\n None, Prints the new API key to the console.\n\n Raises:\n Exception, If the API key generation fails. The error message will be printed to the console.\n\n "
|
106 |
+
"\n This function generates a new API key for the given user.\n\n Arguments:\n config: A dictionary containing the user's configuration details.\n - access_token: str, The user's access token.\n - username: str, The user's username.\n\n Returns:\n None, prints the new API key to the console.\n\n Raises:\n Exception, If the API key generation fails. The error message will be printed to the console.\n "
|
107 |
try:
|
108 |
headers = {'accept': 'application/json', 'Authorization': f"Bearer {config['access_token']}"}
|
109 |
response = requests.put(url=BASE_URL + '/auth/regenerate_api_key', headers=headers, data=json.dumps({'username': config['username']}))
|
|
|
114 |
print(f'$ {e}')
|
115 |
|
116 |
def signup(config):
|
117 |
+
"""
|
118 |
+
This function is used to sign up a user with the provided configuration.
|
119 |
+
|
120 |
+
Arguments:
|
121 |
+
config: dict
|
122 |
+
A dictionary containing the user's signup information.
|
123 |
|
124 |
+
Returns:
|
125 |
+
None
|
|
|
|
|
|
|
126 |
|
127 |
Raises:
|
128 |
+
Exception
|
129 |
+
If the username or email already exists.
|
130 |
+
If there's a general error during the sign up process.
|
131 |
+
"""
|
132 |
+
"\n This function is used to sign up a user with the provided configuration.\n\n Arguments:\n config: dict\n A dictionary containing the user's signup information.\n\n Returns:\n None\n\n Raises:\n Exception\n If the username or email already exists.\n If there's a general error during the sign up process.\n "
|
133 |
+
'\ndef signup(config: dict) -> None:\n '
|
134 |
try:
|
135 |
headers = {'accept': 'application/json'}
|
136 |
response = requests.post(url=BASE_URL + '/auth/signup', headers=headers, data=json.dumps(config))
|
testing/test.py
CHANGED
@@ -1,11 +1,33 @@
|
|
1 |
def add(a, b):
|
2 |
-
"""
|
|
|
3 |
|
4 |
-
|
5 |
-
a (int): The first
|
6 |
-
b (int): The second
|
7 |
|
8 |
-
Returns:
|
9 |
-
int: The sum of
|
10 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
return a + b
|
|
|
1 |
def add(a, b):
|
2 |
+
"""
|
3 |
+
This function adds two integers.
|
4 |
|
5 |
+
Arguments:
|
6 |
+
a (int): The first integer to be added.
|
7 |
+
b (int): The second integer to be added.
|
8 |
|
9 |
+
Returns:
|
10 |
+
int: The sum of the two integers.
|
11 |
+
"""
|
12 |
+
'\n This function adds two integers.\n\n Arguments:\n a (int): The first integer to be added.\n b (int): The second integer to be added.\n\n Returns:\n int: The sum of the two integers.\n '
|
13 |
+
'\n This function adds two integers.\n\n Arguments:\n a (int): The first integer to be added.\n b (int): The second integer to be added.\n\n Returns:\n int: The sum of the two integers.\n '
|
14 |
+
'\n This function adds two integers.\n\n Arguments:\n a (int): The first integer to be added.\n b (int): The second integer to be added.\n\n Returns:\n int: The sum of the two integers.\n '
|
15 |
+
'\n This function adds two integers.\n\n Arguments:\n a (int): The first integer to be added.\n b (int): The second integer to be added.\n\n Returns:\n int: The sum of the two integers.\n '
|
16 |
+
'\n This function adds two integers.\n\n Arguments:\n a (int): The first integer to be added.\n b (int): The second integer to be added.\n\n Returns:\n int: The sum of the two integers.\n '
|
17 |
+
'\n This function adds two integers.\n\n Arguments:\n a (int): The first integer to be added.\n b (int): The second integer to be added.\n\n Returns:\n int: The sum of the two integers.\n '
|
18 |
+
'\n This function adds two integers.\n\n Arguments:\n a (int): The first integer to be added.\n b (int): The second integer to be added.\n\n Returns:\n int: The sum of the two integers.\n '
|
19 |
+
'\n This function adds two integers.\n\n Arguments:\n a (int): The first integer to be added.\n b (int): The second integer to be added.\n\n Returns:\n int: The sum of the two integers.\n '
|
20 |
+
'\n This function adds two integers.\n\n Arguments:\n a (int): The first integer to be added.\n b (int): The second integer to be added.\n\n Returns:\n int: The sum of the two integers.\n '
|
21 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
22 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
23 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
24 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
25 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
26 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
27 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
28 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
29 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
30 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
31 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
32 |
+
'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n '
|
33 |
return a + b
|