<#1590 Lazy load modules> Pull request opened by <...
# flyte-github
a
#1590 Lazy load modules Pull request opened by pingsutw TL;DR The loading time can be reduced from
6~8
seconds to
0.25~0.30
seconds. It can improve performance up to 30x when running a simple workflow.
Copy code
@task
def demo_task():
    print("foobar")


@workflow
def demo_workflow():
    demo_task()
Copy code
(flytekit-3.9) ➜ PYTHONPROFILEIMPORTTIME=1 python tuna.py &> myscript.prof && tuna myscript.prof
Before:

image

After:

image

Type ☑︎ Bug Fix ☑︎ Feature ☐ Plugin Are all requirements met? ☑︎ Code completed ☑︎ Smoke tested ☐ Unit tests added ☐ Code documentation added ☐ Any pending items have an associated Issue Complete description use
lazy_import
in the flytekit to load module lazily. Tracking Issue https://flyte-org.slack.com/archives/CP2HDHKE1/p1681239386271109?thread_ts=1681235972.845179&amp;cid=CP2HDHKE1 Follow-up issue NA flyteorg/flytekit Codecov: 38.51% of diff hit (target 70.10%) 29 other checks have passed 29/30 successful checks