repackage and tidy up codes to run test 39/9439/1
authorYouhwan Seol <yh.seol@samsung.com>
Mon, 31 Oct 2022 09:57:49 +0000 (18:57 +0900)
committerYouhwan Seol <yh.seol@samsung.com>
Mon, 31 Oct 2022 10:02:30 +0000 (19:02 +0900)
Delete shebangs, follow PEP 8 import style, and use __init__.py.
Please run test script at project ROOT dir
(e.g., bash ./test/unit_test.sh)

Issue-id: AIMLFW-9

Signed-off-by: Youhwan Seol <yh.seol@samsung.com>
Change-Id: I95a32b24cab38870c1fb793b14af57c5b8658975

15 files changed:
kfadapter/__init__.py [new file with mode: 0644]
kfadapter/kfadapter_conf.py
kfadapter/kfadapter_kfconnect.py
kfadapter/kfadapter_main.py
kfadapter/kfadapter_util.py
kfadapter/tmgr_logger.py
test/__init__.py [new file with mode: 0644]
test/fake_kfconnect.py
test/fake_kfp.py
test/test_kfadapter_conf.py
test/test_kfadapter_kfconnect.py
test/test_kfadapter_main.py
test/test_kfadapter_util.py
test/test_tmgr_logger.py
test/unit_test.sh

diff --git a/kfadapter/__init__.py b/kfadapter/__init__.py
new file mode 100644 (file)
index 0000000..7954d16
--- /dev/null
@@ -0,0 +1,17 @@
+# ==================================================================================
+#
+#       Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#          http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+# ==================================================================================
index e2f27ec..f4a3a50 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/python3
 # ==================================================================================
 #
 #       Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
@@ -16,7 +15,6 @@
 #   limitations under the License.
 #
 # ==================================================================================
-
 """kfadapter_conf.py
 
 This module is for retrieving configuration for KfAdapter App
@@ -25,9 +23,11 @@ Application configuration - Application Port and run status interval
 
 
 """
+
 from os import getenv
 from threading import Lock
-from tmgr_logger import TMLogger
+
+from .tmgr_logger import TMLogger
 
 TRAINING_DICT = {}
 LOCK = Lock()
index a9b1396..32f06f7 100644 (file)
 #   limitations under the License.
 #
 # ==================================================================================
-
 """kfadapter_kfconnect.py.
 
 This module is for interfacing and interworking with KubeFlow SDK
 
 """
 import kfp
-from kfadapter_util import random_suffix
-from kfadapter_conf import KfConfiguration
+
+from .kfadapter_util import random_suffix
+from .kfadapter_conf import KfConfiguration
 
 class KfConnect:
     """
index 0340558..3fe032c 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/python3
 # ==================================================================================
 #
 #       Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
@@ -31,12 +30,13 @@ import os
 import traceback
 import json
 from threading import Thread
+
 from flask import Flask, request, jsonify
 from flask_api import status
 import kfp_server_api
-from kfadapter_kfconnect import KfConnect
-import kfadapter_conf
-from kfadapter_util import BadRequest, wait_status_thread, keys_match, check_map
+
+from .kfadapter_kfconnect import KfConnect
+from .kfadapter_util import BadRequest, wait_status_thread, keys_match, check_map
 
 #Handles to Config and Kubeflow
 KFCONNECT_CONFIG_OBJ = None
index cde187d..baaba3a 100644 (file)
@@ -1,9 +1,3 @@
-"""kfadapter_util.py.
-
-This module is for all the utility functions to be used
-by the main and other modules
-
-"""
 # ==================================================================================
 #
 #       Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
@@ -21,14 +15,21 @@ by the main and other modules
 #   limitations under the License.
 #
 # ==================================================================================
-from random import choices
+"""kfadapter_util.py.
+
+This module is for all the utility functions to be used
+by the main and other modules
+
+"""
+
 import traceback
 import string
 import time
 import json
 import requests
+from random import choices
+
 from flask_api import status
-import kfadapter_conf
 
 class BadRequest(Exception):
     """
index 79877da..c3cc3d1 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/python3
 # ==================================================================================
 #
 #       Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
 #
 # ==================================================================================
 """tmgr_logger.py
+
 This module is for Initializing Logger Framework
-"""
 
