From 2e880728aab0dad57dc397395083ac2ce4040a7e Mon Sep 17 00:00:00 2001 From: Yash Daga Date: Wed, 24 Jun 2026 20:35:15 +0530 Subject: [PATCH 1/6] testing the exe of main.py --- tests/unit/templates/test_temp_main.py | 86 ++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 tests/unit/templates/test_temp_main.py diff --git a/tests/unit/templates/test_temp_main.py b/tests/unit/templates/test_temp_main.py new file mode 100644 index 0000000..8964e85 --- /dev/null +++ b/tests/unit/templates/test_temp_main.py @@ -0,0 +1,86 @@ +import os +import subprocess +import sys +import pytest + +def test_check_all_templates_dir(): + templates = [ "chatbot", "cnn", "empty", "lora-cls", "lstm-cls", "lstm-gen", "mlp-binary", + "mlp-multiclass", "mlp-regression", "timm-cls", "vae", "yolo"] + template_dir = os.listdir(r"\fenn\templates") + result = False + for test in template_dir: + if test in [".git",".gitignore","__init__.py","LICENSE"]: + continue + elif test in templates: + result = True + else: + result = False + assert result == True + +def test_check_for_main(): + path = r"\fenn\templates" + template_dir = os.listdir(path) + result = False + for test in template_dir: + main_path = os.path.join(path, test, "main.py") + if test in [".git",".gitignore","__init__.py","LICENSE"]: + continue + elif os.path.exists(main_path): + result = True + else: + result = False + assert result == True + +def test_check_for_requirement(): + path = r"\fenn\templates" + template_dir = os.listdir(path) + result = False + for test in template_dir: + requirement_path = os.path.join(path, test, "requirements.txt") + if test in [".git",".gitignore","__init__.py","LICENSE"]: + continue + elif os.path.exists(requirement_path): + result = True + else: + result = False + assert result == True + +def test_main(): + path = r"\fenn\templates" + template_dir = os.listdir(path) + result = False + for test in template_dir: + requirement_path = os.path.join(path, test, "requirements.txt") + main_path = os.path.join(path, test, "main.py") + if test in [".git",".gitignore","__init__.py","LICENSE"]: + continue + else: + try: + print(f"\nTesting {test}") + + subprocess.run( + [sys.executable, "-m", "pip", "install", "-r", requirement_path], + check=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + subprocess.run( + [sys.executable, main_path], + check=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + + print(f"{test} ran successfully") + + except subprocess.CalledProcessError as e: + raise AssertionError(f"{test} failed: {e}") + + finally: + subprocess.run( + [sys.executable, "-m", "pip", "uninstall", "-y", "-r", requirement_path], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + + assert result == True \ No newline at end of file From f0c05aa8aeb187765cbddda496a1f6a88ef4940c Mon Sep 17 00:00:00 2001 From: DagaBhai Date: Sat, 4 Jul 2026 10:51:14 +0530 Subject: [PATCH 2/6] Update template directory path in unit tests Refactor template directory path handling in tests. --- tests/unit/templates/test_temp_main.py | 50 ++++++++++++++------------ 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/tests/unit/templates/test_temp_main.py b/tests/unit/templates/test_temp_main.py index 8964e85..6678d99 100644 --- a/tests/unit/templates/test_temp_main.py +++ b/tests/unit/templates/test_temp_main.py @@ -3,13 +3,20 @@ import sys import pytest +TEST_DIR = os.path.dirname(os.path.abspath(__file__)) +TEMPLATE_DIR = os.path.abspath(os.path.join(TEST_DIR, "..", "templates")) + def test_check_all_templates_dir(): - templates = [ "chatbot", "cnn", "empty", "lora-cls", "lstm-cls", "lstm-gen", "mlp-binary", - "mlp-multiclass", "mlp-regression", "timm-cls", "vae", "yolo"] - template_dir = os.listdir(r"\fenn\templates") - result = False + templates = [ + "chatbot", "cnn", "empty", "lora-cls", "lstm-cls", "lstm-gen", + "mlp-binary", "mlp-multiclass", "mlp-regression", "timm-cls", "vae", "yolo" + ] + assert os.path.exists(TEMPLATE_DIR), f"Templates directory not found at {TEMPLATE_DIR}" + + template_dir = os.listdir(TEMPLATE_DIR) + result = False for test in template_dir: - if test in [".git",".gitignore","__init__.py","LICENSE"]: + if test in [".git", ".gitignore", "__init__.py", "LICENSE"]: continue elif test in templates: result = True @@ -18,12 +25,11 @@ def test_check_all_templates_dir(): assert result == True def test_check_for_main(): - path = r"\fenn\templates" - template_dir = os.listdir(path) - result = False + template_dir = os.listdir(TEMPLATE_DIR) + result = False for test in template_dir: - main_path = os.path.join(path, test, "main.py") - if test in [".git",".gitignore","__init__.py","LICENSE"]: + main_path = os.path.join(TEMPLATE_DIR, test, "main.py") + if test in [".git", ".gitignore", "__init__.py", "LICENSE"]: continue elif os.path.exists(main_path): result = True @@ -32,12 +38,11 @@ def test_check_for_main(): assert result == True def test_check_for_requirement(): - path = r"\fenn\templates" - template_dir = os.listdir(path) - result = False + template_dir = os.listdir(TEMPLATE_DIR) + result = False for test in template_dir: - requirement_path = os.path.join(path, test, "requirements.txt") - if test in [".git",".gitignore","__init__.py","LICENSE"]: + requirement_path = os.path.join(TEMPLATE_DIR, test, "requirements.txt") + if test in [".git", ".gitignore", "__init__.py", "LICENSE"]: continue elif os.path.exists(requirement_path): result = True @@ -46,13 +51,13 @@ def test_check_for_requirement(): assert result == True def test_main(): - path = r"\fenn\templates" - template_dir = os.listdir(path) - result = False + template_dir = os.listdir(TEMPLATE_DIR) + result = False for test in template_dir: - requirement_path = os.path.join(path, test, "requirements.txt") - main_path = os.path.join(path, test, "main.py") - if test in [".git",".gitignore","__init__.py","LICENSE"]: + requirement_path = os.path.join(TEMPLATE_DIR, test, "requirements.txt") + main_path = os.path.join(TEMPLATE_DIR, test, "main.py") + + if test in [".git", ".gitignore", "__init__.py", "LICENSE"]: continue else: try: @@ -72,6 +77,7 @@ def test_main(): ) print(f"{test} ran successfully") + result = True except subprocess.CalledProcessError as e: raise AssertionError(f"{test} failed: {e}") @@ -83,4 +89,4 @@ def test_main(): stderr=subprocess.DEVNULL, ) - assert result == True \ No newline at end of file + assert result == True From 50935c9c629fb94a222cd1b3422cf3b93ff22f50 Mon Sep 17 00:00:00 2001 From: DagaBhai Date: Sat, 4 Jul 2026 11:04:22 +0530 Subject: [PATCH 3/6] Refactor assertions and template list formatting --- tests/unit/templates/test_temp_main.py | 48 ++++++++++++++++++-------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/tests/unit/templates/test_temp_main.py b/tests/unit/templates/test_temp_main.py index 6678d99..cad4e2e 100644 --- a/tests/unit/templates/test_temp_main.py +++ b/tests/unit/templates/test_temp_main.py @@ -1,18 +1,30 @@ import os import subprocess import sys -import pytest TEST_DIR = os.path.dirname(os.path.abspath(__file__)) TEMPLATE_DIR = os.path.abspath(os.path.join(TEST_DIR, "..", "templates")) + def test_check_all_templates_dir(): templates = [ - "chatbot", "cnn", "empty", "lora-cls", "lstm-cls", "lstm-gen", - "mlp-binary", "mlp-multiclass", "mlp-regression", "timm-cls", "vae", "yolo" + "chatbot", + "cnn", + "empty", + "lora-cls", + "lstm-cls", + "lstm-gen", + "mlp-binary", + "mlp-multiclass", + "mlp-regression", + "timm-cls", + "vae", + "yolo", ] - assert os.path.exists(TEMPLATE_DIR), f"Templates directory not found at {TEMPLATE_DIR}" - + assert os.path.exists(TEMPLATE_DIR), ( + f"Templates directory not found at {TEMPLATE_DIR}" + ) + template_dir = os.listdir(TEMPLATE_DIR) result = False for test in template_dir: @@ -22,7 +34,8 @@ def test_check_all_templates_dir(): result = True else: result = False - assert result == True + assert result is True + def test_check_for_main(): template_dir = os.listdir(TEMPLATE_DIR) @@ -35,7 +48,8 @@ def test_check_for_main(): result = True else: result = False - assert result == True + assert result is True + def test_check_for_requirement(): template_dir = os.listdir(TEMPLATE_DIR) @@ -48,7 +62,8 @@ def test_check_for_requirement(): result = True else: result = False - assert result == True + assert result is True + def test_main(): template_dir = os.listdir(TEMPLATE_DIR) @@ -56,13 +71,11 @@ def test_main(): for test in template_dir: requirement_path = os.path.join(TEMPLATE_DIR, test, "requirements.txt") main_path = os.path.join(TEMPLATE_DIR, test, "main.py") - + if test in [".git", ".gitignore", "__init__.py", "LICENSE"]: continue else: try: - print(f"\nTesting {test}") - subprocess.run( [sys.executable, "-m", "pip", "install", "-r", requirement_path], check=True, @@ -76,7 +89,6 @@ def test_main(): stderr=subprocess.DEVNULL, ) - print(f"{test} ran successfully") result = True except subprocess.CalledProcessError as e: @@ -84,9 +96,17 @@ def test_main(): finally: subprocess.run( - [sys.executable, "-m", "pip", "uninstall", "-y", "-r", requirement_path], + [ + sys.executable, + "-m", + "pip", + "uninstall", + "-y", + "-r", + requirement_path, + ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) - assert result == True + assert result is True From cca23cc2c2f1534aca8890482e1f7636d43e8fc7 Mon Sep 17 00:00:00 2001 From: DagaBhai Date: Sat, 4 Jul 2026 11:12:55 +0530 Subject: [PATCH 4/6] Update test_temp_main.py --- tests/unit/templates/test_temp_main.py | 157 ++++++++++--------------- 1 file changed, 61 insertions(+), 96 deletions(-) diff --git a/tests/unit/templates/test_temp_main.py b/tests/unit/templates/test_temp_main.py index cad4e2e..e593a8e 100644 --- a/tests/unit/templates/test_temp_main.py +++ b/tests/unit/templates/test_temp_main.py @@ -2,111 +2,76 @@ import subprocess import sys +import pytest + TEST_DIR = os.path.dirname(os.path.abspath(__file__)) TEMPLATE_DIR = os.path.abspath(os.path.join(TEST_DIR, "..", "templates")) +TEMPLATES_LIST = [ + "chatbot", + "cnn", + "empty", + "lora-cls", + "lstm-cls", + "lstm-gen", + "mlp-binary", + "mlp-multiclass", + "mlp-regression", + "timm-cls", + "vae", + "yolo", +] -def test_check_all_templates_dir(): - templates = [ - "chatbot", - "cnn", - "empty", - "lora-cls", - "lstm-cls", - "lstm-gen", - "mlp-binary", - "mlp-multiclass", - "mlp-regression", - "timm-cls", - "vae", - "yolo", - ] - assert os.path.exists(TEMPLATE_DIR), ( - f"Templates directory not found at {TEMPLATE_DIR}" - ) - - template_dir = os.listdir(TEMPLATE_DIR) - result = False - for test in template_dir: - if test in [".git", ".gitignore", "__init__.py", "LICENSE"]: - continue - elif test in templates: - result = True - else: - result = False - assert result is True - - -def test_check_for_main(): - template_dir = os.listdir(TEMPLATE_DIR) - result = False - for test in template_dir: - main_path = os.path.join(TEMPLATE_DIR, test, "main.py") - if test in [".git", ".gitignore", "__init__.py", "LICENSE"]: - continue - elif os.path.exists(main_path): - result = True - else: - result = False - assert result is True - -def test_check_for_requirement(): - template_dir = os.listdir(TEMPLATE_DIR) - result = False - for test in template_dir: - requirement_path = os.path.join(TEMPLATE_DIR, test, "requirements.txt") - if test in [".git", ".gitignore", "__init__.py", "LICENSE"]: - continue - elif os.path.exists(requirement_path): - result = True - else: - result = False - assert result is True +def get_template_directories(): + if not os.path.exists(TEMPLATE_DIR): + return [] + return [ + d + for d in os.listdir(TEMPLATE_DIR) + if d not in [".git", ".gitignore", "__init__.py", "LICENSE"] + ] -def test_main(): - template_dir = os.listdir(TEMPLATE_DIR) - result = False - for test in template_dir: - requirement_path = os.path.join(TEMPLATE_DIR, test, "requirements.txt") - main_path = os.path.join(TEMPLATE_DIR, test, "main.py") +def test_templates_dir_exists(): + assert os.path.exists(TEMPLATE_DIR), ( + f"Templates directory not found at {TEMPLATE_DIR}. Did you pull the submodule?" + ) - if test in [".git", ".gitignore", "__init__.py", "LICENSE"]: - continue - else: - try: - subprocess.run( - [sys.executable, "-m", "pip", "install", "-r", requirement_path], - check=True, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - ) - subprocess.run( - [sys.executable, main_path], - check=True, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - ) - result = True +@pytest.mark.parametrize("template_name", get_template_directories()) +def test_template_structure_and_execution(template_name): + assert template_name in TEMPLATES_LIST, ( + f"Unexpected directory found in templates: {template_name}" + ) - except subprocess.CalledProcessError as e: - raise AssertionError(f"{test} failed: {e}") + template_path = os.path.join(TEMPLATE_DIR, template_name) + main_path = os.path.join(template_path, "main.py") + requirement_path = os.path.join(template_path, "requirements.txt") - finally: - subprocess.run( - [ - sys.executable, - "-m", - "pip", - "uninstall", - "-y", - "-r", - requirement_path, - ], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - ) + assert os.path.exists(main_path), f"Missing main.py in {template_name}" + assert os.path.exists(requirement_path), ( + f"Missing requirements.txt in {template_name}" + ) - assert result is True + try: + subprocess.run( + [sys.executable, "-m", "pip", "install", "-r", requirement_path], + check=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + subprocess.run( + [sys.executable, main_path], + check=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + except subprocess.CalledProcessError as e: + raise AssertionError(f"Template '{template_name}' execution failed: {e}") + finally: + subprocess.run( + [sys.executable, "-m", "pip", "uninstall", "-y", "-r", requirement_path], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) From 006638cfc1670cb7f2d07f6038de8b2ed83a6163 Mon Sep 17 00:00:00 2001 From: DagaBhai Date: Sat, 4 Jul 2026 11:22:38 +0530 Subject: [PATCH 5/6] run tests for submodules --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9082ce9..cad58aa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -21,6 +21,7 @@ jobs: uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false + submodules: true - name: Set up Python uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 @@ -63,6 +64,7 @@ jobs: uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false + submodules: true - name: Set up Python uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 From 2b7dd53a2b0dc2ef36cde898c0606e7e1966e7d5 Mon Sep 17 00:00:00 2001 From: "24f3004373@ds.study.iitm.ac.in" <24f3004373@ds.study.iitm.ac.in> Date: Wed, 15 Jul 2026 15:16:47 +0530 Subject: [PATCH 6/6] Bump templates submodule to latest commit --- templates | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates b/templates index bd62cc1..8a4f5c2 160000 --- a/templates +++ b/templates @@ -1 +1 @@ -Subproject commit bd62cc1426e3aa06e5be165c8cb49040c58991cc +Subproject commit 8a4f5c244c0fbc3cf2d684c14d6ccb0831467906