Skip to content

Commit

Permalink
fix: fix sqs handler fail (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingwanying authored Aug 18, 2024
2 parents 0a69ed7 + 989d4b8 commit a5a1628
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions docs/guides/publish_petercat-utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ python3 -m pip install --upgrade build
Build petercat_utils:

```bash
cd petercat_utils
python3 -m build
npm run build:pypi
```

Make sure your have the latest version of twine installed:
Expand Down
4 changes: 2 additions & 2 deletions petercat_utils/rag_helper/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_task(task_type: TaskType, task_id: str) -> GitTask:
.execute())
if len(response.data) > 0:
data = response.data[0]
if task_type is TaskType.GIT_DOC:
if task_type == TaskType.GIT_DOC:
return GitDocTask(
id=data["id"],
commit_id=data["commit_id"],
Expand All @@ -74,7 +74,7 @@ def get_task(task_type: TaskType, task_id: str) -> GitTask:
status=data["status"],
from_id=data["from_task_id"]
)
if task_type is TaskType.GIT_ISSUE:
if task_type == TaskType.GIT_ISSUE:
return GitIssueTask(
id=data["id"],
issue_id=data["issue_id"],
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "petercat_utils"
version = "0.1.26"
version = "0.1.27"
description = ""
authors = ["raoha.rh <[email protected]>"]
readme = "README.md"
Expand Down
4 changes: 3 additions & 1 deletion subscriber/handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json

from petercat_utils import task as task_helper
from petercat_utils.data_class import TaskType


def lambda_handler(event, context):
Expand All @@ -16,14 +17,15 @@ def lambda_handler(event, context):
message_dict = json.loads(body)
task_id = message_dict["task_id"]
task_type = message_dict["task_type"]
task = task_helper.get_task(task_type, task_id)
task = task_helper.get_task(TaskType(task_type), task_id)
if task is None:
return task
task.handle()

# process message
print(f"message content: message={message_dict}, task_id={task_id}, task={task}")
except Exception as e:
print(f"message handle error: ${e}")
batch_item_failures.append({"itemIdentifier": record['messageId']})

sqs_batch_response["batchItemFailures"] = batch_item_failures
Expand Down

0 comments on commit a5a1628

Please sign in to comment.