Skip to content

Commit

Permalink
Override python3 kernelspec for notebook operator if uv is used
Browse files Browse the repository at this point in the history
  • Loading branch information
petteja committed Jun 11, 2024
1 parent 625a0cb commit 520a39c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dataverk_airflow/notebook_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ def notebook_operator(
except KeyError:
image = os.getenv("KNADA_AIRFLOW_OPERATOR_IMAGE")

cmds = [f"papermill {Path(nb_path).name} output.ipynb"]
# Needs to override python3 kernelspec if using uv
if use_uv_pip_install:
cmds = [f"python -m ipykernel install --user --name=python3 --display-name 'Python (UV)' && papermill {Path(nb_path).name} output.ipynb"]
else:
cmds = [f"papermill {Path(nb_path).name} output.ipynb"]

if log_output:
cmds[-1] += " --log-output"
if override_notebook_kernelspec:
Expand Down

0 comments on commit 520a39c

Please sign in to comment.