-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
feat: added trigger methods on toolset #1225
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
LGTM 👍 |
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.
👍 Looks good to me! Reviewed everything up to 1e45b3d in 59 seconds
More details
- Looked at
120
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/composio/client/collections.py:937
- Draft comment:
The endpoint for deleting a trigger seems incorrect. It should beurl=str(self.endpoint / "instance" / id)
instead of including "delete" in the path. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
The comment suggests changing the URL structure, but I don't have strong evidence that the suggested change is correct. While other endpoints like disable() use a different URL pattern, that's not conclusive proof that delete() should match. The actual API endpoint structure would be determined by the backend, and without access to backend API docs or specs, I can't be certain which URL is correct.
I might be missing some implicit API design pattern that would make this obvious to someone more familiar with the codebase. The fact that other endpoints use a different pattern could be meaningful.
While there may be patterns in the API design, without clear documentation or specs, I can't be confident enough that the comment is correct. The current URL could be intentionally different for delete operations.
Delete the comment since we don't have strong evidence that the suggested URL change is correct. Making incorrect suggestions about API endpoints could cause confusion.
Workflow ID: wflow_1sQeMbtw6JyPoCig
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
def test_delete_trigger() -> None: | ||
"""Test `ComposioToolSet.delete_trigger` method.""" | ||
toolset = ComposioToolSet( | ||
api_key="s7cccojimwxj9od0344an" # [email protected] account key |
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.
Security concern: Hardcoded API key and account ID in test file. Consider using environment variables or test fixtures instead:
toolset = ComposioToolSet(
api_key=os.getenv("COMPOSIO_TEST_API_KEY")
)
enabled_trigger = toolset.client.triggers.enable(
name="GMAIL_NEW_GMAIL_MESSAGE",
connected_account_id=os.getenv("COMPOSIO_TEST_ACCOUNT_ID"),
...
)
python/composio/tools/toolset.py
Outdated
trigger_names=trigger_names | ||
) | ||
|
||
def delete_trigger(self, id: str): |
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.
Missing docstring and return type hint. Consider adding:
def delete_trigger(self, id: str) -> t.Dict[str, str]:
"""Delete a trigger by its ID.
Args:
id (str): The ID of the trigger to delete
Returns:
Dict[str, str]: Response containing the status of deletion
Raises:
ComposioClientError: If trigger deletion fails
"""
return self.client.triggers.delete(id=id)
python/composio/tools/toolset.py
Outdated
@@ -1495,6 +1497,25 @@ def get_action(self, action: ActionType) -> ActionModel: | |||
|
|||
def get_trigger(self, trigger: TriggerType) -> TriggerModel: | |||
return self.client.triggers.get(trigger_names=[trigger]).pop() | |||
|
|||
def get_trigger_config_scheme(self, trigger: TriggerType) -> TriggerConfigModel: |
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.
Missing docstring and type hints could be improved. Consider:
def get_trigger_config_scheme(self, trigger: TriggerType) -> TriggerConfigModel:
"""Get the configuration schema for a specific trigger.
Args:
trigger (TriggerType): The type of trigger to get config scheme for
Returns:
TriggerConfigModel: The configuration schema model
Raises:
ComposioClientError: If trigger type is invalid or not found
"""
return self.client.triggers.get(trigger_names=[trigger]).pop().config
python/composio/tools/toolset.py
Outdated
def get_trigger_config_scheme(self, trigger: TriggerType) -> TriggerConfigModel: | ||
return self.client.triggers.get(trigger_names=[trigger]).pop().config | ||
|
||
def get_active_triggers(self, |
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.
Consider improving type hints and adding docstring:
def get_active_triggers(
self,
trigger_ids: t.Optional[t.List[str]] = None,
connected_account_ids: t.Optional[t.List[str]] = None,
integration_ids: t.Optional[t.List[str]] = None,
trigger_names: t.Optional[t.List[t.Union[str, Trigger]]] = None
) -> t.List[ActiveTriggerModel]:
"""Retrieve active triggers based on various filter criteria.
Args:
trigger_ids: Optional list of trigger IDs to filter by
connected_account_ids: Optional list of connected account IDs
integration_ids: Optional list of integration IDs
trigger_names: Optional list of trigger names or Trigger enum values
Returns:
List[ActiveTriggerModel]: List of active triggers matching the criteria
Raises:
ComposioClientError: If retrieval fails
"""
return self.client.active_triggers.get(
trigger_ids=trigger_ids,
connected_account_ids=connected_account_ids,
integration_ids=integration_ids,
trigger_names=trigger_names
)
Code Review SummaryOverall, the changes look good but there are some areas that need improvement: Strengths:
Areas for Improvement:
The code is functionally sound but would benefit from these improvements for better maintainability and security. Rating: 7/10 - Good functionality but needs documentation and security improvements. |
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.
👍 Looks good to me! Incremental review on b304fcf in 28 seconds
More details
- Looked at
114
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/tests/test_tools/test_toolset.py:52
- Draft comment:
Avoid using hardcoded API keys in tests for security reasons. Consider using a mock or a fixture instead. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_iN1nLZ2MuE2AwkGY
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 95f9ed0 in 12 seconds
More details
- Looked at
19
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/composio/tools/toolset.py:905
- Draft comment:
Uset.Optional
for type hinting optional parameters for consistency and readability. This change is correctly applied in theget_active_triggers
method. - Reason this comment was not posted:
Confidence changes required:0%
The PR changes the type hinting for optional parameters in theget_active_triggers
method. This is a good practice as it makes the code more readable and consistent with the rest of the codebase.
Workflow ID: wflow_iZQFMqp7NQpXhShw
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on e069ccf in 12 seconds
More details
- Looked at
13
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/composio/tools/toolset.py:908
- Draft comment:
The change fromTrigger
toTriggerType
in the type hint is correct and aligns with the importedTriggerType
. Ensure that all usages oftrigger_names
are compatible with this type change. - Reason this comment was not posted:
Confidence changes required:0%
The change fromTrigger
toTriggerType
in the type hint is correct based on the imports and usage context.
Workflow ID: wflow_XcnwmIQCcJKfxTUC
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 55d6730 in 11 seconds
More details
- Looked at
22
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/composio/tools/toolset.py:47
- Draft comment:
The removal of theTrigger
import is correct as it is not used in the file. - Reason this comment was not posted:
Confidence changes required:0%
The import statement forTrigger
is removed, but it is not used anywhere in the file. This change is correct and does not affect the functionality.
Workflow ID: wflow_fM5LnzeqvbGDQp1f
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on 56751b7 in 33 seconds
More details
- Looked at
47
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/tests/test_tools/test_toolset.py:52
- Draft comment:
Consider adding a check to ensureCOMPOSIO_API_KEY
is set before using it to initializeComposioToolSet
. This will prevent potentialNoneType
errors if the environment variable is not set. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
- The comment is about a real potential issue - null API keys could cause problems. 2. However, looking at the full file, this is already well-handled by the codebase. 3. There is a specific test case test_api_key_missing that verifies the error handling. 4. The code already has proper error handling via ApiKeyNotProvidedError. 5. The comment is suggesting something that is already implemented.
I could be wrong if the test case doesn't actually cover all code paths, or if there are edge cases not handled by the existing error handling.
The test case explicitly tests the error handling by setting an empty API key and verifying the error message. The error handling appears comprehensive.
Delete the comment because the suggested check is already implemented and tested via test_api_key_missing.
Workflow ID: wflow_Fjb4V7mfUEFt5req
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
python/composio/tools/toolset.py
Outdated
@@ -895,6 +897,26 @@ def get_action(self, action: ActionType) -> ActionModel: | |||
def get_trigger(self, trigger: TriggerType) -> TriggerModel: | |||
return self.client.triggers.get(trigger_names=[trigger]).pop() | |||
|
|||
def get_trigger_config_scheme(self, trigger: TriggerType) -> TriggerConfigModel: | |||
return self.client.triggers.get(trigger_names=[trigger]).pop().config |
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.
return self.client.triggers.get(trigger_names=[trigger]).pop().config | |
return self.get_trigger(trigger=trigger).config |
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.
👍 Looks good to me! Incremental review on b204879 in 16 seconds
More details
- Looked at
42
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. python/composio/tools/toolset.py:901
- Draft comment:
Refactoredget_trigger_config_scheme
to useget_trigger
method for better code reuse. No issues found. - Reason this comment was not posted:
Confidence changes required:0%
The methodget_trigger_config_scheme
was updated to useget_trigger
method, which is a good change for code reuse. No issues here.
2. python/composio/tools/toolset.py:918
- Draft comment:
Updateddelete_trigger
method to include return typet.Dict
. This is a good practice for type hinting. No issues found. - Reason this comment was not posted:
Confidence changes required:0%
The return type ofdelete_trigger
method was updated tot.Dict
, which is a good practice for type hinting. No issues here.
Workflow ID: wflow_yat4WWlCbyjvzt9n
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Fixes ENG-2758
Added some trigger methods on toolset to view config, list active triggers and delete triggers.
Important
Add methods to
ComposioToolSet
for managing triggers, including viewing configurations, listing active triggers, and deleting triggers, with corresponding tests.get_trigger_config_scheme()
toComposioToolSet
for retrieving trigger configuration.get_active_triggers()
toComposioToolSet
for listing active triggers.delete_trigger()
toComposioToolSet
for deleting triggers.delete()
method toTriggers
class incollections.py
for deleting a trigger.test_get_trigger_config_scheme()
intest_toolset.py
to test trigger config retrieval.test_delete_trigger()
intest_toolset.py
to test trigger deletion.This description was created by for b204879. It will automatically update as commits are pushed.