https://kedro.org/ logo
#questions
Title
# questions
p

Pallavi Kumari

12/06/2022, 11:41 AM
Hi everyone, I have to call Kedro nodes or pipelines in my Django project. eg: for simulation ,we need to call kedro pipeline and want to use its output as input of django apis. please suggest some solution for this.
d

datajoely

12/06/2022, 11:49 AM
two ways come to mind 1. You use the Kedro code API to run things directly 2. You use Kedro in an isolated fashion where you write to a SQL table at the end and read that in on the Django side natively
p

Pallavi Kumari

12/07/2022, 10:24 AM
its a run time calculation, I have to read pickel file every time on click event from UI.For this I need to call kedro pipeline in django API .Is it possible?
i can't use 2nd approch becz of above mentioned issue .
d

datajoely

12/07/2022, 10:25 AM
so then option 1 is your friend
so you can create a session like this
p

Pallavi Kumari

12/07/2022, 10:25 AM
will u pls help me more with 1st option.I m not able to find anything related to that.
d

datajoely

12/07/2022, 10:26 AM
just bootstrap the project at the right path
and then the
session.run
method takes all the arguments available via the
kedro run
cli command
and then it will also return any terminal datasets
known as ‘free outputs’
i.e. don’t have any downstream uses
p

Pallavi Kumari

12/07/2022, 10:28 AM
i have to call pipeline in a function of django,can't call through cli.
d

datajoely

12/07/2022, 10:29 AM
the bootstrap mechansim finds all registered pipelines in the directory structure
p

Pallavi Kumari

12/07/2022, 10:30 AM
is there anyway through which i can directly call nodes in django function and store its output in a variable?
d

datajoely

12/07/2022, 12:44 PM
I’ve just done a quick search of GitHub and here is an example of someone doing this in a fastapi app https://github.com/hugosousa111/kedro_automobile_project/blob/4f36bcd6c6ea91f3c84794dd7dabd62c0e0bf84e/app.py#L244 The concepts should be the same