From 3134c5b68f7342a6c707582c15a68206aa4d393a Mon Sep 17 00:00:00 2001 From: MadratJerry Date: Sun, 18 Aug 2024 20:46:40 +0800 Subject: [PATCH 1/3] docs: improve petercat utils publish doc --- docs/guides/publish_petercat-utils.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/guides/publish_petercat-utils.md b/docs/guides/publish_petercat-utils.md index d242dcea..4fe23e5b 100644 --- a/docs/guides/publish_petercat-utils.md +++ b/docs/guides/publish_petercat-utils.md @@ -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: From 63bacfb25f6c0a862d13459144e6333d65c1bf83 Mon Sep 17 00:00:00 2001 From: MadratJerry Date: Sun, 18 Aug 2024 20:47:58 +0800 Subject: [PATCH 2/3] feat: add handler fail log print --- subscriber/handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/subscriber/handler.py b/subscriber/handler.py index 7eee0244..adc20bbe 100644 --- a/subscriber/handler.py +++ b/subscriber/handler.py @@ -24,6 +24,7 @@ def lambda_handler(event, context): # 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 From 989d4b8e059703a0818432f38722e87e1b05616e Mon Sep 17 00:00:00 2001 From: MadratJerry Date: Sun, 18 Aug 2024 21:07:25 +0800 Subject: [PATCH 3/3] fix: task type enum handle problem --- petercat_utils/rag_helper/task.py | 4 ++-- pyproject.toml | 2 +- subscriber/handler.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/petercat_utils/rag_helper/task.py b/petercat_utils/rag_helper/task.py index 162c1e83..1153795a 100644 --- a/petercat_utils/rag_helper/task.py +++ b/petercat_utils/rag_helper/task.py @@ -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"], @@ -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"], diff --git a/pyproject.toml b/pyproject.toml index 0dfe70b8..369a4561 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "petercat_utils" -version = "0.1.26" +version = "0.1.27" description = "" authors = ["raoha.rh "] readme = "README.md" diff --git a/subscriber/handler.py b/subscriber/handler.py index adc20bbe..84ba74e7 100644 --- a/subscriber/handler.py +++ b/subscriber/handler.py @@ -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): @@ -16,7 +17,7 @@ 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()