From bb62b321a55d2410d43c66edbb6c2241e1bb81fd Mon Sep 17 00:00:00 2001 From: qimingj Date: Tue, 6 Nov 2018 20:06:58 -0800 Subject: [PATCH] Fix an issue that %%docker doesn't work. (#119) --- sdk/python/kfp/notebook/_magic.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/python/kfp/notebook/_magic.py b/sdk/python/kfp/notebook/_magic.py index a1bb1b5ce9..644eb49bf8 100644 --- a/sdk/python/kfp/notebook/_magic.py +++ b/sdk/python/kfp/notebook/_magic.py @@ -21,6 +21,7 @@ except ImportError: from kfp.compiler import build_docker_image +import os import tempfile @@ -35,8 +36,9 @@ def docker(line, cell): target, staging = line.split() - with tempfile.NamedTemporaryFile(mode='wt') as f: - f.write(cell) - build_docker_image(staging, target, f.name) - + with tempfile.NamedTemporaryFile(mode='wt', delete=False) as f: + f.write(cell) + + build_docker_image(staging, target, f.name) + os.remove(f.name)