Skip to content

Commit 812ca7f

Browse files
gaoning777k8s-ci-robot
authored andcommitted
configurable timeout and namespace in docker magic (#1550)
* configurable timeout and namespace in docker magic * debug * remove debug code
1 parent 24aae0d commit 812ca7f

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

sdk/python/kfp/dsl/_pipeline_volume.py

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def __init__(self,
6868
)
6969
init_volume["persistent_volume_claim"] = pvc_volume_source
7070
super().__init__(**init_volume, **kwargs)
71-
7271
if not name_provided:
7372
self.name = "pvolume-%s" % hashlib.sha256(
7473
bytes(json.dumps(self.to_dict(), sort_keys=True), "utf-8")

sdk/python/kfp/notebook/_magic.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@
2121
def docker(line, cell):
2222
"""cell magic for %%docker"""
2323

24-
if len(line.split()) != 2:
25-
raise ValueError("usage: %%docker [gcr.io/project/image:tag] [gs://staging-bucket]")
24+
if len(line.split()) < 2:
25+
raise ValueError("usage: %%docker [gcr.io/project/image:tag] [gs://staging-bucket] [600] [kubeflow]\n\
26+
arg1(required): target image tag\n\
27+
arg2(required): staging gcs bucket\n\
28+
arg3(optional): timeout in seconds, default(600)\n\
29+
arg4(optional): namespace, default(kubeflow)")
2630
if not cell.strip():
2731
raise ValueError("Please fill in a dockerfile content in the cell.")
2832

29-
target, staging = line.split()
30-
33+
fields = line.split()
3134

3235
with tempfile.NamedTemporaryFile(mode='wt', delete=False) as f:
3336
f.write(cell)
3437

35-
build_docker_image(staging, target, f.name)
38+
build_docker_image(fields[1], fields[0], f.name, timeout=int(fields[2]) if len(fields)>=3 else 600, namespace=fields[3] if len(fields)>=4 else 'kubeflow')
3639
os.remove(f.name)
3740

3841
try:

sdk/python/tests/dsl/pipeline_volume_tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,5 @@ def test_omitting_name(self):
6868
name1 = ("pvolume-127ac63cf2013e9b95c192eb6a2c7d5a023ebeb51f6a114486e3"
6969
"1216e083a563")
7070
name2 = "provided"
71-
7271
self.assertEqual(vol1.name, name1)
7372
self.assertEqual(vol2.name, name2)

0 commit comments

Comments
 (0)