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_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_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_2a_long(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") if "travis" in sys.executable: # skip travis and R warnings.warn( "travis, unable to test TestNotebookRunner2a_long.test_notebook_runner_2a_long") return if "R_HOME" not in os.environ or not os.path.exists(os.environ["R_HOME"]): paths = [r"C:\Program Files\R\R-3.2.4revised", r"C:\Program Files\R\R-3.2.4", r"C:\Program Files\R\R-3.2.3", r"C:\Program Files\R\R-3.2.2"] for path in paths: if os.path.exists(path): os.environ["R_HOME"] = path break if "R_HOME" not in os.environ: warnings.warn("No installed R") return from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks from ensae_teaching_cs.automation.notebook_test_helper import clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_long_") keepnote = ls_notebooks("2a") execute_notebooks(temp, keepnote, (lambda i, n: "python_r" in n), 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_correction_1_7(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook1a_correction_1_7") keepnote = ls_notebooks("td1a") fold = os.path.dirname(keepnote[0]) cp = os.path.join(temp, "..", "data", "seance4_excel.txt") shutil.copy(cp, temp) cp = os.path.join(temp, "..", "data", "seance4_excel.xlsx") shutil.copy(cp, temp) cp = os.path.join(fold, "td2_1.png") shutil.copy(cp, temp) execute_notebooks( temp, keepnote, lambda i, n: "_12" not in n and "session6." not in n and "session8." not in n and "session9." not in n and "session_10." not in n and "session_11." not in n and "session5." not in n and "deviner" not in n and "correction" in n, 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_correction_1_7(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook1a_correction_1_7") keepnote = ls_notebooks("td1a") fold = os.path.dirname(keepnote[0]) cp = os.path.join(temp, "..", "data", "seance4_excel.txt") shutil.copy(cp, temp) cp = os.path.join(temp, "..", "data", "seance4_excel.xlsx") shutil.copy(cp, temp) cp = os.path.join(fold, "td2_1.png") shutil.copy(cp, temp) execute_notebooks(temp, keepnote, lambda i, n: "_12" not in n and "session6." not in n and "session8." not in n and "session9." not in n and "session_10." not in n and "session_11." not in n and "session5." not in n and "deviner" not in n and "correction" in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def common_notebook_runner_2a_eco_nlp_enonce(self, sub): from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_eco_nlp_" + sub) keepnote = ls_notebooks("td2a_eco") if sub in ("correction", "enonce"): folder = os.path.join(temp, "ressources_googleplus") os.mkdir(folder) folder_note = os.path.split(keepnote[0])[0] jsfile = os.path.join( folder_note, "ressources_googleplus", "107033731246200681024.json") shutil.copy(jsfile, folder) def filter(i, n): if "Traitement_automatique" not in n: return False if sub == "enonce": if "correction" in n: return False elif sub not in n: return False return True res = execute_notebooks(temp, keepnote, filter, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs) return res
def a_test_notebook_runner(self, name, folder): from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a from ensae_teaching_cs.helpers.size_helper import total_size self.assertTrue(total_size) temp = get_temp_folder(__file__, "temp_notebook_123_{0}".format(name)) keepnote = ls_notebooks(folder) self.assertTrue(len(keepnote) > 0) def custom_clean_function_1a(cell): if "..." in cell: return "" if "b[0,0] = 44444444" in cell: return "" return clean_function_1a(cell) replacements = { 'input("Entrez un nombre")': 'random.randint(0, 100)', 'input(message)': 'random.randint(0, 100)' } execute_notebooks(temp, keepnote, lambda i, n: name in n, fLOG=fLOG, replacements=replacements, clean_function=custom_clean_function_1a, dump=ensae_teaching_cs)
def common_notebook_runner_2a_eco_nlp_enonce(self, sub): from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_eco_nlp_" + sub) keepnote = ls_notebooks("td2a_eco") if sub in ("correction", "enonce"): folder = os.path.join(temp, "ressources_googleplus") os.mkdir(folder) folder_note = os.path.split(keepnote[0])[0] jsfile = os.path.join(folder_note, "ressources_googleplus", "107033731246200681024.json") shutil.copy(jsfile, folder) def filter(i, n): if "Traitement_automatique" not in n: return False if sub == "enonce": if "correction" in n: return False elif sub not in n: return False return True res = execute_notebooks(temp, keepnote, filter, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs) return res
def test_notebook_runner_enonce_algo(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") temp = get_temp_folder(__file__, "temp_notebook1a_algo") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a keepnote = ls_notebooks("td1a_algo") def filter(i, n): if is_travis_or_appveyor() == "travis": if "graph1exo_parcours" in n or "graph4exos" in n: # Graphviz is installed but cannot be found. return False if "graph_spectral_clustering" in n: # Graphviz is installed but cannot be found. return False return "BJKST" in n or ("enonce" not in n and "correction" not in n) execute_notebooks(temp, keepnote, filter, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") # this notebook describes how to distribute the work with multiple processors # it requires to start multiple clusters first (a command line) # and to stop them afterwards # it still needs to be implemented # we skip ! warnings.warn( "TODO: implement a unit test testing the distribution on multiple processors" ) do_test = False if do_test: temp = get_temp_folder(__file__, "temp_notebook2a_2_enonce_2D") keepnote = ls_notebooks("td2a") execute_notebooks( temp, keepnote, lambda i, n: "_2" in n and "enonce" in n and "_2D" in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_correction(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_3B_correction") keepnote = ls_notebooks("td2a_ml") execute_notebooks(temp, keepnote, (lambda i, n: "_3B" in n and "correction" in n), clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_correction(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_3A_correction") keepnote = ls_notebooks("td2a_ml") execute_notebooks(temp, keepnote, (lambda i, n: "_3A" in n and "correction" in n), clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_enonce_8(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook1a_enonce_8") keepnote = ls_notebooks("td1a_algo") execute_notebooks(temp, keepnote, lambda i, n: "cenonce_session8." in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_eleves(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks temp = get_temp_folder(__file__, "temp_notebook_eleves_2017") keepnote = ls_notebooks("notebook_eleves/2017-2018") self.assertTrue(len(keepnote) > 0) execute_notebooks(temp, keepnote, (lambda i, n: True), fLOG=fLOG, replacements=self.get_replacements(), dump=ensae_teaching_cs)
def test_notebook_runner_exposelong2(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebookexposelong2_") keepnote = ls_notebooks("expose") execute_notebooks(temp, keepnote, (lambda i, n: "paris_parcours" in n), fLOG=fLOG, deepfLOG=fLOG if __name__ == "__main__" else noLOG, clean_function=clean_function_1a, 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, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_1") keepnote = ls_notebooks("competitions/2016") execute_notebooks(temp, keepnote, (lambda i, n: "solution" not in n), clean_function=clean_function_1a, fLOG=fLOG, 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 temp = get_temp_folder(__file__, "temp_notebook2a_5") keepnote = ls_notebooks("2a") execute_notebooks(temp, keepnote, (lambda i, n: "_5" in n), fLOG=fLOG, dump=ensae_teaching_cs)
def test_notebook_runner_enonce_12(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks temp = get_temp_folder(__file__, "temp_notebook1a_enonce_12") keepnote = ls_notebooks("td1a_dfnp") execute_notebooks(temp, keepnote, (lambda i, n: "cenonce_session_12" in n), fLOG=fLOG, deepfLOG=fLOG if __name__ == "__main__" else noLOG, clean_function=TestNotebookRunner1a_enonce_12.clean_function, 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, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_1") keepnote = ls_notebooks("competitions/2016") execute_notebooks(temp, keepnote, (lambda i, n: "solution" not in n), clean_function=clean_function_1a, fLOG=fLOG, 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 a_test_notebook_runner_1a(self, name, folder): from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a from ensae_teaching_cs.helpers.size_helper import total_size self.assertTrue(total_size) temp = get_temp_folder(__file__, "temp_notebook_123_{0}".format(name)) keepnote = ls_notebooks(folder) self.assertTrue(len(keepnote) > 0) execute_notebooks(temp, keepnote, lambda i, n: name in n, fLOG=fLOG, clean_function=clean_function_1a, 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)
def test_notebook_runner_enonce_home(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") temp = get_temp_folder(__file__, "temp_notebook1a_home") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks keepnote = ls_notebooks("td1a_home") sr = [_ for _ in keepnote if "json" in _] shutil.copy(sr[0], temp) execute_notebooks(temp, keepnote, filter, fLOG=fLOG, dump=ensae_teaching_cs)
def test_notebook_runner_exams(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebookexams_") keepnote = ls_notebooks("exams") execute_notebooks(temp, keepnote, lambda i, n: "git_" not in n and "interro_rapide_20_minutes_2014_11" not in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_correction(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks temp = get_temp_folder(__file__, "temp_notebook2a_4_correction") keepnote = ls_notebooks("td2a_ml") execute_notebooks(temp, keepnote, lambda i, n: "_4" in n and "correction" in n, fLOG=fLOG, replacements=self.get_replacements(), dump=ensae_teaching_cs)
def test_notebook_runner_eleves(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks temp = get_temp_folder(__file__, "temp_notebook_eleves_2017") keepnote = ls_notebooks("notebook_eleves/2017-2018") self.assertTrue(len(keepnote) > 0) execute_notebooks(temp, keepnote, (lambda i, n: True), fLOG=fLOG, replacements=self.get_replacements(), dump=ensae_teaching_cs)
def test_notebook_runner_soft_cpp(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") temp = get_temp_folder(__file__, "temp_notebook1a_soft") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a keepnote = ls_notebooks("td1a_soft") execute_notebooks(temp, keepnote, lambda i, n: "edit_correction" in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_correction_12(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks temp = get_temp_folder(__file__, "temp_notebook1a_correction_12") keepnote = ls_notebooks("td1a_dfnp") execute_notebooks(temp, keepnote, (lambda i, n: "correction_session_12" in n), fLOG=fLOG, deepfLOG=fLOG if __name__ == "__main__" else noLOG, clean_function=TestNotebookRunner1a_correction_12.clean_function, dump=ensae_teaching_cs)
def test_notebook_runner_correction_9(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a, copy_data_file temp = get_temp_folder(__file__, "temp_notebook1a_correction_9") keepnote = ls_notebooks("td1a_algo") copy_data_file("td1a", "seance4_excel.txt", temp, fLOG=fLOG) copy_data_file("td1a", "seance4_excel.xlsx", temp, fLOG=fLOG) execute_notebooks(temp, keepnote, (lambda i, n: "_12" not in n and "session9." in n and "correction" in n), fLOG=fLOG, clean_function=clean_function_1a, 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.automation.notebook_test_helper import clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_1_tiny") keepnote = ls_notebooks("td2a_eco") for k in keepnote: if "_1" in k: fLOG("*********", k) execute_notebooks(temp, keepnote, (lambda i, n: "_1" in n and "td2_eco_rappels_1a" in n), clean_function=clean_function_1a, fLOG=fLOG, dump=ensae_teaching_cs)
def test_notebook_runner_expose1(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebookexpose1_") keepnote = ls_notebooks("expose") execute_notebooks(temp, keepnote, lambda i, n: "velib" not in n and "paris_parcours" not in n and "ml_table_mortalite" not in n and "huge" not in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_exposelong3(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebookexposelong3_") keepnote = ls_notebooks("expose") execute_notebooks(temp, keepnote, lambda i, n: "mortalite" in n, fLOG=fLOG, deepfLOG=fLOG if __name__ == "__main__" else noLOG, clean_function=clean_function_1a, 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)
def test_notebook_runner_soft(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") temp = get_temp_folder(__file__, "temp_notebook1a_soft") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a keepnote = ls_notebooks("td1a_soft") for n in keepnote: fLOG(n) execute_notebooks(temp, keepnote, lambda i, n: "csharp" not in n and "edit_correction" not in n and "sql" not in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_correction_9(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a, copy_data_file temp = get_temp_folder(__file__, "temp_notebook1a_correction_9") keepnote = ls_notebooks("td1a_algo") copy_data_file("td1a", "seance4_excel.txt", temp, fLOG=fLOG) copy_data_file("td1a", "seance4_excel.xlsx", temp, fLOG=fLOG) execute_notebooks(temp, keepnote, (lambda i, n: "_12" not in n and "session9." in n and "correction" in n), fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_expose1(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebookexpose1_") keepnote = ls_notebooks("expose") execute_notebooks( temp, keepnote, lambda i, n: "velib" not in n and "paris_parcours" not in n and "ml_table_mortalite" not in n and "huge" not in n, fLOG=fLOG, clean_function=clean_function_1a, 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 temp = get_temp_folder(__file__, "temp_notebook2a_6") keepnote = ls_notebooks("td2a_algo") 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, lambda i, n: "_6" in n, fLOG=fLOG, dump=ensae_teaching_cs)
def test_notebook_runner_1a_part2(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.helpers.size_helper import total_size self.assertTrue(total_size) temp = get_temp_folder(__file__, "temp_notebook1a_part2") keepnote = ls_notebooks("1a") self.assertTrue(len(keepnote) > 0) execute_notebooks(temp, keepnote, lambda i, n: "deviner" not in n and "exercice" not in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def a_test_notebook_runner(self, name, folder): from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a from ensae_teaching_cs.helpers.size_helper import total_size self.assertTrue(total_size) temp = get_temp_folder(__file__, "temp_notebook_123_{0}".format(name)) keepnote = ls_notebooks(folder) self.assertTrue(len(keepnote) > 0) replacements = {'input("Entrez un nombre")': 'random.randint(0, 100)', 'input(message)': 'random.randint(0, 100)'} execute_notebooks(temp, keepnote, lambda i, n: name in n, fLOG=fLOG, replacements=replacements, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_1a_part2(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.helpers.size_helper import total_size self.assertTrue(total_size) temp = get_temp_folder(__file__, "temp_notebook1a_part2") keepnote = ls_notebooks("1a") self.assertTrue(len(keepnote) > 0) execute_notebooks( temp, keepnote, lambda i, n: "deviner" not in n and "exercice" not in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_2a_cffi(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_") keepnote = ls_notebooks("2a") def filter(i, n): if "cffi" not in n: return False return True execute_notebooks(temp, keepnote, filter, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def a_test_notebook_runner(self, name, folder, additional_path=None): from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a from ensae_teaching_cs.helpers.size_helper import total_size import ensae_teaching_cs self.assertTrue(total_size) temp = get_temp_folder(__file__, "temp_notebook_123_{0}".format(name)) keepnote = ls_notebooks(folder) self.assertTrue(len(keepnote) > 0) replacements = {'input("Entrez un nombre")': 'random.randint(0, 100)', 'input(message)': 'random.randint(0, 100)'} execute_notebooks(temp, keepnote, lambda i, n: name in n, fLOG=fLOG, replacements=replacements, clean_function=clean_function_1a, dump=ensae_teaching_cs, additional_path=additional_path)
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 temp = get_temp_folder(__file__, "temp_notebook2a_6") keepnote = ls_notebooks("td2a_algo") 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, lambda i, n: "_6" in n, fLOG=fLOG, dump=ensae_teaching_cs)
def test_notebook_runner_enonce_10(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") temp = get_temp_folder(__file__, "temp_notebook1a_enonce_10") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a keepnote = ls_notebooks("td1a_dfnp") 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, lambda i, n: "cenonce_session_10." in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_2a_bayesian(self): fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_") keepnote = ls_notebooks("2a") def filter(i, n): if "bayesian_with_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_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)
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, clean_function_1a temp = get_temp_folder(__file__, "temp_notebook2a_2_enonce") keepnote = ls_notebooks("td2a") 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) self.assertTrue(len(keepnote) > 0) execute_notebooks(temp, keepnote, lambda i, n: "_2" in n and "enonce" in n and "_2D" not in n and "_2B" not in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_enonce_algo(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") temp = get_temp_folder(__file__, "temp_notebook1a_algo") from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a keepnote = ls_notebooks("td1a_algo") def filter(i, n): if is_travis_or_appveyor() == "travis": if "graph1exo_parcours" in n or "graph4exos" in n: # Graphviz is installed but cannot be found. return False if "graph_spectral_clustering" in n: # Graphviz is installed but cannot be found. return False return "BJKST" in n or ("enonce" not in n and "correction" not in n) execute_notebooks(temp, keepnote, filter, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") # this notebook describes how to distribute the work with multiple processors # it requires to start multiple clusters first (a command line) # and to stop them afterwards # it still needs to be implemented # we skip ! warnings.warn( "TODO: implement a unit test testing the distribution on multiple processors") do_test = False if do_test: temp = get_temp_folder(__file__, "temp_notebook2a_2_enonce_2D") keepnote = ls_notebooks("td2a") execute_notebooks(temp, keepnote, lambda i, n: "_2" in n and "enonce" in n and "_2D" in n, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs)
def test_notebook_runner_ensae_sklearn(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.automation.notebook_test_helper import copy_data_file from ensae_teaching_cs.helpers.size_helper import total_size self.assertTrue(total_size) temp = get_temp_folder(__file__, "temp_notebook_ensae_sklearn") keepnote = ls_notebooks("sklearn_ensae_course") self.assertTrue(len(keepnote) > 0) copy_data_file("sklearn_ensae_course", "iris_setosa.jpg", temp, fLOG=fLOG) copy_data_file("sklearn_ensae_course", "iris_versicolor.jpg", temp, fLOG=fLOG) copy_data_file("sklearn_ensae_course", "iris_virginica.jpg", temp, fLOG=fLOG) execute_notebooks(temp, keepnote, lambda i, n: True, fLOG=fLOG, clean_function=clean_function_1a, dump=ensae_teaching_cs, additional_path=[os.path.dirname(keepnote[0])])