Solving the TypeError: Object of type PipelineInfo is not JSON serializable 00/13600/2
authorrajdeep11 <rajdeep.sin@samsung.com>
Fri, 11 Oct 2024 10:47:10 +0000 (16:17 +0530)
committerrajdeep11 <rajdeep.sin@samsung.com>
Mon, 14 Oct 2024 07:18:19 +0000 (12:48 +0530)
Change-Id: I21910a274f0667f2bb0ede9d4c5032fd5d1cdeb7
Signed-off-by: rajdeep11 <rajdeep.sin@samsung.com>
trainingmgr/common/trainingmgr_util.py
trainingmgr/trainingmgr_main.py

index 5345597..fa0f4e2 100644 (file)
@@ -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
index d80a06d..3a213c6 100644 (file)
@@ -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"}