Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -169,36 +169,27 @@ async def update_streams(request: Request):
|
|
169 |
|
170 |
payload = payload["payload"]
|
171 |
# Check if the payload structure matches the expected format
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
# Attempt to load the configuration for the stream and branch
|
184 |
-
try:
|
185 |
-
stream_config = config[streamName][branchName]
|
186 |
-
should_continue = True
|
187 |
-
# You can now use stream_config for further processing
|
188 |
-
except KeyError:
|
189 |
-
print(f"Configuration for stream {streamName} and branch {branchName} not found.")
|
190 |
-
else:
|
191 |
-
print("Branch name not found in payload.")
|
192 |
else:
|
193 |
-
print("
|
194 |
else:
|
195 |
-
print("
|
196 |
else:
|
197 |
-
print("
|
198 |
|
199 |
# If the flag is True, continue running the main part of the code
|
200 |
if should_continue:
|
201 |
locals().update(config[streamName, branchName])
|
202 |
|
203 |
-
#
|
204 |
mainFunc(STREAM_ID, SOURCE_BRANCH, TARGET_BRANCH, UUID_COL, ATTR_METADATA, KPI_METADATA, DEFAULT_ATTRIBUTES)
|
|
|
169 |
|
170 |
payload = payload["payload"]
|
171 |
# Check if the payload structure matches the expected format
|
172 |
+
# Assuming payload["event"]["event_name"] gives you the event type
|
173 |
+
event_name = payload["event"]["event_name"]
|
174 |
+
|
175 |
+
# List of valid event types
|
176 |
+
valid_event_types = ["commit_create", "commit_delete", "commit_update"]
|
177 |
+
|
178 |
+
if event_name in valid_event_types:
|
179 |
+
if streamName in config:
|
180 |
+
if branchName in config[streamName]:
|
181 |
+
stream_config = config[streamName][branchName]
|
182 |
+
should_continue = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
else:
|
184 |
+
print(f"Branch name {branchName} not found in config for stream {streamName}.")
|
185 |
else:
|
186 |
+
print(f"Stream name {streamName} not found in config.")
|
187 |
else:
|
188 |
+
print(f"Event type {event_name} is not one of the specified types.")
|
189 |
|
190 |
# If the flag is True, continue running the main part of the code
|
191 |
if should_continue:
|
192 |
locals().update(config[streamName, branchName])
|
193 |
|
194 |
+
# main
|
195 |
mainFunc(STREAM_ID, SOURCE_BRANCH, TARGET_BRANCH, UUID_COL, ATTR_METADATA, KPI_METADATA, DEFAULT_ATTRIBUTES)
|