HemanthSai7 commited on
Commit
08fce87
·
1 Parent(s): c341d18

CLI testing complete

Browse files
testing/logs_2024_01_07_16_08_04.log ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,31 +9,17 @@ 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
- 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,38 +33,16 @@ class DBQueries:
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,21 +56,25 @@ class DBQueries:
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):
 
9
 
10
  @classmethod
11
  def insert_to_database(cls, table_name: str, data: Union[Tuple, List[Tuple]], cols: List[str]=None):
12
+ """Wrapper method to insert data to the database.
 
13
 
14
  Args:
15
+ table_name (str): Name of the table in the database.
16
+ data (Union[Tuple, List[Tuple]]): Data to be inserted in the table. It can be a single tuple or a list of tuples.
17
+ cols (List[str], optional): List of columns in the table. If not provided, all columns will be used.
18
 
19
  Raises:
20
+ ValidationError: If data is not a tuple or a list of tuples.
21
+ InternalServerError: If an error occurs while inserting data to the database.
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
 
34
  @classmethod
35
  def fetch_data_from_database(cls, table_name: str, cols_to_fetch: Union[str, List[str]], where_clause: str=None):
36
+ """Method to fetch data from database using a SQL query.
 
 
37
 
38
  Args:
39
+ table_name: str. Name of the table to fetch data from.
40
+ cols_to_fetch: Union[str, List[str]]. Columns to fetch from the table.
41
+ where_clause: str. Optional. Where clause to filter the data.
 
42
 
43
  Returns:
44
+ List. List of tuples containing the fetched data.
 
 
 
 
 
 
45
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  con = DBConnection.get_client()
47
  cursor = con.cursor()
48
  if isinstance(cols_to_fetch, str):
 
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
+ """Updates the values of the columns in the table defined by `table_name`
60
+ where the condition defined by `where_clause` is met.
 
 
 
 
 
 
61
 
62
+ Args:
63
+ table_name: str. Name of the table.
64
+ cols_to_update: Union[str, List[str]]. Column/s to be updated. If a
65
+ single column is to be updated, pass it as a string.
66
+ If multiple columns are to be updated, pass them as a
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
+ Returns:
76
+ bool. True if update was successful, False otherwise.
77
+ """
78
  con = DBConnection.get_client()
79
  cursor = con.cursor()
80
  if isinstance(cols_to_update, str):
testing/pack/functools.py CHANGED
@@ -3,21 +3,14 @@ import requests
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,25 +26,18 @@ def get_access_token(data, return_refresh_token=False):
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,43 +53,30 @@ Raises:
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,23 +87,17 @@ def issue_api_key(config):
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))
 
3
  BASE_URL = 'https://caffeinecrew-techdocs.hf.space'
4
 
5
  def get_access_token(data, return_refresh_token=False):
6
+ """Authenticates and returns the access token.
7
+
8
+ Args:
9
+ data: dict. User login credentials.
10
+
 
 
11
  Returns:
12
+ str. The access token.
13
+ """
 
 
 
 
 
14
  try:
15
  url = BASE_URL + '/auth/login'
16
  headers = {'accept': 'application/json'}
 
26
  return None
27
 
28
  def request_inference(config, code_block, max_retries=1):
29
+ """Request for inference from an external model.
 
 
 
 
30
 
31
+ Args:
32
+ config: Config. Configuration dictionary with model credentials,
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
+ Returns:
39
+ str: Docstring generated from the model.
 
 
 
40
  """
 
 
41
  if max_retries == 0:
42
  return None
43
  url = BASE_URL + '/api/inference'
 
53
  return request_inference(config, code_block, max_retries=max_retries - 1)
54
 
55
  def update_file(file_path, docstr_code):
56
+ """insert a single record or iterable of records to the database.
 
57
 
58
+ Args:
59
+ db_name (str): name of the database
60
+ coll_name (str): name of the collection
61
+ data (dict): data to be inserted
 
 
62
 
63
+ Returns:
64
+ An instance of class: pymongo.results.InsertOneResult or
65
+ pymongo.results.InsertManyResult
66
+ """
 
 
67
  with open(file_path, 'w', errors='ignore') as file:
68
  file.write(docstr_code)
69
 
70
  def issue_api_key(config):
71
+ """Issues an API key for a valid user
 
 
 
 
 
 
72
 
73
+ Args:
74
+ config (dict): Config dictionary containing `username` and `access_token`
75
+ of the user.
76
 
77
  Raises:
78
+ Exception: If API key generation fails.
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
  print(f'$ {e}')
88
 
89
  def signup(config):
90
+ """Sends a request to the server to create a new user account.
 
 
 
 
 
91
 
92
+ Args:
93
+ config (dict): A dictionary containing the following keys:
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
+ Exception: If the request fails or the status code is not 200.
100
+ """
 
 
 
 
101
  try:
102
  headers = {'accept': 'application/json'}
103
  response = requests.post(url=BASE_URL + '/auth/signup', headers=headers, data=json.dumps(config))
testing/test.py CHANGED
@@ -1,33 +1,11 @@
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
 
1
  def add(a, b):
2
+ """Computes and returns the sum of two numbers.
 
3
 
4
+ Args:
5
+ a (int): The first number.
6
+ b (int): The second number.
7
 
8
+ Returns:
9
+ int: The sum of a and b.
10
+ """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  return a + b