From 0aac14076d01d033e4ce93b1c3afcd42ab3ea770 Mon Sep 17 00:00:00 2001 From: Jan Stourac Date: Fri, 26 Jan 2024 18:53:18 +0100 Subject: [PATCH] Fix CI ruff check for the `take_nap.py` file recently added Fixes CI ruff code-style check for recently added file [1,2] [1] https://github.com/red-hat-data-services/ods-ci/pull/1162 [2] db7d9c1c526d643b08eb558525443c8b91402dfc --- .../Files/pipeline-samples/take_nap.py | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/ods_ci/tests/Resources/Files/pipeline-samples/take_nap.py b/ods_ci/tests/Resources/Files/pipeline-samples/take_nap.py index a5ea04d4c..3907b2ace 100644 --- a/ods_ci/tests/Resources/Files/pipeline-samples/take_nap.py +++ b/ods_ci/tests/Resources/Files/pipeline-samples/take_nap.py @@ -1,32 +1,43 @@ -from kfp import dsl -from kfp import components +from kfp import components, dsl + def take_nap(naptime_secs: int) -> str: """Sleeps for secs""" from time import sleep + print(f"Sleeping for {naptime_secs} seconds: Zzzzzz ...") sleep(naptime_secs) return "I'm awake now. Did I snore?" - + + def wake_up(message: str): """Wakes up from nap printing a message""" print(message) - + + take_nap_op = components.create_component_from_func( - take_nap, base_image='registry.redhat.io/ubi8/python-39@sha256:3523b184212e1f2243e76d8094ab52b01ea3015471471290d011625e1763af61') + take_nap, + base_image="registry.redhat.io/ubi8/python-39@sha256:3523b184212e1f2243e76d8094ab52b01ea3015471471290d011625e1763af61", +) wake_up_op = components.create_component_from_func( - wake_up, base_image='registry.redhat.io/ubi8/python-39@sha256:3523b184212e1f2243e76d8094ab52b01ea3015471471290d011625e1763af61') - -@dsl.pipeline( - name='take-nap-pipeline', - description='Pipeline that sleeps for 15 mins (900 secs)' + wake_up, + base_image="registry.redhat.io/ubi8/python-39@sha256:3523b184212e1f2243e76d8094ab52b01ea3015471471290d011625e1763af61", ) + +@dsl.pipeline( + name="take-nap-pipeline", + description="Pipeline that sleeps for 15 mins (900 secs)", +) def take_nap_pipeline(naptime_secs: int = 900): - take_nap_task = take_nap_op(naptime_secs) - wake_up_task = wake_up_op(message=take_nap_task.output) + take_nap_task = take_nap_op(naptime_secs) + wake_up_task = wake_up_op(message=take_nap_task.output) + + +if __name__ == "__main__": + from kfp_tekton.compiler import TektonCompiler -if __name__ == '__main__': - from kfp_tekton.compiler import TektonCompiler - TektonCompiler().compile(take_nap_pipeline, package_path=__file__.replace('.py', '.yaml')) + TektonCompiler().compile( + take_nap_pipeline, package_path=__file__.replace(".py", ".yaml") + )