+"""
+import os
 import logging
 import logging.config
 import yaml
 
-
 class TMLogger(object):# pylint: disable=too-few-public-methods
     """
     This is a class for initiliazing logger configuration for TMLogger
diff --git a/test/__init__.py b/test/__init__.py
new file mode 100644 (file)
index 0000000..7954d16
--- /dev/null
@@ -0,0 +1,17 @@
+# ==================================================================================
+#
+#       Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#          http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+# ==================================================================================
index 50136d1..1344db6 100644 (file)
@@ -19,7 +19,6 @@
 import kfp_server_api
 from kfp_server_api.models.api_run import ApiRun
 from kfp_server_api.models.api_list_runs_response import ApiListRunsResponse
-
 from kfp_server_api.models.api_experiment import ApiExperiment
 from kfp_server_api.models.api_list_pipelines_response import ApiListPipelinesResponse
 from kfp_server_api.models.api_pipeline import ApiPipeline
index 283d8e2..c80cd1a 100644 (file)
@@ -23,9 +23,6 @@ from kfp_server_api.models.api_pipeline_version import ApiPipelineVersion
 from kfp_server_api.models.api_experiment import ApiExperiment
 from kfp_server_api.models.api_run_detail import ApiRunDetail
 from kfp_server_api.models.api_run import ApiRun
-
-
-
 import kfp_server_api
 
 class FakeKfp:
index 4727590..524244b 100644 (file)
 #
 # ==================================================================================
 
-import sys
 import os
-sys.path.append("../kfadapter")
-import kfadapter_conf
-import pytest
+
+from kfadapter import kfadapter_conf
 
 class Test_kfadapter_conf:
     KUBEFLOW_HOST_NAME = '127.0.0.1'
index 2775685..d15b8d1 100644 (file)
 #
 # ==================================================================================
 
-import sys
-sys.path.append("kfadapter")
-# import kfadapter_conf
-from kfadapter_kfconnect import KfConnect
-from fake_kfconnect import FakeKfConnect
-from fake_kfp import FakeKfp
-from fake_kfp import FakeNegativeKfp
 import kfp_server_api
 
+from kfadapter.kfadapter_kfconnect import KfConnect
+
+from .fake_kfp import FakeKfp
+from .fake_kfp import FakeNegativeKfp
+
 class Test_KfConnect:
     def setup_method(self):
         self.__KFCONNECT = KfConnect()
index efe1385..cc7c448 100644 (file)
 #   limitations under the License.
 #
 # ==================================================================================
-
-import sys
-sys.path.append("kfadapter")
-import kfadapter_main
-from tmgr_logger import TMLogger
+import json 
 
 from flask_api import status
-import json 
-from fake_kfconnect import FakeKfConnect, NegativeFakeAdditionalKfConnect, NegativeFakeKfConnect, NegativeFakeNoneKfConnect
-from fake_kfconf import FakeKfConf
+
+from kfadapter import kfadapter_main
+from kfadapter.tmgr_logger import TMLogger
+from .fake_kfconnect import FakeKfConnect, NegativeFakeAdditionalKfConnect, NegativeFakeKfConnect, NegativeFakeNoneKfConnect
+from .fake_kfconf import FakeKfConf
 
 class Test_pipeline_id_operations:
     
index 5b377e9..0e3618e 100644 (file)
 #
 # ==================================================================================
 
-import pytest
-import sys
-import string
-from mock import patch
-sys.path.append("../kfadapter")
-import kfadapter_util
+from kfadapter import kfadapter_util
 
 class Test_kfadapter_util:
     def setup_method(self):
index 245f0f4..11aaa8a 100644 (file)
 #
 # ==================================================================================
 
-import sys
-sys.path.append("../kfadapter")
-from tmgr_logger import TMLogger
+from kfadapter.tmgr_logger import TMLogger
 
 class Test_tmgr_logger:
     def setup_method(self):
-        self.TMGR_LOGGER_OBJ = TMLogger("../config/log_config.yaml")
+        self.TMGR_LOGGER_OBJ = TMLogger("config/log_config.yaml")
         
     def test_get_loglevel(self):
         ret = self.TMGR_LOGGER_OBJ.get_logLevel
index 305141d..bdf69b5 100755 (executable)
@@ -1,5 +1,3 @@
-// test/unit_test.sh
-
 # ==================================================================================
 #
 #       Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.