Kedro with FastAPI - improving performance of KedroSession.load_context()
#2134
illia-shkroba
started this conversation in
Idea
Replies: 2 comments
-
This is really cool - analysis, thanks @illia-shkroba ! |
Beta Was this translation helpful? Give feedback.
0 replies
-
@illia-shkroba Sorry for the late response. There are definitely rooms to improve to reduce the overhead. Meanwhile, if you pipeline do not involve saving any versioned datasets, using the Runner object directly with pipelines and catalog would mitigate the problem. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello.
I'm trying to build RestAPI with FastAPI that runs Kedro Pipeline under the hood and come up with this solution:
session.run("math")
runs a simple pipeline that calculates a variance for the input:[1, 2, 3]
.The solution seems to work as expected, but it takes nearly 2.1 seconds to finish a request:
I've noticed that
session.load_context()
takes about 1 second to finish. Also I've found thatload_context()
is used bysession.run()
:It seems that
load_context()
is called twice during the request:get_context()
.session.run()
.I've tried to cache the result of
session.load_context()
like this:And by doing that I've decreased the request processing time to 1.06 seconds.
Do you have any suggestions on how I can further optimize the
session.run()
? Should I try a different approach with a plainDataCatalog
/SequentialRunner
? Or maybe Kedro's implementation ofload_context()
should be modified to use some caching?Beta Was this translation helpful? Give feedback.
All reactions