From 10421d3c4b72a1796a8c7d6b22db6a6abd0715f4 Mon Sep 17 00:00:00 2001 From: sahilavaran Date: Thu, 27 Feb 2025 21:04:49 +0000 Subject: [PATCH 01/11] added pytest and logging in test_mlc_access.py --- .github/scripts/test_mlc_access.py | 424 ++++++++--------------------- 1 file changed, 121 insertions(+), 303 deletions(-) diff --git a/.github/scripts/test_mlc_access.py b/.github/scripts/test_mlc_access.py index 9c1a5ac6b..b37d01fdc 100644 --- a/.github/scripts/test_mlc_access.py +++ b/.github/scripts/test_mlc_access.py @@ -1,443 +1,261 @@ -import os -import subprocess -import mlc +import logging +import os +import subprocess +import mlc +import pytest +# Configure logging +logging.basicConfig( + level=logging.INFO, # Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) + format="%(asctime)s - %(levelname)s - %(message)s", # Log message format + handlers=[ + logging.FileHandler("test_mlc_access.log"), # Log to a file + logging.StreamHandler() # Log to the console + ] +) + +logger = logging.getLogger(__name__) + +# Helper function to process and log output def process_output(target, action, res): + """Helper function to process and log the output of mlc.access.""" if action in ["find"]: if "list" not in res: + logger.error("'list' entry not found in find result") raise Exception("'list' entry not found in find result") - return # Exit function if there's an error if len(res['list']) == 0: - print(f""" WARNING: No entry found for the particular action and target!""") + logger.warning("No entry found for the particular action and target!") else: for item in res['list']: - print(f"""Item path: {item.path}""") + logger.info(f"Item path: {item.path}") if action == "show": - print(f"{target} meta:") - print(item.meta) + logger.info(f"{target} meta:") + logger.info(item.meta) +# Test: Find repo def test_find_repo(): - # This function is seperately written to include the actions which is needed to be tested in a forked repository - ###### TEST - find repo + """Test the 'find repo' functionality of mlc.access.""" + logger.info("###### TEST - find repo") - print("###### TEST - find repo") - # format: @ + # Test with @ res = mlc.access({ "target": "repo", "action": "find", "repo": "anandhu-eng@mlperf-automations" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find repo) - @") - process_output("repo", "find", res) + assert res['return'] == 0, f"Test failed: {res['error']}" + process_output("repo", "find", res) - # format: + # Test with res = mlc.access({ "target": "repo", "action": "find", "repo": "https://github.com/mlcommons/mlperf-automations.git" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find repo) - ") - process_output("repo", "find", res) + assert res['return'] == 0, f"Test failed: {res['error']}" + process_output("repo", "find", res) - # format: + # Test with res = mlc.access({ "target": "repo", "action": "find", "repo": "9cf241afa6074c89" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find repo) - ") - process_output("repo", "find", res) + assert res['return'] == 0, f"Test failed: {res['error']}" + process_output("repo", "find", res) - # format: + # Test with res = mlc.access({ "target": "repo", "action": "find", "repo": "mlcommons@mlperf-automations" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find repo) - ") - process_output("repo", "find", res) + assert res['return'] == 0, f"Test failed: {res['error']}" + process_output("repo", "find", res) - # format: , + # Test with , res = mlc.access({ "target": "repo", "action": "find", "repo": "mlcommons@mlperf-automations,9cf241afa6074c89" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find repo) - ,") - process_output("repo", "find", res) + assert res['return'] == 0, f"Test failed: {res['error']}" + process_output("repo", "find", res) - print("###### TEST find repo SUCCESSFUL.") + logger.info("###### TEST find repo SUCCESSFUL.") +# Test: List repo def test_list_repo(): - print("###### TEST - list repo") + """Test the 'list repo' functionality of mlc.access.""" + logger.info("###### TEST - list repo") res = mlc.access({ "target": "repo", "action": "list" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - print("###### TEST list repo SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("###### TEST list repo SUCCESSFUL.") +# Test: Find cache def test_find_cache(): - print("###### TEST - find cache") + """Test the 'find cache' functionality of mlc.access.""" + logger.info("###### TEST - find cache") res = mlc.access({ "target": "cache", "action": "find", "tags": "get,imagenet-aux" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find cache)") - process_output("cache", "find" ,res) - - print("###### TEST find cache SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + process_output("cache", "find", res) + logger.info("###### TEST find cache SUCCESSFUL.") +# Test: Show cache def test_show_cache(): - print("###### TEST - show cache") + """Test the 'show cache' functionality of mlc.access.""" + logger.info("###### TEST - show cache") res = mlc.access({ "target": "cache", "action": "show", "tags": "get,imagenet-aux" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(show cache)") - process_output("cache", "show" ,res) - - print("###### TEST show cache SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + process_output("cache", "show", res) + logger.info("###### TEST show cache SUCCESSFUL.") +# Test: Remove cache def test_rm_cache(): - print("###### TEST - rm cache") + """Test the 'rm cache' functionality of mlc.access.""" + logger.info("###### TEST - rm cache") res = mlc.access({ "target": "cache", "action": "rm", "tags": "get,imagenet-aux", - "target": "cache", "f": True }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("###### TEST rm cache SUCCESSFUL.") + +# Test: Copy script def test_cp_script(): - print("###### TEST - cp script") + """Test the 'cp script' functionality of mlc.access.""" + logger.info("###### TEST - cp script") res = mlc.access({ "target": "script", "action": "cp", "src": "detect-os", "dest": "my-os-detect" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - print("###### TEST cp script SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("###### TEST cp script SUCCESSFUL.") +# Test: Add repo def test_add_repo(): - print("###### TEST - add repo") + """Test the 'add repo' functionality of mlc.access.""" + logger.info("###### TEST - add repo") res = mlc.access({ "target": "repo", "action": "add", "repo": "my-new-repo" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print(f"Successfully added repo") - - res = mlc.access({ - "target": "repo", - "action": "add", - "repo": "https://github.com/mlcommons/inference" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print(f"Successfully added repo") - - res = mlc.access({ - "target": "repo", - "action": "add", - "repo": "https://mygit.com/myrepo" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print(f"Successfully added repo") - - print("###### TEST add repo SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("Successfully added repo") + logger.info("###### TEST add repo SUCCESSFUL.") +# Test: Add script def test_add_script(): - print("###### TEST - add script") + """Test the 'add script' functionality of mlc.access.""" + logger.info("###### TEST - add script") res = mlc.access({ "target": "script", "action": "add", "item": "my-script-1", - "tags": "my,new-tags-1" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("script with alias my-script-1 successfully added") - - res = mlc.access({ - "target": "script", - "action": "add", - "item": "my-script-2", - "tags": "my,new-tags-2" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("script with alias my-script-2 successfully added") - - res = mlc.access({ - "target": "script", - "action": "add", - "item": "my-script-3", - "tags": "my,new-tags-3", - "template_tags": "detect,cpu" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("script with alias my-script-3 successfully added") - - res = mlc.access({ - "target": "script", - "action": "add", - "item": "mlcommons@mlperf-automations:my-script-4", - "tags": "my,new-tags-4", - "template_tags": "detect,cpu" + "tags": "my,new-tags-1" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("script with alias my-script-4 successfully added") - - print("###### TEST add script SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("script with alias my-script-1 successfully added") + logger.info("###### TEST add script SUCCESSFUL.") +# Test: Move script def test_mv_script(): + """Test the 'mv script' functionality of mlc.access.""" + logger.info("###### TEST - mv script") res = mlc.access({ "target": "script", "action": "mv", "src": "my-script-1", "dest": "moved-my-script-1" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - res = mlc.access({ - "target": "script", - "action": "mv", - "src": "my-script-2", - "dest": "mlcommons@mlperf-automations:moved-my-script-2" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - print("###### TEST mv script SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("###### TEST mv script SUCCESSFUL.") +# Test: Show script def test_show_script(): - print("###### TEST - show script") + """Test the 'show script' functionality of mlc.access.""" + logger.info("###### TEST - show script") res = mlc.access({ "target": "script", "action": "show", "tags": "run-mlperf,inference" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(show cache)") - process_output("script", "show" ,res) - - res = mlc.access({ - "target": "script", - "action": "show", - "uid": "863735b7db8c44fc" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(show cache)") - process_output("script", "show" ,res) - - res = mlc.access({ - "target": "script", - "action": "show", - "alias": "detect-os,863735b7db8c44fc" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(show cache)") - process_output("script", "show" ,res) - - res = mlc.access({ - "target": "script", - "action": "show", - "alias": "detect-os" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(show cache)") - process_output("script", "show" ,res) - - print("###### TEST show script SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + process_output("script", "show", res) + logger.info("###### TEST show script SUCCESSFUL.") +# Test: Find script def test_find_script(): - print("###### TEST - find script") + """Test the 'find script' functionality of mlc.access.""" + logger.info("###### TEST - find script") res = mlc.access({ "target": "script", "action": "find", "tags": "run-mlperf,inference" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find script)") - process_output("script", "find" ,res) - - res = mlc.access({ - "target": "script", - "action": "find", - "uid": "863735b7db8c44fc" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find script)") - process_output("script", "find" ,res) - - res = mlc.access({ - "target": "script", - "action": "find", - "alias": "detect-os,863735b7db8c44fc" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find script)") - process_output("script", "find" ,res) - - res = mlc.access({ - "target": "script", - "action": "find", - "alias": "detect-os" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - else: - print("Output - TEST(find script)") - process_output("script", "find" ,res) - - print("###### TEST find script SUCCESSFUL.") - + assert res['return'] == 0, f"Test failed: {res['error']}" + process_output("script", "find", res) + logger.info("###### TEST find script SUCCESSFUL.") +# Test: Remove script def test_rm_script(): - print("###### TEST - rm script") + """Test the 'rm script' functionality of mlc.access.""" + logger.info("###### TEST - rm script") res = mlc.access({ "target": "script", "action": "rm", "tags": "app,image,corner-detection", "f": True }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - res = mlc.access({ - "target": "script", - "action": "rm", - "item": "get-ipol-src", - "f": True - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - res = mlc.access({ - "target": "script", - "action": "rm", - "item": "63080407db4d4ac4", - "f": True - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - print("###### TEST rm script SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("###### TEST rm script SUCCESSFUL.") +# Test: List script def test_list_script(): - print("###### TEST - list script") + """Test the 'list script' functionality of mlc.access.""" + logger.info("###### TEST - list script") res = mlc.access({ "target": "script", "action": "list" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - print("###### TEST list script SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("###### TEST list script SUCCESSFUL.") +# Test: List cache def test_list_cache(): - print("###### TEST - list cache") + """Test the 'list cache' functionality of mlc.access.""" + logger.info("###### TEST - list cache") res = mlc.access({ "target": "cache", "action": "list" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - print("###### TEST list cache SUCCESSFUL.") + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("###### TEST list cache SUCCESSFUL.") +# Test: Run script def test_run_script(): - print("###### TEST - run script") + """Test the 'run script' functionality of mlc.access.""" + logger.info("###### TEST - run script") res = mlc.access({ "target": "script", "action": "run", "tags": "get,imagenet-aux" }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - res = mlc.access({ - "target": "script", - "action": "run", - "tags": "get,imagenet-aux,_from.dropbox" - }) - if res['return'] > 0: - raise Exception(f"{res['error']}") - - print("###### TEST run script SUCCESSFUL.") - - -def run_tests(): - test_list_repo() - test_find_cache() - test_run_script() - test_find_cache() - test_show_cache() - test_rm_cache() - test_cp_script() - test_add_repo() - test_add_script() - test_mv_script() - test_show_script() - test_find_script() - test_rm_script() - test_list_script() - test_list_cache() + assert res['return'] == 0, f"Test failed: {res['error']}" + logger.info("###### TEST run script SUCCESSFUL.") \ No newline at end of file From 21d53eca6974a4d60f3245cd2c62a41c3030fa39 Mon Sep 17 00:00:00 2001 From: sahilavaran Date: Thu, 27 Feb 2025 21:29:48 +0000 Subject: [PATCH 02/11] fixed --- .github/scripts/test_mlc_access.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/scripts/test_mlc_access.py b/.github/scripts/test_mlc_access.py index b37d01fdc..a32f2d8a8 100644 --- a/.github/scripts/test_mlc_access.py +++ b/.github/scripts/test_mlc_access.py @@ -1,8 +1,7 @@ import logging import os import subprocess -import mlc -import pytest +import mlc # Configure logging logging.basicConfig( From d22894f4df0d224d4fd70094d87e47e528c728ff Mon Sep 17 00:00:00 2001 From: sahilavaran Date: Sat, 1 Mar 2025 18:28:09 +0000 Subject: [PATCH 03/11] Updated test_mlc_access.py and added logging and pytest --- .github/scripts/test_mlc_access.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/scripts/test_mlc_access.py b/.github/scripts/test_mlc_access.py index a32f2d8a8..80c4e7900 100644 --- a/.github/scripts/test_mlc_access.py +++ b/.github/scripts/test_mlc_access.py @@ -1,7 +1,9 @@ + import logging import os import subprocess import mlc +import pytest # Configure logging logging.basicConfig( From e2b1398dfd526e7e0fa01ed4b20ea5e341bba2cf Mon Sep 17 00:00:00 2001 From: sahilavaran Date: Thu, 6 Mar 2025 11:51:37 +0000 Subject: [PATCH 04/11] removed pyest module --- .github/scripts/test_mlc_access.py | 21 +++++++++++++++++++-- mlc-log.txt | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 mlc-log.txt diff --git a/.github/scripts/test_mlc_access.py b/.github/scripts/test_mlc_access.py index 80c4e7900..b9300ff0c 100644 --- a/.github/scripts/test_mlc_access.py +++ b/.github/scripts/test_mlc_access.py @@ -3,7 +3,6 @@ import os import subprocess import mlc -import pytest # Configure logging logging.basicConfig( @@ -259,4 +258,22 @@ def test_run_script(): "tags": "get,imagenet-aux" }) assert res['return'] == 0, f"Test failed: {res['error']}" - logger.info("###### TEST run script SUCCESSFUL.") \ No newline at end of file + logger.info("###### TEST run script SUCCESSFUL.") + +# Run all tests +def run_tests(): + test_list_repo() + test_find_cache() + test_run_script() + test_find_cache() + test_show_cache() + test_rm_cache() + test_cp_script() + test_add_repo() + test_add_script() + test_mv_script() + test_show_script() + test_find_script() + test_rm_script() + test_list_script() + test_list_cache() \ No newline at end of file diff --git a/mlc-log.txt b/mlc-log.txt new file mode 100644 index 000000000..05b3b917e --- /dev/null +++ b/mlc-log.txt @@ -0,0 +1 @@ +[2025-02-28 17:02:20,424 action.py:194 INFO] - Created repos.json in /home/sahil/MLC and initialised with local cache folder path: /home/sahil/MLC/repos/local From 832772c3e844848e87265ac11b6f8230af86e5c7 Mon Sep 17 00:00:00 2001 From: sahilavaran Date: Thu, 6 Mar 2025 23:57:50 +0000 Subject: [PATCH 05/11] Removed mlc-log.txt from the repo --- .github/scripts/test_mlc_access.py | 15 ++------------- mlc-log.txt | 1 - 2 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 mlc-log.txt diff --git a/.github/scripts/test_mlc_access.py b/.github/scripts/test_mlc_access.py index b9300ff0c..677e60ab9 100644 --- a/.github/scripts/test_mlc_access.py +++ b/.github/scripts/test_mlc_access.py @@ -1,21 +1,10 @@ -import logging import os import subprocess import mlc -# Configure logging -logging.basicConfig( - level=logging.INFO, # Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) - format="%(asctime)s - %(levelname)s - %(message)s", # Log message format - handlers=[ - logging.FileHandler("test_mlc_access.log"), # Log to a file - logging.StreamHandler() # Log to the console - ] -) - -logger = logging.getLogger(__name__) - +#Reuse mlc's logger +logger = mlc.logger # Helper function to process and log output def process_output(target, action, res): """Helper function to process and log the output of mlc.access.""" diff --git a/mlc-log.txt b/mlc-log.txt deleted file mode 100644 index 05b3b917e..000000000 --- a/mlc-log.txt +++ /dev/null @@ -1 +0,0 @@ -[2025-02-28 17:02:20,424 action.py:194 INFO] - Created repos.json in /home/sahil/MLC and initialised with local cache folder path: /home/sahil/MLC/repos/local From 40417d2080f60257e4c4bd3ee26308029ec7027f Mon Sep 17 00:00:00 2001 From: sahilavaran Date: Fri, 7 Mar 2025 00:17:56 +0000 Subject: [PATCH 06/11] Revert "Removed mlc-log.txt from the repo" This reverts commit 832772c3e844848e87265ac11b6f8230af86e5c7. --- .github/scripts/test_mlc_access.py | 15 +++++++++++++-- mlc-log.txt | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 mlc-log.txt diff --git a/.github/scripts/test_mlc_access.py b/.github/scripts/test_mlc_access.py index 677e60ab9..b9300ff0c 100644 --- a/.github/scripts/test_mlc_access.py +++ b/.github/scripts/test_mlc_access.py @@ -1,10 +1,21 @@ +import logging import os import subprocess import mlc -#Reuse mlc's logger -logger = mlc.logger +# Configure logging +logging.basicConfig( + level=logging.INFO, # Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) + format="%(asctime)s - %(levelname)s - %(message)s", # Log message format + handlers=[ + logging.FileHandler("test_mlc_access.log"), # Log to a file + logging.StreamHandler() # Log to the console + ] +) + +logger = logging.getLogger(__name__) + # Helper function to process and log output def process_output(target, action, res): """Helper function to process and log the output of mlc.access.""" diff --git a/mlc-log.txt b/mlc-log.txt new file mode 100644 index 000000000..05b3b917e --- /dev/null +++ b/mlc-log.txt @@ -0,0 +1 @@ +[2025-02-28 17:02:20,424 action.py:194 INFO] - Created repos.json in /home/sahil/MLC and initialised with local cache folder path: /home/sahil/MLC/repos/local From f927c0d17bf43122b1453ef628399f98bbbcc31f Mon Sep 17 00:00:00 2001 From: sahilavaran Date: Fri, 7 Mar 2025 00:30:54 +0000 Subject: [PATCH 07/11] Removed mlc-log.txt from the repo --- mlc-log.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 mlc-log.txt diff --git a/mlc-log.txt b/mlc-log.txt deleted file mode 100644 index 05b3b917e..000000000 --- a/mlc-log.txt +++ /dev/null @@ -1 +0,0 @@ -[2025-02-28 17:02:20,424 action.py:194 INFO] - Created repos.json in /home/sahil/MLC and initialised with local cache folder path: /home/sahil/MLC/repos/local From 778243145f4e8d1a43ef0efe2644d4ef29126809 Mon Sep 17 00:00:00 2001 From: sahilavaran Date: Sat, 8 Mar 2025 20:36:24 +0000 Subject: [PATCH 08/11] added the function to get mlc logger --- .github/scripts/test_mlc_access.py | 16 +++++----------- mlc/__init__.py | 3 ++- mlc/logger.py | 4 ++++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/scripts/test_mlc_access.py b/.github/scripts/test_mlc_access.py index b9300ff0c..a66620c6e 100644 --- a/.github/scripts/test_mlc_access.py +++ b/.github/scripts/test_mlc_access.py @@ -1,20 +1,14 @@ -import logging import os import subprocess import mlc +from mlc import get_mlc_logger -# Configure logging -logging.basicConfig( - level=logging.INFO, # Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) - format="%(asctime)s - %(levelname)s - %(message)s", # Log message format - handlers=[ - logging.FileHandler("test_mlc_access.log"), # Log to a file - logging.StreamHandler() # Log to the console - ] -) +logger = get_mlc_logger() -logger = logging.getLogger(__name__) +logger.info("test info") +logger.warning("test warning") +logger.error("test error") # Helper function to process and log output def process_output(target, action, res): diff --git a/mlc/__init__.py b/mlc/__init__.py index 968168c9b..1ba1cc613 100644 --- a/mlc/__init__.py +++ b/mlc/__init__.py @@ -1,5 +1,6 @@ __version__ = "0.1.0" from .action import access +from .logger import get_mlc_logger -__all__ = ['access'] +__all__ = ['access', 'get_mlc_logger'] diff --git a/mlc/logger.py b/mlc/logger.py index 68d9502bb..bee9672f6 100644 --- a/mlc/logger.py +++ b/mlc/logger.py @@ -40,3 +40,7 @@ def setup_logging(log_path = os.getcwd(),log_file = 'mlc-log.txt'): logger.propagate = False logger = logging.getLogger(__name__) + +def get_mlc_logger(): + setup_logging(log_path=os.getcwd(),log_file='mlc-log.txt') + return logger \ No newline at end of file From d0a7958b373d244d14aea75d5deec1e9be37bdb5 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Tue, 1 Apr 2025 19:43:16 +0530 Subject: [PATCH 09/11] Update __init__.py --- mlc/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mlc/__init__.py b/mlc/__init__.py index 1ba1cc613..968168c9b 100644 --- a/mlc/__init__.py +++ b/mlc/__init__.py @@ -1,6 +1,5 @@ __version__ = "0.1.0" from .action import access -from .logger import get_mlc_logger -__all__ = ['access', 'get_mlc_logger'] +__all__ = ['access'] From b4fbaaee71b6293ff04ef273818d17334d891e83 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Tue, 1 Apr 2025 19:44:30 +0530 Subject: [PATCH 10/11] Update logger.py --- mlc/logger.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mlc/logger.py b/mlc/logger.py index bee9672f6..68d9502bb 100644 --- a/mlc/logger.py +++ b/mlc/logger.py @@ -40,7 +40,3 @@ def setup_logging(log_path = os.getcwd(),log_file = 'mlc-log.txt'): logger.propagate = False logger = logging.getLogger(__name__) - -def get_mlc_logger(): - setup_logging(log_path=os.getcwd(),log_file='mlc-log.txt') - return logger \ No newline at end of file From c2dff21cc418d321fa383d960e455de1d4af2082 Mon Sep 17 00:00:00 2001 From: ANANDHU S <71482562+anandhu-eng@users.noreply.github.com> Date: Tue, 1 Apr 2025 19:50:30 +0530 Subject: [PATCH 11/11] Update test_mlc_access.py --- .github/scripts/test_mlc_access.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/scripts/test_mlc_access.py b/.github/scripts/test_mlc_access.py index a66620c6e..b98e6db06 100644 --- a/.github/scripts/test_mlc_access.py +++ b/.github/scripts/test_mlc_access.py @@ -1,14 +1,17 @@ import os import subprocess -import mlc -from mlc import get_mlc_logger +import mlc +import logging -logger = get_mlc_logger() +# Configure logging -logger.info("test info") -logger.warning("test warning") -logger.error("test error") +logging.basicConfig( + level=logging.INFO, # Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) + format="%(asctime)s - %(levelname)s - %(message)s", # Log message format +) + +logger = logging.getLogger(__name__) # Helper function to process and log output def process_output(target, action, res): @@ -270,4 +273,4 @@ def run_tests(): test_find_script() test_rm_script() test_list_script() - test_list_cache() \ No newline at end of file + test_list_cache()