Files
NexQuant/test/utils/test_import.py
T
you-n-g f9bd19179f feat: kaggle refactor (#489)
* init trail

* Add spec info

* auto unzip mlebench prepared data for out scenario

* successfully run example

* successfully run main

* simplify load traing

* extract load_from_raw_data

* split the fies(still buggy)
It should stop on ~20 epoch and reach the end

* some changes

* Fix bug to run example

* (success) until feature

* refine model and ensemble

* add metrics in ens.py

* update README &  spec.md

* ens change

* fix ens bug

* Delete rdagent/scenarios/kaggle/tpl_ex/aerial-cactus-identification/train.py

* add template_path in KG_conf

* fix test kaggle

* CI

* make test_import not check kaggle template codes

---------

Co-authored-by: Bowen Xian <xianbowen@outlook.com>
2024-11-20 17:01:18 +08:00

49 lines
1.5 KiB
Python

import importlib
import os
import unittest
from pathlib import Path
import pytest
@pytest.mark.offline
class TestRDAgentImports(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.rdagent_directory = Path(__file__).resolve().parent.parent.parent
cls.modules = list(cls.import_all_modules_from_directory(cls.rdagent_directory))
@staticmethod
def import_all_modules_from_directory(directory):
for file in directory.joinpath("rdagent").rglob("*.py"):
fstr = str(file)
if "meta_tpl" in fstr:
continue
if "template" in fstr or "tpl" in fstr:
continue
if "model_coder" in fstr:
continue
if (
fstr.endswith("rdagent/log/ui/app.py")
or fstr.endswith("rdagent/app/cli.py")
or fstr.endswith("rdagent/app/CI/run.py")
):
# the entrance points
continue
yield fstr[fstr.index("rdagent") : -3].replace("/", ".")
def test_import_modules(self):
print(self.modules)
for module_name in self.modules:
with self.subTest(module=module_name):
try:
print(module_name)
importlib.import_module(module_name)
except Exception as e:
self.fail(f"Failed to import {module_name}: {e}")
if __name__ == "__main__":
unittest.main()