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, 4, 33, 19), 'unittest.main', 'unittest.main', ({}, {}), '()', False, 'import unittest\n'), ((8, 16, 8, 33), 'platform.system', 'platform.system', ({}, {}), '()', False, 'import platform\n'), ((16, 21, 16, 65), 'os.path.join', 'os.path.join', ({(16, 34, 16, 48): 'logging_folder', (16, 50, 16, 64): 'f"""__{model}__"""'}, {}), "(logging_folder, f'__{model}__')", False, 'import os\n'), ((17, 14, 17, 32), 'cflearn.Zoo', 'cflearn.Zoo', ({(17, 26, 17, 31): 'model'}, {}), '(model)', False, 'import cflearn\n'), ((23, 8, 23, 39), 'cflearn._rmtree', 'cflearn._rmtree', ({(23, 24, 23, 38): 'logging_folder'}, {}), '(logging_folder)', False, 'import cflearn\n'), ((15, 15, 15, 36), 'cfdata.tabular.TabularDataset.iris', 'TabularDataset.iris', ({}, {}), '()', False, 'from cfdata.tabular import TabularDataset\n'), ((19, 35, 19, 64), 'os.path.join', 'os.path.join', ({(19, 48, 19, 58): 'zoo_folder', (19, 60, 19, 63): 'key'}, {}), '(zoo_folder, key)', False, 'import os\n'), ((22, 12, 22, 47), 'cflearn.evaluate', 'cflearn.evaluate', (), '', False, 'import cflearn\n'), ((21, 16, 21, 45), 'cflearn.make', 'cflearn.make', ({(21, 29, 21, 34): 'model'}, {}), '(model, **config)', False, 'import cflearn\n')]