From 1aa7aa5c6d20f02d8a0b742c6d105cc78e6976cd Mon Sep 17 00:00:00 2001 From: rajdeep11 Date: Fri, 11 Oct 2024 16:17:10 +0530 Subject: [PATCH] Solving the TypeError: Object of type PipelineInfo is not JSON serializable Change-Id: I21910a274f0667f2bb0ede9d4c5032fd5d1cdeb7 Signed-off-by: rajdeep11 --- trainingmgr/common/trainingmgr_util.py | 12 ++++++++++-- trainingmgr/trainingmgr_main.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/trainingmgr/common/trainingmgr_util.py b/trainingmgr/common/trainingmgr_util.py index 5345597..fa0f4e2 100644 --- a/trainingmgr/common/trainingmgr_util.py +++ b/trainingmgr/common/trainingmgr_util.py @@ -426,7 +426,7 @@ def fetch_pipeline_info_by_name(training_config_obj, pipe_name): display_name=pipeline_info['display_name'], description=pipeline_info['description'], created_at=pipeline_info['created_at'] - ) + ).to_dict() logger.warning(f"Pipeline '{pipe_name}' not found") return None @@ -453,4 +453,12 @@ class PipelineInfo: def __repr__(self): return (f"PipelineInfo(pipeline_id={self.pipeline_id}, display_name={self.display_name}, " - f"description={self.description}, created_at={self.created_at})") \ No newline at end of file + f"description={self.description}, created_at={self.created_at})") + + def to_dict(self): + return { + "pipeline_id":self.pipeline_id, + "display_name": self.display_name, + "description": self.description, + "created_at": self.created_at + } \ No newline at end of file diff --git a/trainingmgr/trainingmgr_main.py b/trainingmgr/trainingmgr_main.py index d80a06d..3a213c6 100644 --- a/trainingmgr/trainingmgr_main.py +++ b/trainingmgr/trainingmgr_main.py @@ -495,7 +495,7 @@ def get_pipeline_info_by_name(pipe_name): try: pipeline_info = fetch_pipeline_info_by_name(TRAININGMGR_CONFIG_OBJ, pipe_name) if pipeline_info: - api_response = pipeline_info + api_response = {"pipeline_info":pipeline_info} response_code = status.HTTP_200_OK else: api_response = {"error": f"Pipeline '{pipe_name}' not found"} -- 2.16.6