def test_notebook_runner_2a_eco(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        if is_travis_or_appveyor():
            # Requires authentification.
            return

        from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from 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
            if "td2a_TD5_Traitement_automatique_des_langues_en_Python" in n:
                return False
            return True

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

        if is_travis_or_appveyor():
            # Requires authentification.
            return

        from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from 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
            if "td2a_TD5_Traitement_automatique_des_langues_en_Python" in n:
                return False
            return True

        execute_notebooks(temp, keepnote,
                          filter,
                          fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=ensae_teaching_cs)
    def test_notebook_runner_2a_ml(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from 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=ensae_teaching_cs)
    def test_notebook_runner_2a_ml(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from 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

        execute_notebooks(temp, keepnote, filter, fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=ensae_teaching_cs)
    def test_notebook_runner_2a_eco_nlp_long(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        if is_travis_or_appveyor():
            # Requires authentification.
            return

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

        folder = os.path.join(temp, "ressources_googleplus")
        if not os.path.exists(folder):
            os.mkdir(folder)
        jsfile = os.path.join(os.path.dirname(keepnote[0]),
                              "ressources_googleplus", "107033731246200681024.json")
        shutil.copy(jsfile, folder)

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

        execute_notebooks(temp, keepnote, filter, fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=ensae_teaching_cs)
 def test_notebook_runner_enonce(self):
     fLOG(
         __file__,
         self._testMethodName,
         OutputPrint=__name__ == "__main__")
     from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks
     from 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=ensae_teaching_cs)
 def test_notebook_runner(self):
     fLOG(
         __file__,
         self._testMethodName,
         OutputPrint=__name__ == "__main__")
     from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks
     from 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=ensae_teaching_cs)
Ejemplo n.º 8
0
 def test_notebook_runner(self):
     fLOG(__file__,
          self._testMethodName,
          OutputPrint=__name__ == "__main__")
     from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks
     from 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=ensae_teaching_cs)
    def test_notebook_runner_2a_eco_scraping(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from 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
            if "corrige" in n:
                return False
            return True

        execute_notebooks(temp, keepnote, filter, fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=ensae_teaching_cs)
Ejemplo n.º 10
0
    def test_notebook_runner_2a_algo(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from 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

        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=ensae_teaching_cs)
Ejemplo n.º 11
0
    def test_notebook_runner_2a_eco_scraping(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from 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
            if "corrige" in n:
                return False
            return True

        execute_notebooks(temp,
                          keepnote,
                          filter,
                          fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=ensae_teaching_cs)
Ejemplo n.º 12
0
    def test_notebook_runner_2a_eco_sncf(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")
        from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from 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=ensae_teaching_cs)
Ejemplo n.º 13
0
 def test_simple_database(self):
     name = simple_database(local=True)
     assert name.endswith(".db3")