Example #1
0
    def test_notebook_runner_2a_eco_scraping(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        if is_travis_or_appveyor() == "appveyor":
            # too long for appveyor
            return
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a, unittest_raise_exception_notebook
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_eco_scraping")
        keepnote = ls_notebooks("td2a_eco")
        assert len(keepnote) > 0
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "Scraping" not in n:
                return False
            return True

        if is_travis_or_appveyor() == "travis":
            warnings.warn("execution does not stop")
            return

        res = execute_notebooks(temp, keepnote,
                                filter,
                                fLOG=fLOG,
                                clean_function=clean_function_1a)
        unittest_raise_exception_notebook(res, fLOG)
    def test_long_notebook_runner_2a_ml(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        if is_travis_or_appveyor() == "appveyor":
            # too long for appveyor
            return
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a, unittest_raise_exception_notebook
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_eco")
        keepnote = ls_notebooks("td2a_ml")
        assert len(keepnote) > 0
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "deep_python" in n:
                return True
            return False

        if is_travis_or_appveyor() == "travis":
            warnings.warn("execution does not stop")
            return

        res = execute_notebooks(temp,
                                keepnote,
                                filter,
                                fLOG=fLOG,
                                clean_function=clean_function_1a)
        unittest_raise_exception_notebook(res, fLOG)
Example #3
0
    def test_notebook_runner_2a_ml(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_ml4")
        keepnote = ls_notebooks("td2a_ml")
        keepnote = [_ for _ in keepnote if "overfitting" in _]
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "SNCF" in n:
                return False
            if "Scraping" in n:
                return False
            if "deep_python" in n:
                return False
            if "h2o" in n:
                # h2o is not working from a virtual environment
                return False
            if "td2a" in os.path.split(n)[-1]:
                # already tested by others tests
                return False
            if "libraries" in n:
                return False
            return True

        execute_notebooks(temp,
                          keepnote,
                          filter,
                          fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=src.ensae_teaching_cs)
Example #4
0
    def test_simple_database(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        name = simple_database(local=True)
        assert name.endswith(".db3")
    def test_long_notebook_runner_2a_ml(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        if is_travis_or_appveyor() == "appveyor":
            # too long for appveyor
            return
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_ml_deep")
        keepnote = ls_notebooks("td2a_deep")
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "deep_python" in n:
                return True
            return False

        if is_travis_or_appveyor() == "travis":
            warnings.warn("execution does not stop")
            return

        clog = CustomLog(temp)
        execute_notebooks(temp,
                          keepnote,
                          filter,
                          fLOG=clog,
                          clean_function=clean_function_1a,
                          dump=src.ensae_teaching_cs)
    def test_notebook_runner_2a_eco_sncf(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a, unittest_raise_exception_notebook
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_eco_sncf")
        keepnote = ls_notebooks("td2a_eco")
        assert len(keepnote) > 0
        shutil.copy(simple_database(), temp)
        folder_note = os.path.split(keepnote[0])[0]
        jsfile = os.path.join(folder_note, "stop_areas.json")
        shutil.copy(jsfile, temp)

        def filter(i, n):
            if "SNCF" not in n:
                return False
            return True

        if is_travis_or_appveyor() == "travis":
            warnings.warn("execution does not stop")
            return

        res = execute_notebooks(temp, keepnote,
                                filter,
                                fLOG=fLOG,
                                clean_function=clean_function_1a)
        unittest_raise_exception_notebook(res, fLOG)
    def test_notebook_runner_2a_eco(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        if is_travis_or_appveyor():
            # Requires authentification.
            return

        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_eco")
        keepnote = ls_notebooks("td2a_eco")
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "SNCF" in n:
                return False
            if "Scraping" in n:
                return False
            if "2.ipynb" in n:
                return False
            if "flask" in n.lower():
                # flask from a notebook does not work
                return False
            return True

        execute_notebooks(temp, keepnote,
                          filter,
                          fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=src.ensae_teaching_cs)
Example #8
0
    def test_simple_database(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        name = simple_database(local=True)
        assert name.endswith(".db3")
Example #9
0
 def test_notebook_runner_enonce(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks
     from src.ensae_teaching_cs.data import simple_database
     temp = get_temp_folder(__file__, "temp_notebook2a_eco_sql")
     keepnote = ls_notebooks("td2a_eco")
     shutil.copy(simple_database(), temp)
     execute_notebooks(temp,
                       keepnote, (lambda i, n: "sql" in n),
                       fLOG=fLOG,
                       replacements=self.get_replacements(),
                       dump=src.ensae_teaching_cs)
Example #10
0
 def test_notebook_runner(self):
     fLOG(
         __file__,
         self._testMethodName,
         OutputPrint=__name__ == "__main__")
     from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, unittest_raise_exception_notebook
     from src.ensae_teaching_cs.data import simple_database
     temp = get_temp_folder(__file__, "temp_notebook2a_2_corection")
     keepnote = ls_notebooks("td2a")
     assert len(keepnote) > 0
     shutil.copy(simple_database(), temp)
     res = execute_notebooks(temp, keepnote, lambda i, n: "_2" in n and
                             "correction" in n and "_2B" not in n, fLOG=fLOG)
     unittest_raise_exception_notebook(res, fLOG)
 def test_notebook_runner(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks
     from src.ensae_teaching_cs.data import simple_database
     temp = get_temp_folder(__file__, "temp_notebook2a_2_corection")
     keepnote = ls_notebooks("td2a")
     shutil.copy(simple_database(), temp)
     execute_notebooks(
         temp,
         keepnote,
         (lambda i, n: "n_2" in n and "correction" in n and "_2B" not in n),
         fLOG=fLOG,
         dump=src.ensae_teaching_cs)
Example #12
0
 def test_notebook_runner(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, unittest_raise_exception_notebook
     from src.ensae_teaching_cs.data import simple_database
     temp = get_temp_folder(__file__, "temp_notebook2a_2_corection")
     keepnote = ls_notebooks("td2a")
     assert len(keepnote) > 0
     shutil.copy(simple_database(), temp)
     res = execute_notebooks(
         temp,
         keepnote,
         lambda i, n: "_2" in n and "correction" in n and "_2B" not in n,
         fLOG=fLOG)
     unittest_raise_exception_notebook(res, fLOG)
Example #13
0
 def test_notebook_runner_enonce(self):
     fLOG(
         __file__,
         self._testMethodName,
         OutputPrint=__name__ == "__main__")
     from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, unittest_raise_exception_notebook
     from src.ensae_teaching_cs.data import simple_database
     temp = get_temp_folder(__file__, "temp_notebook2a_eco_sql")
     keepnote = ls_notebooks("td2a_eco")
     shutil.copy(simple_database(), temp)
     assert len(keepnote) > 0
     res = execute_notebooks(
         temp,
         keepnote,
         lambda i,
         n: "sql" in n,
         fLOG=fLOG,
         replacements=self.get_replacements())
     unittest_raise_exception_notebook(res, fLOG)
    def test_notebook_runner_2a_algo(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        if is_travis_or_appveyor() == "appveyor":
            # too long for appveyor
            return
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_algo")
        keepnote = ls_notebooks("td2a_algo")
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "SNCF" in n:
                return False
            return True

        def clean_function_1a_upgraded(code):
            code = clean_function_1a(code)
            rep = "[1000, 2000, 5000, 10000, 12000, 15000, 17000, 20000]"
            by = "[1000, 2000]"
            code = code.replace(rep, by)
            rep = "[10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000]"
            by = "[10, 20, 50, 100, 200]"
            code = code.replace(rep, by)
            return code

        if is_travis_or_appveyor() == "travis":
            # execution does not stop
            return

        fold = os.path.dirname(keepnote[0])
        for png in os.listdir(fold):
            if ".png" not in png:
                continue
            fLOG("copy", png)
            shutil.copy(os.path.join(fold, png), temp)

        execute_notebooks(temp, keepnote, filter, fLOG=fLOG,
                          clean_function=clean_function_1a_upgraded,
                          dump=src.ensae_teaching_cs)
    def test_notebook_runner_2a_eco_scraping(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_eco_scraping")
        keepnote = ls_notebooks("td2a_eco")
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "Scraping" not in n:
                return False
            return True

        execute_notebooks(temp,
                          keepnote,
                          filter,
                          fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=src.ensae_teaching_cs)
Example #16
0
    def test_notebook_runner_2a_ml(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        if is_travis_or_appveyor() == "appveyor":
            # too long for appveyor
            return
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_ml")
        keepnote = ls_notebooks("td2a_ml")
        keepnote = [_ for _ in keepnote if "machine_learning" in _]
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "SNCF" in n:
                return False
            if "Scraping" in n:
                return False
            if "deep_python" in n:
                return False
            if "h2o" in n:
                # h2o is not working from a virtual environment
                return False
            if "td2a" in os.path.split(n)[-1]:
                # already tested by others tests
                return False
            return True

        if is_travis_or_appveyor() == "travis":
            warnings.warn("execution does not stop")
            return

        execute_notebooks(temp,
                          keepnote,
                          filter,
                          fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=src.ensae_teaching_cs)
Example #17
0
    def test_notebook_runner_2a_ml(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        if is_travis_or_appveyor() == "appveyor":
            # too long for appveyor
            return
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a, unittest_raise_exception_notebook
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_eco")
        keepnote = ls_notebooks("td2a_ml")
        assert len(keepnote) > 0
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "SNCF" in n:
                return False
            if "Scraping" in n:
                return False
            if "deep_python" in n:
                return False
            if "h2o" in n:
                # h2o is not working from a virtual environment
                return False
            if "td2a" in os.path.split(n)[-1]:
                # already tested by others tests
                return False
            return True

        if is_travis_or_appveyor() == "travis":
            warnings.warn("execution does not stop")
            return

        res = execute_notebooks(temp, keepnote,
                                filter,
                                fLOG=fLOG,
                                clean_function=clean_function_1a)
        unittest_raise_exception_notebook(res, fLOG)
    def test_notebook_runner_2a_eco_sncf(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        from src.ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from src.ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_eco_sncf")
        keepnote = ls_notebooks("td2a_eco")
        shutil.copy(simple_database(), temp)
        folder_note = os.path.split(keepnote[0])[0]
        jsfile = os.path.join(folder_note, "stop_areas.json")
        shutil.copy(jsfile, temp)

        def filter(i, n):
            if "SNCF" not in n:
                return False
            return True

        execute_notebooks(temp,
                          keepnote,
                          filter,
                          fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=src.ensae_teaching_cs)