forked from red-hat-data-services/ods-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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] red-hat-data-services#1162 [2] db7d9c1
- Loading branch information
Showing
1 changed file
with
26 additions
and
15 deletions.
There are no files selected for viewing
41 changes: 26 additions & 15 deletions
41
ods_ci/tests/Resources/Files/pipeline-samples/take_nap.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
) |