Skip to content

Commit

Permalink
Fix misc bugs (#816)
Browse files Browse the repository at this point in the history
<!-- ELLIPSIS_HIDDEN -->



> [!IMPORTANT]
> Renames `triggers` to `trigger_names` in several files, adds an
environment variable to disable version checks, and removes unnecessary
warnings.
> 
>   - **Behavior**:
> - Change parameter `triggers` to `trigger_names` in `triggers.get()`
calls in `triggers.py`, `collections.py`, and `toolset.py`.
> - Add environment variable `COMPOSIO_DISABLE_VERSION_CHECK` in
`warnings.py` to disable version checks.
>   - **Misc**:
> - Remove `warnings.simplefilter` calls in `repomap.py` and
`toolset.py`.
>     - Fix comment typo in `triggers.mdx`.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=SamparkAI%2Fcomposio&utm_source=github&utm_medium=referral)<sup>
for 25f025e. It will automatically
update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
angrybayblade authored Nov 4, 2024
1 parent b43af06 commit 64f5ef3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/patterns/functions/triggers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Fetch the trigger using its name and verify if it exists.

<CodeGroup>
```python python
triggers = composio_client.triggers.get(trigger_ids=[trigger_name]) # Get the triggers
triggers = composio_client.triggers.get(trigger_names=[trigger_name]) # Get the triggers

if len(triggers) == 0:
raise Exception("Trigger not found") # Handle incorrect trigger name
Expand Down
4 changes: 2 additions & 2 deletions python/composio/cli/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _triggers(
@handle_exceptions()
@pass_context
def _show(context: Context, name: str) -> None:
(trigger,) = context.client.triggers.get(triggers=[name])
(trigger,) = context.client.triggers.get(trigger_names=[name])

context.console.print(f"• Showing: [green][bold]{name}[/bold][/green]")
context.console.print(
Expand Down Expand Up @@ -149,7 +149,7 @@ class EnableTriggerExamples(HelpfulCmdBase, click.Command):
def _enable_trigger(context: Context, name: str) -> None:
"""Enable a trigger for an app"""
context.console.print(f"Enabling trigger [green]{name}[/green]")
triggers = context.client.triggers.get(triggers=[name])
triggers = context.client.triggers.get(trigger_names=[name])
if len(triggers) == 0:
raise click.ClickException(f"Trigger with name {name} not found")
trigger = triggers[0]
Expand Down
6 changes: 3 additions & 3 deletions python/composio/client/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ def __init__(self, client: BaseClient) -> None:

def get( # type: ignore
self,
triggers: t.Optional[t.List[TriggerType]] = None,
trigger_names: t.Optional[t.List[TriggerType]] = None,
apps: t.Optional[t.List[str]] = None,
) -> t.List[TriggerModel]:
"""
Expand All @@ -736,8 +736,8 @@ def get( # type: ignore
:return: List of triggers filtered by provided parameters
"""
queries = {}
if triggers is not None and len(triggers) > 0:
queries["triggerIds"] = to_trigger_names(triggers)
if trigger_names is not None and len(trigger_names) > 0:
queries["triggerIds"] = to_trigger_names(trigger_names)
if apps is not None and len(apps) > 0:
queries["appNames"] = ",".join(apps)
return super().get(queries=queries)
Expand Down
5 changes: 0 additions & 5 deletions python/composio/tools/local/base/utils/repomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import math
import os
import shutil
import warnings
from collections import Counter, defaultdict, namedtuple
from importlib import resources
from pathlib import Path
Expand All @@ -17,10 +16,6 @@
)


# Suppress FutureWarning from tree_sitter
warnings.simplefilter("ignore", category=FutureWarning)


# Define a named tuple for storing tag information
Tag = namedtuple("Tag", ["rel_fname", "fname", "line", "name", "kind"])

Expand Down
5 changes: 1 addition & 4 deletions python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@
ProcessorType = te.Literal["pre", "post", "schema"]
AuthSchemeType = t.Literal["OAUTH2", "OAUTH1", "API_KEY", "BASIC", "BEARER_TOKEN"]

# Enable deprecation warnings
warnings.simplefilter("always", DeprecationWarning)


class IntegrationParams(te.TypedDict):

Expand Down Expand Up @@ -1071,7 +1068,7 @@ def get_action(self, action: ActionType) -> ActionModel:
return self.client.actions.get(actions=[action]).pop()

def get_trigger(self, trigger: TriggerType) -> TriggerModel:
return self.client.triggers.get(triggers=[trigger]).pop()
return self.client.triggers.get(trigger_names=[trigger]).pop()

def get_integration(self, id: str) -> IntegrationModel:
return self.client.integrations.get(id=id)
Expand Down
17 changes: 12 additions & 5 deletions python/composio/utils/warnings.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
"""Composio version helpers."""

import os

import requests
import rich
from semver import VersionInfo


COMPOSIO_PYPI_METADATA = "https://pypi.org/pypi/composio-core/json"


def create_latest_version_warning_hook(version: str):
def latest_version_warning() -> None:
try:
request = requests.get(
"https://pypi.org/pypi/composio-core/json",
timeout=10.0,
)
if (
os.environ.get("COMPOSIO_DISABLE_VERSION_CHECK", "false").lower()
== "true"
):
return

request = requests.get(COMPOSIO_PYPI_METADATA, timeout=10.0)
if request.status_code != 200:
return

data = request.json()

current_version = VersionInfo.parse(version)
latest_version = VersionInfo.parse(data["info"]["version"])

Expand Down

0 comments on commit 64f5ef3

Please sign in to comment.