-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bot Sorting #1205
base: master
Are you sure you want to change the base?
Bot Sorting #1205
Conversation
maheshsattala
commented
May 15, 2024
- Added code for the bot sorting with modified date and fixed the test cases for the same.
…st cases for the same.
WalkthroughWalkthroughThe recent updates enhance the bot management system by introducing a Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Out of diff range and nitpick comments (15)
kairon/api/app/routers/account.py (1)
Line range hint
1-1
: Remove unused importsfastapi.Form
andfastapi.Path
.- from fastapi import APIRouter, Depends, Security, Form, Path + from fastapi import APIRouter, Depends, Securitykairon/shared/account/processor.py (3)
Line range hint
91-91
: Avoid using bareexcept
statements.Using bare
except
statements can catch unexpected errors and make debugging difficult. Specify the exception type to catch only the intended exceptions.- except: + except DoesNotExist:
Line range hint
645-645
: Avoid using bareexcept
statements.Using bare
except
statements can catch unexpected errors and make debugging difficult. Specify the exception type to catch only the intended exceptions.- except: + except DoesNotExist:
Line range hint
813-813
: Remove unused import.The import
kairon.shared.data.processor.MongoProcessor
is not used in this file and should be removed to keep the code clean.- from kairon.shared.data.processor import MongoProcessor
tests/unit_test/api/api_processor_test.py (11)
Line range hint
2688-2688
: Useisinstance()
instead of comparing types directly.- assert all([i for i in temp if type(i) is dict]) + assert all([i for i in temp if isinstance(i, dict)])
Line range hint
25-25
: Remove the unused importkairon.api.app.routers.idp.get_idp_config
.- from kairon.api.app.routers.idp import get_idp_config
Line range hint
46-46
: Remove the redefined unused importAppException
.- from kairon.exceptions import AppException
Line range hint
47-47
: Remove the redefined unused importtime
.- import time
Line range hint
48-48
: Remove the redefined unused importIdpConfig
.- from kairon.idp.data_objects import IdpConfig
Line range hint
49-49
: Remove the redefined unused importsRegisterAccount
,EventConfig
,IDPConfig
,StoryRequest
,HttpActionParameters
, andPassword
.- from kairon.api.models import RegisterAccount, EventConfig, IDPConfig, StoryRequest, HttpActionParameters, Password
Line range hint
50-50
: Remove the unused importmongomock.MongoClient
.- from mongomock import MongoClient
Line range hint
1397-1397
: Remove the unused local variablestart_date
.- start_date = datetime.datetime.now()
Line range hint
1539-1539
: Remove the unused local variabledata_stack
.- data_stack = Utility.decode_limited_access_token(refresh)
Line range hint
1577-1577
: Remove the unused local variabledata_stack
.- data_stack = Utility.decode_limited_access_token(refresh)
Line range hint
1594-1594
: Fix the f-string without any placeholders.- assert f"Account frozen due to too many unsuccessful login attempts. Please come back in *" + assert "Account frozen due to too many unsuccessful login attempts. Please come back in *"
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- kairon/api/app/routers/account.py (1 hunks)
- kairon/shared/account/data_objects.py (1 hunks)
- kairon/shared/account/processor.py (1 hunks)
- tests/integration_test/services_test.py (4 hunks)
- tests/unit_test/api/api_processor_test.py (16 hunks)
Additional Context Used
Ruff (81)
kairon/api/app/routers/account.py (2)
1-1:
fastapi.Form
imported but unused
1-1:
fastapi.Path
imported but unusedkairon/shared/account/processor.py (3)
91-91: Do not use bare
except
645-645: Do not use bare
except
813-813:
kairon.shared.data.processor.MongoProcessor
imported but unusedtests/integration_test/services_test.py (57)
826-826: f-string without any placeholders
836-836: f-string without any placeholders
2414-2414: Local variable
response_three
is assigned to but never used
2638-2638: Comparison to
None
should becond is None
5463-5463: Avoid equality comparisons to
True
; useif actual["success"]:
for truth checks
5672-5672: Do not compare types, use
isinstance()
8497-8497: f-string without any placeholders
9037-9037: Local variable
response_one
is assigned to but never used
9041-9041: Local variable
response_two
is assigned to but never used
9045-9045: Local variable
response_three
is assigned to but never used
9068-9068: f-string without any placeholders
9211-9211: f-string without any placeholders
9691-9691: Local variable
response_delete_story_one
is assigned to but never used
9696-9696: Local variable
response_delete_story_two
is assigned to but never used
10385-10385: Local variable
payload_response
is assigned to but never used
12483-12483: f-string without any placeholders
14003-14003: Comparison to
None
should becond is None
14049-14049: Comparison to
None
should becond is None
16866-16866: f-string without any placeholders
16877-16877: f-string without any placeholders
16888-16888: f-string without any placeholders
16901-16901: f-string without any placeholders
16911-16911: f-string without any placeholders
16920-16920: f-string without any placeholders
16937-16937: f-string without any placeholders
16943-16943: f-string without any placeholders
16949-16949: f-string without any placeholders
16969-16969: f-string without any placeholders
16973-16973: f-string without any placeholders
16979-16979: f-string without any placeholders
16990-16990: f-string without any placeholders
17007-17007: f-string without any placeholders
17020-17020: f-string without any placeholders
17033-17033: f-string without any placeholders
17047-17047: f-string without any placeholders
17079-17079: f-string without any placeholders
18643-18643: Comparison to
None
should becond is None
18684-18684: Comparison to
None
should becond is None
18698-18698: Comparison to
None
should becond is None
19239-19239: f-string without any placeholders
20534-20534: Local variable
mock
is assigned to but never used
21891-21891: f-string without any placeholders
21926-21926: Comparison to
None
should becond is None
22015-22015: Comparison to
None
should becond is None
22041-22041: Comparison to
None
should becond is None
22281-22281: Avoid equality comparisons to
False
; useif not actual["data"]["logs"][1]["translate_responses"]:
for false checks
22282-22282: Avoid equality comparisons to
False
; useif not actual["data"]["logs"][1]["translate_actions"]:
for false checks
22298-22298: f-string without any placeholders
22544-22544: f-string without any placeholders
22596-22596: f-string without any placeholders
23254-23254: f-string without any placeholders
23268-23268: f-string without any placeholders
23361-23361: Local variable
passwrd_change_response
is assigned to but never used
23441-23441: Local variable
regsiter_response
is assigned to but never used
23473-23473: Local variable
regsiter_response
is assigned to but never used
23678-23678: Avoid equality comparisons to
False
; useif not actual["success"]:
for false checks
23682-23682: f-string without any placeholders
tests/unit_test/api/api_processor_test.py (19)
25-25:
kairon.api.app.routers.idp.get_idp_config
imported but unused
46-46: Redefinition of unused
AppException
from line 27
47-47: Redefinition of unused
time
from line 5
48-48: Redefinition of unused
IdpConfig
from line 28
49-49: Redefinition of unused
RegisterAccount
from line 26
49-49: Redefinition of unused
EventConfig
from line 26
49-49: Redefinition of unused
IDPConfig
from line 26
49-49: Redefinition of unused
StoryRequest
from line 26
49-49: Redefinition of unused
HttpActionParameters
from line 26
49-49: Redefinition of unused
Password
from line 26
50-50:
mongomock.MongoClient
imported but unused
1397-1397: Local variable
start_date
is assigned to but never used
1539-1539: Local variable
data_stack
is assigned to but never used
1577-1577: Local variable
data_stack
is assigned to but never used
1594-1594: f-string without any placeholders
1628-1628: Local variable
start_date
is assigned to but never used
1722-1722: Local variable
payload
is assigned to but never used
2569-2569: Local variable
idp_config
is assigned to but never used
2688-2688: Do not compare types, use
isinstance()
Additional comments not posted (29)
kairon/shared/account/data_objects.py (1)
85-85
: Addition ofmodified_at
field looks good and will help in tracking the last modification time of each bot.kairon/api/app/routers/account.py (1)
167-167
: The addition ofcurrent_user.get_user()
to theupdate_bot
function ensures that the user context is passed during bot updates. This change looks good.kairon/shared/account/processor.py (2)
212-217
: Ensure proper ordering of bots bymodified_at
.The logic to order bots by
modified_at
in descending order looks correct. This will ensure that the most recently modified bots appear first.
220-229
: Ensuremodified_at
is updated correctly.The logic to update the
modified_at
field if the user matches the bot's user looks correct. This ensures that the modification time is only updated by the bot's owner.tests/unit_test/api/api_processor_test.py (21)
126-126
: Ensure theuser
parameter is correctly passed and utilized in theAccountProcessor.update_bot
method.
195-195
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
207-207
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
219-219
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
229-229
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
239-239
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
266-266
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
278-278
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
291-291
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
313-313
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
323-323
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
337-337
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
344-344
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
356-356
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
379-379
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
410-410
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
418-418
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
424-424
: Ensure the bot ID retrieval logic aligns with the new bot ordering bymodified_at
.
445-447
: Ensure the assertions reflect the new bot ordering bymodified_at
.
451-454
: Ensure theuser
parameter is correctly passed and utilized in theAccountProcessor.update_bot
method.
458-462
: Ensure theuser
parameter is correctly passed and utilized in theAccountProcessor.update_bot
method.tests/integration_test/services_test.py (4)
1118-1125
: The changes in thetest_list_bots
function correctly update the bot index to reflect the new ordering logic. The assertions have been adjusted to match the new order of bots.
9557-9557
: The changes in thetest_add_intents_to_different_bot
function correctly update the bot index to reflect the new ordering logic.
9681-9681
: The changes in the_mock_training_limit
function correctly update the bot index to reflect the new ordering logic.
9720-9720
: The changes in thetest_delete_bot
function correctly update the bot index to reflect the new ordering logic.