import os
import cflearn
import platform
import unittest

from cfdata.tabular import TabularDataset

num_jobs = 0 if platform.system() == "Linux" else 2
logging_folder = "__test_zoo__"


class TestZoo(unittest.TestCase):
    @staticmethod
    def _test_zoo_core(model: str) -> None:
        x, y = TabularDataset.iris().xy
        zoo_folder = os.path.join(logging_folder, f"__{model}__")
        zoo = cflearn.Zoo(model)
        for key, config in zoo.benchmarks.items():
            local_logging_folder = os.path.join(zoo_folder, key)
            config["logging_folder"] = local_logging_folder
            m = cflearn.make(model, **config).fit(x, y)
            cflearn.evaluate(x, y, pipelines=m)
        cflearn._rmtree(logging_folder)

    def test_fcnn_zoo(self) -> None:
        self._test_zoo_core("fcnn")

    def test_tree_dnn_zoo(self) -> None:
        self._test_zoo_core("tree_dnn")


if __name__ == "__main__":
    unittest.main()

[(33, 'unittest.main', 'unittest.main', False, 'import unittest\n'), (8, 'platform.system', 'platform.system', False, 'import platform\n'), (16, 'os.path.join', 'os.path.join', False, 'import os\n'), (17, 'cflearn.Zoo', 'cflearn.Zoo', False, 'import cflearn\n'), (23, 'cflearn._rmtree', 'cflearn._rmtree', False, 'import cflearn\n'), (15, 'cfdata.tabular.TabularDataset.iris', 'TabularDataset.iris', False, 'from cfdata.tabular import TabularDataset\n'), (19, 'os.path.join', 'os.path.join', False, 'import os\n'), (22, 'cflearn.evaluate', 'cflearn.evaluate', False, 'import cflearn\n'), (21, 'cflearn.make', 'cflearn.make', False, 'import cflearn\n')]