Update kubeflow-adapter for detail information of pipelines 48/13348/2
authorHoseong Choi <to6044@khu.ac.kr>
Wed, 11 Sep 2024 11:41:15 +0000 (11:41 +0000)
committerHoseong Choi <to6044@khu.ac.kr>
Wed, 25 Sep 2024 03:14:02 +0000 (03:14 +0000)
- Added information : pipeline_id, display_name, description, created_at, total_size, next_page_token
- Change 'list_pipelines' in kfadapter_main.py
- Change 'test_get_pipelines' in  test_kfadapter_main.py

ISSUE-ID: AIMLFW-146

Change-Id: If30695fa91242c8e6251c28ce223e31ccd3b33bb
Signed-off-by: Hoseong Choi <to6044@khu.ac.kr>
kfadapter/kfadapter_main.py
test/test_kfadapter_main.py

index 6d12176..8670679 100644 (file)
@@ -306,13 +306,19 @@ def list_pipelines():
     pipe_dict = {}
     try:
         pipeline_list = KFCONNECT_KF_OBJ.get_kf_list_pipelines()
-
+        pipe_dict['next_page_token'] = pipeline_list.next_page_token
+        pipe_dict['total_size'] = pipeline_list.total_size
+        
+        pipelines = []
         for pipeline in pipeline_list.pipelines:
             pipe_super_dict = {}
-            pipe_param_dict = {}
-            pipe_super_dict['id'] = pipeline.pipeline_id
+            pipe_super_dict['pipeline_id'] = pipeline.pipeline_id
+            pipe_super_dict['display_name'] = pipeline.display_name
             pipe_super_dict['description'] = pipeline.description
-            pipe_dict[pipeline.display_name] = pipe_super_dict
+            pipe_super_dict['created_at'] = pipeline.created_at
+            pipelines.append(pipe_super_dict)
+        pipe_dict['pipelines'] = pipelines
+        
     except:# pylint: disable=bare-except
         tbk = traceback.format_exc()
         LOGGER.error(tbk)
@@ -321,6 +327,7 @@ def list_pipelines():
 
     return jsonify(pipe_dict), status.HTTP_200_OK
 
+
 @APP.route('/trainingjobs/<trainingjob_name>/execution', methods=['POST'])
 def run_pipeline(trainingjob_name):
     """Function handling HTTP POST rest endpoint to execute pipeline based on trainingjob name
index af29348..eae6232 100644 (file)
@@ -195,10 +195,14 @@ class testKfadapterApi(TestCase):
         pipeline.pipeline_id = "pipeline-id"
         pipeline.description = "pipeline-description"
         pipeline.display_name= "pipeline-name"
+        pipeline.created_at = "created-at"
+
 
         pipeline_list = ApiListPipelinesResponse()
         pipeline_list.pipelines = [pipeline]
-        
+        pipeline_list.next_page_token = "next-page-token"
+        pipeline_list.total_size = "total-size"
+
         mock_get_kf_list_pipelines.return_value = pipeline_list
         
         # when
@@ -208,8 +212,10 @@ class testKfadapterApi(TestCase):
         mock_get_kf_list_pipelines.assert_called_once()
         self.assertEqual(response.content_type, "application/json")
         self.assertEqual(response.status_code, status.HTTP_200_OK)
-        self.assertEqual(response.get_data(), b'{"pipeline-name":{"description":"pipeline-description","id":"pipeline-id"}}\n')
-    
+        self.assertEqual(response.get_data(), 
+                         b'{"next_page_token":"next-page-token","pipelines":[{"created_at":"created-at","description":"pipeline-description","display_name":"pipeline-name","pipeline_id":"pipeline-id"}],"total_size":"total-size"}\n')
+
+
 
     @patch("kfadapter.kfadapter_kfconnect.KfConnect.get_kf_pipeline_desc")
     def test_get_pipeline(self, mock_get_kf_pipeline_desc):