Skip to content

Commit

Permalink
implement retry policy compilation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-mccarthy committed Jun 9, 2022
1 parent ea61750 commit 947c6cb
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions sdk/python/kfp/compiler/compiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
import os
import re
import tempfile
import unittest
from typing import Any, Dict, List, Optional
import unittest

import yaml
from absl.testing import parameterized
from click import testing
from google.protobuf import json_format
Expand All @@ -30,6 +29,7 @@
from kfp.components.types import type_utils
from kfp.dsl import PipelineTaskFinalStatus
from kfp.pipeline_spec import pipeline_spec_pb2
import yaml

VALID_PRODUCER_COMPONENT_SAMPLE = components.load_component_from_text("""
name: producer
Expand Down Expand Up @@ -977,5 +977,36 @@ def test_compile_pipelines(self, file: str):
self._test_compile_py_to_yaml(file)


class TestSetRetryCompilation(unittest.TestCase):

def test_set_retry(self):

@dsl.component
def hello_world(text: str) -> str:
"""Hello world component."""
return text

@dsl.pipeline(name='hello-world', description='A simple intro pipeline')
def pipeline_hello_world(text: str = 'hi there'):
"""Hello world pipeline."""

hello_world(text=text).set_retry(
num_retries=3,
backoff_duration='30s',
backoff_factor=1.0,
backoff_max_duration='3h',
)

with tempfile.TemporaryDirectory() as tempdir:
package_path = os.path.join(tempdir, 'pipeline.yaml')
compiler.Compiler().compile(
pipeline_func=pipeline_hello_world, package_path=package_path)
pipeline_spec = pipeline_spec_from_file(package_path)

self.assertEqual(
pipeline_spec.root.dag.tasks['hello-world'].retry_policy
.max_retry_count, 3)


if __name__ == '__main__':
unittest.main()

0 comments on commit 947c6cb

Please sign in to comment.