From: rajdeep11 Date: Fri, 11 Oct 2024 10:47:10 +0000 (+0530) Subject: Solving the TypeError: Object of type PipelineInfo is not JSON serializable X-Git-Tag: 3.0.0~70^2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=1aa7aa5c6d20f02d8a0b742c6d105cc78e6976cd;p=aiml-fw%2Fawmf%2Ftm.git Solving the TypeError: Object of type PipelineInfo is not JSON serializable Change-Id: I21910a274f0667f2bb0ede9d4c5032fd5d1cdeb7 Signed-off-by: rajdeep11 --- 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"}