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"])