From a56abeeed2eea1f3273bac1d70bda39d55413214 Mon Sep 17 00:00:00 2001 From: Michael Schuster Date: Tue, 6 Aug 2024 10:52:58 +0200 Subject: [PATCH] Additional warning --- src/zenml/utils/notebook_utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/zenml/utils/notebook_utils.py b/src/zenml/utils/notebook_utils.py index e5c59006619..4b228c04e84 100644 --- a/src/zenml/utils/notebook_utils.py +++ b/src/zenml/utils/notebook_utils.py @@ -178,8 +178,14 @@ def extract_notebook_cell_code(notebook_path: str, cell_id: str) -> str: cell["cell_type"], ) - # TODO: Should we exclude lines starting with special symbols here? - # Or would that mess with some code? + if any(line.startswith(("%", "!")) for line in cell["source"]): + logger.warning( + "Some lines in your notebook cell start with a `!` or `%` " + "character. Running a ZenML step remotely from a notebook " + "only works if the cell only contains python code. If any " + "of these lines contain Jupyter notebook magic commands, " + "remove them and try again." + ) return "".join(cell["source"])