1
1
from typing import Literal
2
2
from dotenv import load_dotenv
3
- from fastapi import Depends , FastAPI , Request
3
+ from fastapi import FastAPI , Request
4
4
5
5
from codegen .extensions .github .types .pull_request import PullRequestLabeledEvent
6
6
load_dotenv (".env" )
11
11
from codegen .extensions .events .codegen_app import CodegenApp
12
12
from codegen .extensions .linear .types import LinearEvent
13
13
from codegen .extensions .slack .types import SlackEvent
14
- from codegen .git .clients .git_repo_client import GitRepoClient
15
- from codegen .git .schemas .repo_config import RepoConfig
16
- from lib import CodebaseEventsApp , EventRouterAPI
14
+
15
+ from codegen .extensions .events .modal .base import CodebaseEventsApp , EventRouterMixin
17
16
from pr_tasks import lint_for_dev_import_violations , review_with_codegen_agent
18
17
from classy_fastapi import Routable , post
19
18
26
25
27
26
28
27
REPO_URL = "https://github.com/codegen-sh/codegen-sdk.git"
29
- COMMIT_ID = "5d8d18eac60ac926d312d1d205c584d9012d078f "
28
+ COMMIT_ID = "f398107d31bbd53fc77bc9c5f8763d2dc8fcae5b "
30
29
31
30
# Create the base image with dependencies
32
31
base_image = (
@@ -55,7 +54,8 @@ class CustomEventHandlersAPI(CodebaseEventsApp):
55
54
commit : str = modal .parameter (default = "79114f67ccfe8700416cd541d1c7c43659a95342" )
56
55
repo_org : str = modal .parameter (default = "codegen-sh" )
57
56
repo_name : str = modal .parameter (default = "Kevin-s-Adventure-Game" )
58
-
57
+ snapshot_index_id : str = SNAPSHOT_DICT_ID
58
+
59
59
def setup_handlers (self , cg : CodegenApp ):
60
60
@cg .slack .event ("app_mention" )
61
61
async def handle_mention (event : SlackEvent ):
@@ -112,17 +112,18 @@ def handle_issue(event: LinearEvent):
112
112
113
113
114
114
@codegen_events_app .cls (image = base_image , secrets = [modal .Secret .from_dotenv ('.env' )])
115
- class WebhookEventRouterAPI (EventRouterAPI , Routable ):
115
+ class WebhookEventRouterAPI (EventRouterMixin , Routable ):
116
116
117
- def __init__ ( self ):
118
- super (). __init__ ()
117
+ snapshot_index_id : str = SNAPSHOT_DICT_ID
118
+
119
119
120
120
def get_event_handler_cls (self ):
121
121
modal_cls = modal .Cls .from_name (app_name = "Events" , name = "CustomEventHandlersAPI" )
122
122
return modal_cls
123
123
124
124
@post ("/{org}/{repo}/{provider}/events" )
125
125
async def handle_event (self , org : str , repo : str , provider : Literal ["slack" , "github" , "linear" ], request : Request ):
126
+ # Define the route for the webhook url sink, it will need to indicate the repo repo org, and the provider
126
127
return await super ().handle_event (org , repo , provider , request )
127
128
128
129
@modal .asgi_app ()
@@ -134,13 +135,12 @@ def api(self):
134
135
return event_api
135
136
136
137
138
+ # Setup a cron job to trigger updates to the codebase snapshots.
137
139
@codegen_events_app .function (schedule = modal .Cron ("*/10 * * * *" ), image = base_image , secrets = [modal .Secret .from_dotenv (".env" )])
138
140
def refresh_repository_snapshots ():
139
141
WebhookEventRouterAPI ().refresh_repository_snapshots (snapshot_index_id = SNAPSHOT_DICT_ID )
140
142
141
143
142
-
143
-
144
144
app = modal .App ("Events" , secrets = [modal .Secret .from_dotenv ('.env' )])
145
145
app .include (event_handlers_app )
146
146
app .include (codegen_events_app )
0 commit comments