Skip to content

Commit

Permalink
fix bootstrapping issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Pwuts committed Oct 19, 2024
1 parent 40e846e commit 6dc9e0c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
8 changes: 4 additions & 4 deletions autogpt_platform/backend/backend/blocks/github/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
logger = logging.getLogger(__name__)


class GitHubBaseTriggerBlock(Block):
class GitHubTriggerBase:
class Input(BlockSchema):
credentials: GithubCredentialsInput = GithubCredentialsField("repo")
repo: str = SchemaField(
Expand All @@ -46,8 +46,8 @@ def run(self, input_data: Input, **kwargs) -> BlockOutput:
yield "sender", input_data.payload["sender"]


class GithubPullRequestTriggerBlock(GitHubBaseTriggerBlock):
class Input(GitHubBaseTriggerBlock.Input):
class GithubPullRequestTriggerBlock(GitHubTriggerBase, Block):
class Input(GitHubTriggerBase.Input):
class EventsFilter(BaseModel):
"""
https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request
Expand Down Expand Up @@ -77,7 +77,7 @@ class EventsFilter(BaseModel):

events: EventsFilter = SchemaField(description="The events to subscribe to")

class Output(GitHubBaseTriggerBlock.Output):
class Output(GitHubTriggerBase.Output):
number: int = SchemaField(description="The number of the affected pull request")
pull_request: dict = SchemaField(
description="Object representing the pull request"
Expand Down
3 changes: 2 additions & 1 deletion autogpt_platform/backend/backend/data/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ def __init__(
self.webhook_config.event_filter_input
]
if not (
isinstance(event_filter_field.annotation, BaseModel)
isinstance(event_filter_field.annotation, type)
and issubclass(event_filter_field.annotation, BaseModel)
and all(
field.annotation is bool
for field in event_filter_field.annotation.model_fields.values()
Expand Down
15 changes: 6 additions & 9 deletions autogpt_platform/backend/backend/data/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import uuid
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any, Literal, Optional
from typing import Any, Literal, Optional

import prisma.types
from prisma.models import AgentGraph, AgentGraphExecution, AgentNode, AgentNodeLink
Expand All @@ -11,13 +11,12 @@
from pydantic_core import PydanticUndefinedType

from backend.blocks.basic import AgentInputBlock, AgentOutputBlock
from backend.data.block import BlockInput, get_block, get_blocks
from backend.data.db import BaseDbModel, transaction
from backend.data.execution import ExecutionStatus
from backend.util import json

if TYPE_CHECKING:
from .integrations import Webhook
from .block import BlockInput, get_block, get_blocks
from .db import BaseDbModel, transaction
from .execution import ExecutionStatus
from .integrations import Webhook

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -61,12 +60,10 @@ class Node(BaseDbModel):
graph_version: int

webhook_id: Optional[str] = None
webhook: Optional["Webhook"] = None
webhook: Optional[Webhook] = None

@staticmethod
def from_db(node: AgentNode):
from .integrations import Webhook

if not node.AgentBlock:
raise ValueError(f"Invalid node {node.id}, invalid AgentBlock.")
obj = Node(
Expand Down
2 changes: 1 addition & 1 deletion autogpt_platform/backend/backend/data/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Webhook(BaseDbModel):

provider_webhook_id: str

attached_nodes: Optional[list[Node]] = None
attached_nodes: Optional[list["Node"]] = None

@staticmethod
def from_db(webhook: IntegrationWebhook):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ async def prune_webhook_if_dangling(
await integrations.delete_webhook(webhook.id)

# --8<-- [start:BaseWebhooksManager3]
@abstractmethod
@classmethod
@abstractmethod
async def validate_payload(
cls, webhook: integrations.Webhook, request: Request
) -> dict: ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


async def on_graph_activate(
graph: "Graph", get_credentials: Callable[[str], Credentials | None]
graph: "Graph", get_credentials: Callable[[str], "Credentials | None"]
):
"""
Hook to be called when a graph is activated/created.
Expand Down Expand Up @@ -50,7 +50,7 @@ async def on_graph_activate(


async def on_graph_deactivate(
graph: "Graph", get_credentials: Callable[[str], Credentials | None]
graph: "Graph", get_credentials: Callable[[str], "Credentials | None"]
):
"""
Hook to be called when a graph is deactivated/deleted.
Expand Down Expand Up @@ -83,7 +83,7 @@ async def on_node_activate(
user_id: str,
node: "Node",
*,
credentials: Optional[Credentials] = None,
credentials: Optional["Credentials"] = None,
) -> "Node":
"""Hook to be called when the node is activated/created"""

Expand Down Expand Up @@ -137,7 +137,7 @@ async def on_node_activate(
async def on_node_deactivate(
node: "Node",
*,
credentials: Optional[Credentials] = None,
credentials: Optional["Credentials"] = None,
webhooks_manager: Optional["BaseWebhooksManager"] = None,
) -> "Node":
"""Hook to be called when node is deactivated/deleted"""
Expand Down

0 comments on commit 6dc9e0c

Please sign in to comment.