diff --git a/benchmarking/mrme.py b/benchmarking/mrme.py index 04c0a61..7a79e8b 100644 --- a/benchmarking/mrme.py +++ b/benchmarking/mrme.py @@ -1,6 +1,6 @@ from meow_base.patterns import FileEventPattern -from meow_base.recipes import getRecipeFromNotebook +from meow_base.recipes import get_recipe_from_notebook from shared import run_test, MRME @@ -15,7 +15,7 @@ def multiple_rules_multiple_events(job_count:int, REPEATS, job_counter, requeste ) patterns[pattern.name] = pattern - recipe = getRecipeFromNotebook("recipe_one", "test.ipynb") + recipe = get_recipe_from_notebook("recipe_one", "test.ipynb") recipes = { recipe.name: recipe diff --git a/benchmarking/mrse.py b/benchmarking/mrse.py index 48efb7c..def47cd 100644 --- a/benchmarking/mrse.py +++ b/benchmarking/mrse.py @@ -1,6 +1,6 @@ from meow_base.patterns import FileEventPattern -from meow_base.recipes import getRecipeFromNotebook +from meow_base.recipes import get_recipe_from_notebook from shared import run_test, MRSE @@ -15,7 +15,7 @@ def multiple_rules_single_event(job_count:int, REPEATS, job_counter, requested_j ) patterns[pattern.name] = pattern - recipe = getRecipeFromNotebook("recipe_one", "test.ipynb") + recipe = get_recipe_from_notebook("recipe_one", "test.ipynb") recipes = { recipe.name: recipe diff --git a/benchmarking/srme.py b/benchmarking/srme.py index e0ccfba..b7a0f8e 100644 --- a/benchmarking/srme.py +++ b/benchmarking/srme.py @@ -1,6 +1,6 @@ from meow_base.patterns import FileEventPattern -from meow_base.recipes import getRecipeFromNotebook +from meow_base.recipes import get_recipe_from_notebook from shared import run_test, SRME @@ -14,7 +14,7 @@ def single_rule_multiple_events(job_count:int, REPEATS, job_counter, requested_j ) patterns[pattern.name] = pattern - recipe = getRecipeFromNotebook("recipe_one", "test.ipynb") + recipe = get_recipe_from_notebook("recipe_one", "test.ipynb") recipes = { recipe.name: recipe diff --git a/benchmarking/srsep.py b/benchmarking/srsep.py index 582922e..d42ae87 100644 --- a/benchmarking/srsep.py +++ b/benchmarking/srsep.py @@ -1,6 +1,6 @@ from meow_base.patterns import FileEventPattern -from meow_base.recipes import getRecipeFromNotebook +from meow_base.recipes import get_recipe_from_notebook from meow_base.functionality.meow import create_parameter_sweep from shared import run_test, SRSEP @@ -16,7 +16,7 @@ def single_rule_single_event_parallel(job_count:int, REPEATS, job_counter, reque ) patterns[pattern.name] = pattern - recipe = getRecipeFromNotebook("recipe_one", "test.ipynb") + recipe = get_recipe_from_notebook("recipe_one", "test.ipynb") recipes = { recipe.name: recipe diff --git a/benchmarking/srsps.py b/benchmarking/srsps.py index 40ad33a..7a18c7e 100644 --- a/benchmarking/srsps.py +++ b/benchmarking/srsps.py @@ -1,6 +1,6 @@ from meow_base.patterns import FileEventPattern -from meow_base.recipes import getRecipeFromNotebook +from meow_base.recipes import get_recipe_from_notebook from shared import run_test, SRSES @@ -17,7 +17,7 @@ def single_rule_single_event_sequential(job_count:int, REPEATS, job_counter, req ) patterns[pattern.name] = pattern - recipe = getRecipeFromNotebook("recipe_two", "sequential.ipynb") + recipe = get_recipe_from_notebook("recipe_two", "sequential.ipynb") recipes = { recipe.name: recipe diff --git a/recipes/__init__.py b/recipes/__init__.py index b4d3dbf..eb28822 100644 --- a/recipes/__init__.py +++ b/recipes/__init__.py @@ -1,4 +1,4 @@ from .jupyter_notebook_recipe import JupyterNotebookRecipe, PapermillHandler, \ - getRecipeFromNotebook + get_recipe_from_notebook from .python_recipe import PythonRecipe, PythonHandler \ No newline at end of file diff --git a/recipes/jupyter_notebook_recipe.py b/recipes/jupyter_notebook_recipe.py index f6e2156..ad0afde 100644 --- a/recipes/jupyter_notebook_recipe.py +++ b/recipes/jupyter_notebook_recipe.py @@ -182,12 +182,11 @@ class PapermillHandler(BaseHandler): # Send job directory, as actual definitons will be read from within it self.to_runner.send(job_dir) -#TODO test me -def getRecipeFromNotebook(name:str, notebook_filename:str, +def get_recipe_from_notebook(name:str, notebook_filename:str, parameters:Dict[str,Any]={}, requirements:Dict[str,Any]={} )->JupyterNotebookRecipe: valid_existing_file_path(notebook_filename, extension=".ipynb") - check_type(name, str, hint="getRecipeFromNotebook.name") + check_type(name, str, hint="get_recipe_from_notebook.name") notebook_code = read_notebook(notebook_filename) diff --git a/tests/test_patterns.py b/tests/test_patterns.py index bff1519..2a44032 100644 --- a/tests/test_patterns.py +++ b/tests/test_patterns.py @@ -15,7 +15,6 @@ from meow_base.recipes.jupyter_notebook_recipe import JupyterNotebookRecipe from shared import setup, teardown, BAREBONES_NOTEBOOK, TEST_MONITOR_BASE - def patterns_equal(tester, pattern_one, pattern_two): tester.assertEqual(pattern_one.name, pattern_two.name) tester.assertEqual(pattern_one.recipe, pattern_two.recipe) diff --git a/tests/test_recipes.py b/tests/test_recipes.py index 29adac2..fdda6bc 100644 --- a/tests/test_recipes.py +++ b/tests/test_recipes.py @@ -20,7 +20,7 @@ from meow_base.functionality.meow import create_job, create_rules, create_rule, create_watchdog_event from meow_base.patterns.file_event_pattern import FileEventPattern from meow_base.recipes.jupyter_notebook_recipe import JupyterNotebookRecipe, \ - PapermillHandler, papermill_job_func + PapermillHandler, papermill_job_func, get_recipe_from_notebook from meow_base.recipes.python_recipe import PythonRecipe, PythonHandler, python_job_func from meow_base.rules import FileEventPythonRule, FileEventJupyterNotebookRule from shared import setup, teardown, BAREBONES_PYTHON_SCRIPT, \ @@ -440,6 +440,19 @@ class JupyterNotebookTests(unittest.TestCase): }) self.assertTrue(status) + # Test function correctly creates Recipe directly from notebook + def testGetRecipeFromNotebook(self)->None: + notebook_path = os.path.join(TEST_MONITOR_BASE, "notebook.ipynb") + write_notebook(COMPLETE_NOTEBOOK, notebook_path) + + self.assertTrue(os.path.exists(notebook_path)) + + recipe = get_recipe_from_notebook("name", notebook_path) + + self.assertIsInstance(recipe, JupyterNotebookRecipe) + self.assertEqual(recipe.name, "name") + self.assertEqual(recipe.recipe, COMPLETE_NOTEBOOK) + class PythonTests(unittest.TestCase): def setUp(self)->None: