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()

[((931, 946), 'unittest.main', 'unittest.main', ([], {}), '()\n', (944, 946), False, 'import unittest\n'), ((117, 134), 'platform.system', 'platform.system', ([], {}), '()\n', (132, 134), False, 'import platform\n'), ((344, 388), 'os.path.join', 'os.path.join', (['logging_folder', 'f"""__{model}__"""'], {}), "(logging_folder, f'__{model}__')\n", (356, 388), False, 'import os\n'), ((403, 421), 'cflearn.Zoo', 'cflearn.Zoo', (['model'], {}), '(model)\n', (414, 421), False, 'import cflearn\n'), ((710, 741), 'cflearn._rmtree', 'cflearn._rmtree', (['logging_folder'], {}), '(logging_folder)\n', (725, 741), False, 'import cflearn\n'), ((298, 319), 'cfdata.tabular.TabularDataset.iris', 'TabularDataset.iris', ([], {}), '()\n', (317, 319), False, 'from cfdata.tabular import TabularDataset\n'), ((508, 537), 'os.path.join', 'os.path.join', (['zoo_folder', 'key'], {}), '(zoo_folder, key)\n', (520, 537), False, 'import os\n'), ((666, 701), 'cflearn.evaluate', 'cflearn.evaluate', (['x', 'y'], {'pipelines': 'm'}), '(x, y, pipelines=m)\n', (682, 701), False, 'import cflearn\n'), ((614, 643), 'cflearn.make', 'cflearn.make', (['model'], {}), '(model, **config)\n', (626, 643), False, 'import cflearn\n')]