acoustic-carpenter-78188
04/14/2023, 4:28 AMdisable_deck parameter=False. For example:
from flytekit import task, Resources, workflow
from flytekit.core.utils import timeit
@task(
disable_deck=False,
limits=Resources(mem="4Gi", cpu="1"),
)
def t1():
import time
# Test timeit used as a decorator
@timeit("Download data from s3")
def download_data():
time.sleep(1)
download_data()
# Test timeit used as a context manager
# Simulate a user using a very long name for a time measurement
with timeit("Test long string "*20):
time.sleep(1)
# Simulate multiple time measurements
for i in range(10):
with timeit(f"Run small tasks {i}"):
# The 'print' function will execute quickly compared to 'time.sleep(1)'.
# This is used to test if the timeline graph can accurately represent
# measurements with significantly varying execution times.
print("hello world")
@workflow
def wf():
t1()
if __name__ == "__main__":
wf()
Tests(also tested in sandbox):
image▾
image▾
image▾
acoustic-carpenter-78188
04/14/2023, 4:28 AMacoustic-carpenter-78188
05/01/2023, 11:40 PM